Merge
authorasaha
Tue, 25 Sep 2012 11:48:00 -0700
changeset 14225 d70ba7fdeae0
parent 14224 45edf328226f (current diff)
parent 13765 08a2396d4c97 (diff)
child 14226 3c870f6d9139
child 16070 4d4f21f5c4f4
Merge
jdk/make/common/Defs-embedded.gmk
jdk/make/common/Release-embedded.gmk
--- a/.hgignore	Mon Sep 24 17:00:40 2012 +0400
+++ b/.hgignore	Tue Sep 25 11:48:00 2012 -0700
@@ -1,6 +1,7 @@
 ^build/
 ^dist/
-/nbproject/private/
+nbproject/private/
 ^webrev
 ^.hgtip
+^.bridge2
 .DS_Store
--- a/.hgtags	Mon Sep 24 17:00:40 2012 +0400
+++ b/.hgtags	Tue Sep 25 11:48:00 2012 -0700
@@ -176,3 +176,5 @@
 b67041a6cb508da18d2f5c7687e6a31e08bea4fc jdk8-b52
 c7aa5cca1c01689a7b1a92411daf83684af05a33 jdk8-b53
 7c6aa31ff1b2ae48c1c686ebe1aadf0c3da5be15 jdk8-b54
+319f583f66db47395fa86127dd3ddb729eb7c64f jdk8-b55
+ffe6bce5a521be40146af2ac03c509b7bac30595 jdk8-b56
--- a/.hgtags-top-repo	Mon Sep 24 17:00:40 2012 +0400
+++ b/.hgtags-top-repo	Tue Sep 25 11:48:00 2012 -0700
@@ -176,3 +176,5 @@
 8d24def5ceb3b8f2e857f2e18b2804fc59eecf8d jdk8-b52
 febd7ff5280067ca482faaeb9418ae88764c1a35 jdk8-b53
 c1a277c6022affbc6855bdfb039511e73fbe2395 jdk8-b54
+b85b44cced2406792cfb9baab1377ff03e7001d8 jdk8-b55
+76844579fa4b30929731115b237e477181a82394 jdk8-b56
--- a/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,16 @@
 # questions.
 #
 
+# If NEWBUILD is defined, use the new build-infra Makefiles and configure.
+#     See NewMakefile.gmk for more information.
+
+ifeq ($(NEWBUILD),true)
+
+  # The new top level Makefile
+  include NewMakefile.gmk
+
+else # Original Makefile logic
+
 BUILD_PARENT_DIRECTORY=.
 
 # Basename of any originally supplied ALT_OUTPUTDIR directory
@@ -557,3 +567,5 @@
 # Force target
 FRC:
 
+endif # Original Makefile logic
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NewMakefile.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,211 @@
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  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.
+#
+
+# Utilities used in this Makefile
+BASENAME=basename
+CAT=cat
+CD=cd
+CMP=cmp
+CP=cp
+ECHO=echo
+MKDIR=mkdir
+PWD=pwd
+SH=sh
+ifeq ($(PLATFORM),windows)
+  ZIP=zip
+else
+  # store symbolic links as the link
+  ZIP=zip -y
+endif
+# Insure we have a path that looks like it came from pwd
+#   (This is mostly for Windows sake and drive letters)
+define UnixPath # path
+$(shell (cd "$1" && $(PWD)))
+endef
+
+# Current root directory
+CURRENT_DIRECTORY := $(shell $(PWD))
+
+# Build directory root
+BUILD_DIR_ROOT = $(CURRENT_DIRECTORY)/build
+
+# All configured Makefiles to run
+ALL_MAKEFILES = $(wildcard $(BUILD_DIR_ROOT)/*-*/Makefile)
+
+# All bundles to create
+ALL_IMAGE_DIRS = $(wildcard $(BUILD_DIR_ROOT)/*-*/images/*-image)
+
+# Build all the standard 'all', 'images', and 'clean' targets
+all images clean: checks
+	@if [ "$(ALL_MAKEFILES)" = "" ] ; then \
+	  $(ECHO) "ERROR: No configurations to build"; exit 1; \
+	fi
+	@for bdir in $(dir $(ALL_MAKEFILES)) ; do \
+	  $(ECHO) "$(CD) $${bdir} && $(MAKE) $(EXTRA_MAKE_ARGS) $@" ; \
+	  $(CD) $${bdir} && $(MAKE) $(EXTRA_MAKE_ARGS) $@ ; \
+	done
+
+# Bundle creation
+bundles:
+	@if [ "$(ALL_IMAGE_DIRS)" = "" ] ; then \
+	  $(ECHO) "ERROR: No images to bundle"; exit 1; \
+	fi
+	@for i in $(ALL_IMAGE_DIRS) ; do \
+          $(MKDIR) -p $${i}/../../bundles && \
+          $(RM) $${i}/../../bundles/`$(BASENAME) $${i}`.zip && \
+	  $(ECHO) "$(CD) $${i} && $(ZIP) -q -r ../../bundles/`$(BASENAME) $${i}`.zip ."  && \
+	  $(CD) $${i} && $(ZIP) -q -r ../../bundles/`$(BASENAME) $${i}`.zip . ; \
+	done
+
+# Clobber all the built files
+clobber::
+	$(RM) -r $(BUILD_DIR_ROOT)
+
+# Make various checks to insure the build will be successful
+#   Possibilities:
+#     * Check that if any closed repo is provided, they all must be.
+#     * Check that all open repos exist, at least until we are ready for some
+#       kind of partial build.
+checks:
+	@$(ECHO) "No checks yet"
+
+# Keep track of phony targets
+PHONY_LIST += all images clean clobber checks
+
+###########################################################################
+# To help in adoption of the new configure&&make build process, a bridge
+#   build will use the old settings to run configure and do the build.
+
+# Build with the configure bridge
+bridgeBuild: bridge2configure images
+
+# Bridge from old Makefile ALT settings to configure options
+bridge2configure: .bridge2configureOpts
+	$(CD) common/makefiles && sh ../autoconf/configure $(strip $(shell $(CAT) $<))
+
+# Create a file with configure options created from old Makefile mechanisms.
+.bridge2configureOpts: .bridge2configureOptsLatest
+	$(RM) $@
+	$(CP) $< $@
+
+# In case make was invoked from a specific path
+_MAKE_COMMAND_PATH:=$(firstword $(MAKE))
+ifneq ($(dir $(_MAKE_COMMAND_PATH)),./)
+  # This could be removed someday if JPRT was fixed and we could assume that
+  #    the path to make was always in PATH.
+  MAKE_BINDIR:=$(call UnixPath,$(dir $(_MAKE_COMMAND_PATH)))
+  NEWPATH:=$(MAKE_BINDIR):${PATH}
+  PATH:=$(NEWPATH)
+  export PATH
+  MAKE_COMMAND=$(MAKE_BINDIR)/$(notdir $(_MAKE_COMMAND_PATH))
+else
+  MAKE_COMMAND=$(_MAKE_COMMAND_PATH)
+endif
+
+# Use this file to only change when obvious things have changed
+.bridge2configureOptsLatest: FRC
+	$(RM) $@.tmp
+	@$(ECHO) " MAKE=$(MAKE_COMMAND) " >> $@.tmp
+	@$(ECHO) " --with-debug-level=$(if $(DEBUG_LEVEL),$(DEBUG_LEVEL),release) " >> $@.tmp
+ifdef ARCH_DATA_MODEL
+	@$(ECHO) " --with-target-bits=$(ARCH_DATA_MODEL) " >> $@.tmp
+endif
+ifdef ALT_PARALLEL_COMPILE_JOBS
+	@$(ECHO) " --with-num-cores=$(ALT_PARALLEL_COMPILE_JOBS) " >> $@.tmp
+endif
+ifdef ALT_BOOTDIR
+	@$(ECHO) " --with-boot-jdk=$(call UnixPath,$(ALT_BOOTDIR)) " >> $@.tmp
+endif
+ifdef ALT_CUPS_HEADERS_PATH
+	@$(ECHO) " --with-cups-include=$(call UnixPath,$(ALT_CUPS_HEADERS_PATH)) " >> $@.tmp
+endif
+ifdef ALT_FREETYPE_HEADERS_PATH
+	@$(ECHO) " --with-freetype=$(call UnixPath,$(ALT_FREETYPE_HEADERS_PATH)/..) " >> $@.tmp
+endif
+	@if [ -f $@ ] ; then \
+          if ! $(CMP) $@ $@.tmp > /dev/null ; then \
+            $(CP) $@.tmp $@ ; \
+          fi ; \
+        else \
+          $(CP) $@.tmp $@ ; \
+        fi
+	$(RM) $@.tmp
+
+# Clobber all the built files
+clobber:: bridge2clobber
+bridge2clobber::
+	$(RM) .bridge2*
+
+# Keep track of phony targets
+PHONY_LIST += bridge2configure bridgeBuild bridge2clobber
+
+###########################################################################
+# Javadocs
+#
+
+javadocs:
+	cd common/makefiles && $(MAKE) -f MakefileJavadoc.gmk
+
+# Keep track of phony targets
+PHONY_LIST += javadocs
+
+###########################################################################
+# JPRT targets
+
+ifndef JPRT_ARCHIVE_BUNDLE
+  JPRT_ARCHIVE_BUNDLE=/tmp/jprt_bundles/j2sdk-image.zip
+endif
+
+jprt_build_product: DEBUG_LEVEL=release
+jprt_build_product: BUILD_DIRNAME=*-release
+jprt_build_product: jprt_build_generic
+
+jprt_build_fastdebug: DEBUG_LEVEL=fastdebug
+jprt_build_fastdebug: BUILD_DIRNAME=*-fastdebug
+jprt_build_fastdebug: jprt_build_generic
+
+jprt_build_debug: DEBUG_LEVEL=slowdebug
+jprt_build_debug: BUILD_DIRNAME=*-debug
+jprt_build_debug: jprt_build_generic
+
+jprt_build_generic: EXTRA_MAKE_ARGS=LOG=nofile,info
+jprt_build_generic: $(JPRT_ARCHIVE_BUNDLE)
+
+$(JPRT_ARCHIVE_BUNDLE): bridgeBuild bundles
+	$(MKDIR) -p $(@D)
+	$(RM) $@
+	$(CP) $(BUILD_DIR_ROOT)/$(BUILD_DIRNAME)/bundles/j2sdk-image.zip $@
+
+# Keep track of phony targets
+PHONY_LIST += jprt_build_product jprt_build_fastdebug jprt_build_debug \
+              jprt_build_generic
+
+###########################################################################
+# Phony targets
+.PHONY: $(PHONY_LIST)
+
+# Force target
+FRC:
+
--- a/common/autoconf/autogen.sh	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/autogen.sh	Tue Sep 25 11:48:00 2012 -0700
@@ -23,18 +23,38 @@
 #
 
 script_dir=`dirname $0`
-closed_script_dir="$script_dir/../../jdk/make/closed/autoconf"
 
 # Create a timestamp as seconds since epoch
-TIMESTAMP=`date +%s`
+if test "x`uname -s`" = "xSunOS"; then
+  # date +%s is not available on Solaris, use this workaround
+  # from http://solarisjedi.blogspot.co.uk/2006/06/solaris-date-command-and-epoch-time.html
+  TIMESTAMP=`/usr/bin/truss /usr/bin/date 2>&1 |  nawk -F= '/^time\(\)/ {gsub(/ /,"",$2);print $2}'`
+  # On Solaris /bin/sh doesn't support test -e but /usr/bin/test does.
+  TEST=`which test`
+else
+  TIMESTAMP=`date +%s`
+  TEST="test"
+fi
 
+if $TEST "$CUSTOM_CONFIG_DIR" = ""; then
+  custom_script_dir="$script_dir/../../jdk/make/closed/autoconf"
+else
+  custom_script_dir=$CUSTOM_CONFIG_DIR
+fi
+
+custom_hook=$custom_script_dir/custom-hook.m4
+
+echo Generating generated-configure.sh
 cat $script_dir/configure.ac  | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | autoconf -W all -I$script_dir - > $script_dir/generated-configure.sh
 rm -rf autom4te.cache
 
-if test -e $closed_script_dir/closed-hook.m4; then
-  # We have closed sources available; also generate configure script
-  # with closed hooks compiled in.
+if $TEST -e $custom_hook; then
+  echo Generating custom generated-configure.sh
+  # We have custom sources available; also generate configure script
+  # with custom hooks compiled in.
   cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | \
-    sed -e "s|AC_DEFUN_ONCE(\[CLOSED_HOOK\])|m4_include([$closed_script_dir/closed-hook.m4])|" | autoconf -W all -I$script_dir - > $closed_script_dir/generated-configure.sh
+    sed -e "s|AC_DEFUN_ONCE(\[CUSTOM_HOOK\])|m4_include([$custom_hook])|" | autoconf -W all -I$script_dir - > $custom_script_dir/generated-configure.sh
   rm -rf autom4te.cache
+else
+  echo No custom hook found:  $custom_hook
 fi
--- a/common/autoconf/basics.m4	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/basics.m4	Tue Sep 25 11:48:00 2012 -0700
@@ -34,7 +34,7 @@
     fi
 ])
 
-AC_DEFUN([WHICHCMD],
+AC_DEFUN([SET_FULL_PATH],
 [
     # Translate "gcc -E" into "`which gcc` -E" ie
     # extract the full path to the binary and at the
@@ -46,7 +46,7 @@
     cdr="${tmp#* }"
     # On windows we want paths without spaces.
     if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
-        WHICHCMD_SPACESAFE(car)
+        SET_FULL_PATH_SPACESAFE(car)
     else
         # "which" is not portable, but is used here
         # because we know that the command exists!
@@ -66,15 +66,19 @@
     HAS_SPACE=`echo "[$]$1" | grep " "`
     if test "x$HAS_SPACE" != x; then
         if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
             $1=`$CYGPATH -s -m -a "[$]$1"`
-            $1=`$CYGPATH -u "[$]$1"`            
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            $1=`$ECHO "[$]$1" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            $1=`$CYGPATH -u "[$]$1"`
         else
             AC_MSG_ERROR([You cannot have spaces in $2! "[$]$1"])
         fi
     fi
 ])
 
-AC_DEFUN([WHICHCMD_SPACESAFE],
+AC_DEFUN([SET_FULL_PATH_SPACESAFE],
 [
     # Translate long cygdrive or C:\sdfsf path
     # into a short mixed mode path that has no
@@ -148,15 +152,16 @@
 AC_SUBST(CONFIGURE_COMMAND_LINE)
 DATE_WHEN_CONFIGURED=`LANG=C date`
 AC_SUBST(DATE_WHEN_CONFIGURED)
+])
 
+# Setup basic configuration paths, and platform-specific stuff related to PATHs.
+AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
+[
 # Locate the directory of this script.
 SCRIPT="[$]0"
-REMOVE_SYMBOLIC_LINKS(SCRIPT)        
+REMOVE_SYMBOLIC_LINKS(SCRIPT)
 AUTOCONF_DIR=`dirname [$]0`
-])
 
-AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
-[
 # Where is the source? It is located two levels above the configure script.
 CURDIR="$PWD"
 cd "$AUTOCONF_DIR/../.."
@@ -172,18 +177,12 @@
 
 SPACESAFE(SRC_ROOT,[the path to the source root])
 SPACESAFE(CURDIR,[the path to the current directory])
-])
 
-AC_DEFUN_ONCE([BASIC_SETUP_SEARCHPATH],
-[
 if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
     # Add extra search paths on solaris for utilities like ar and as etc...
     PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin"
 fi
-])
 
-AC_DEFUN_ONCE([BASIC_SETUP_PATH_SEP],
-[
 # For cygwin we need cygpath first, since it is used everywhere.
 AC_PATH_PROG(CYGPATH, cygpath)
 PATH_SEP=":"
@@ -194,6 +193,36 @@
     PATH_SEP=";"
 fi
 AC_SUBST(PATH_SEP)
+
+# You can force the sys-root if the sys-root encoded into the cross compiler tools
+# is not correct.
+AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
+  [pass this sys-root to the compilers and linker (useful if the sys-root encoded in
+   the cross compiler tools is incorrect)])])
+
+if test "x$with_sys_root" != x; then
+  SYS_ROOT=$with_sys_root
+else
+  SYS_ROOT=/
+fi
+AC_SUBST(SYS_ROOT)
+
+AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
+  [search this directory for (cross-compiling) compilers and tools])], [TOOLS_DIR=$with_tools_dir])
+
+AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
+  [use this directory as base for tools-dir and sys-root (for cross-compiling)])],
+  [
+    if test "x$with_sys_root" != x; then
+      AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time])
+    fi
+    if test "x$with_tools_dir" != x; then
+      AC_MSG_ERROR([Cannot specify both --with-devkit and --with-tools-dir at the same time])
+    fi
+    TOOLS_DIR=$with_devkit/bin
+    SYS_ROOT=$with_devkit/$host_alias/libc
+  ])
+
 ])
 
 AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
@@ -236,7 +265,13 @@
 AC_CONFIG_HEADERS([$OUTPUT_ROOT/config.h:$AUTOCONF_DIR/config.h.in])
 # The spec.gmk file contains all variables for the make system.
 AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
-# The spec.sh file contains variables for compare{images|-objects}.sh scrips.
+# The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
+AC_CONFIG_FILES([$OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in])
+# The bootcycle-spec.gmk file contains support for boot cycle builds.
+AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in])
+# The compare.sh is used to compare the build output to other builds.
+AC_CONFIG_FILES([$OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in])
+# Spec.sh is currently used by compare-objects.sh
 AC_CONFIG_FILES([$OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in])
 # The generated Makefile knows where the spec.gmk is and where the source is.
 # You can run make from the OUTPUT_ROOT, or from the top-level Makefile
@@ -261,6 +296,79 @@
 
 #%%% Simple tools %%%
 
+# Check if we have found a usable version of make
+# $1: the path to a potential make binary (or empty)
+# $2: the description on how we found this
+AC_DEFUN([BASIC_CHECK_MAKE_VERSION],
+[
+  MAKE_CANDIDATE="$1"
+  DESCRIPTION="$2"
+  if test "x$MAKE_CANDIDATE" != x; then
+    AC_MSG_NOTICE([Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION])
+    SET_FULL_PATH(MAKE_CANDIDATE)
+    MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
+    IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
+    if test "x$IS_GNU_MAKE" = x; then
+      AC_MSG_NOTICE([Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring.])
+    else
+      IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[[12346789]]'`
+      if test "x$IS_MODERN_MAKE" = x; then
+        AC_MSG_NOTICE([Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring.])
+      else 
+        FOUND_MAKE=$MAKE_CANDIDATE
+      fi
+    fi
+  fi
+])
+
+# Goes looking for a usable version of GNU make.
+AC_DEFUN([BASIC_CHECK_GNU_MAKE],
+[
+  # We need to find a recent version of GNU make. Especially on Solaris, this can be tricky.
+  if test "x$MAKE" != x; then
+    # User has supplied a make, test it.
+    if test ! -f "$MAKE"; then
+      AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not found.])
+    fi
+    BASIC_CHECK_MAKE_VERSION("$MAKE", [user supplied MAKE=])
+    if test "x$FOUND_MAKE" = x; then
+      AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer.])
+    fi
+  else
+    # Try our hardest to locate a correct version of GNU make
+    AC_PATH_PROGS(CHECK_GMAKE, gmake)
+    BASIC_CHECK_MAKE_VERSION("$CHECK_GMAKE", [gmake in PATH])
+
+    if test "x$FOUND_MAKE" = x; then
+      AC_PATH_PROGS(CHECK_MAKE, make)
+      BASIC_CHECK_MAKE_VERSION("$CHECK_MAKE", [make in PATH])
+    fi
+
+    if test "x$FOUND_MAKE" = x; then
+      if test "x$TOOLS_DIR" != x; then
+        # We have a tools-dir, check that as well before giving up.
+        OLD_PATH=$PATH
+        PATH=$TOOLS_DIR:$PATH
+        AC_PATH_PROGS(CHECK_TOOLSDIR_GMAKE, gmake)
+        BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_GMAKE", [gmake in tools-dir])
+        if test "x$FOUND_MAKE" = x; then
+          AC_PATH_PROGS(CHECK_TOOLSDIR_MAKE, make)
+          BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_MAKE", [make in tools-dir])
+        fi
+        PATH=$OLD_PATH
+      fi
+    fi
+
+    if test "x$FOUND_MAKE" = x; then
+      AC_MSG_ERROR([Cannot find GNU make 3.81 or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure.])
+    fi
+  fi
+
+  MAKE=$FOUND_MAKE
+  AC_SUBST(MAKE)
+  AC_MSG_NOTICE([Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)])
+])
+
 AC_DEFUN([BASIC_CHECK_FIND_DELETE],
 [
     # Test if find supports -delete
@@ -283,10 +391,30 @@
     rmdir $DELETEDIR
 ])
 
+# Test that variable $1 denoting a program is not empty. If empty, exit with an error.
+# $1: variable to check
+# $2: executable name to print in warning (optional)
 AC_DEFUN([CHECK_NONEMPTY],
 [
-    # Test that variable $1 is not empty.
-    if test "" = "[$]$1"; then AC_MSG_ERROR(Could not find translit($1,A-Z,a-z) !); fi
+    if test "x[$]$1" = x; then
+        if test "x$2" = x; then
+          PROG_NAME=translit($1,A-Z,a-z)
+        else
+          PROG_NAME=$2
+        fi
+        AC_MSG_NOTICE([Could not find $PROG_NAME!])
+        AC_MSG_ERROR([Cannot continue])
+    fi
+])
+
+# Does AC_PATH_PROG followed by CHECK_NONEMPTY.
+# Arguments as AC_PATH_PROG:
+# $1: variable to set
+# $2: executable name to look for
+AC_DEFUN([BASIC_REQUIRE_PROG],
+[
+    AC_PATH_PROGS($1, $2)
+    CHECK_NONEMPTY($1, $2)
 ])
 
 AC_DEFUN_ONCE([BASIC_SETUP_TOOLS],
@@ -295,90 +423,68 @@
 # and can be expected to be found in the default PATH. These tools are
 # used by configure. Nor are these tools expected to be found in the
 # devkit from the builddeps server either, since they are
-# needed to download the devkit. 
+# needed to download the devkit.
+
+# First are all the simple required tools.
+BASIC_REQUIRE_PROG(BASENAME, basename)
+BASIC_REQUIRE_PROG(CAT, cat)
+BASIC_REQUIRE_PROG(CHMOD, chmod)
+BASIC_REQUIRE_PROG(CMP, cmp)
+BASIC_REQUIRE_PROG(CP, cp)
+BASIC_REQUIRE_PROG(CPIO, cpio)
+BASIC_REQUIRE_PROG(CUT, cut)
+BASIC_REQUIRE_PROG(DATE, date)
+BASIC_REQUIRE_PROG(DF, df)
+BASIC_REQUIRE_PROG(DIFF, [gdiff diff])
+BASIC_REQUIRE_PROG(ECHO, echo)
+BASIC_REQUIRE_PROG(EXPR, expr)
+BASIC_REQUIRE_PROG(FILE, file)
+BASIC_REQUIRE_PROG(FIND, find)
+BASIC_REQUIRE_PROG(HEAD, head)
+BASIC_REQUIRE_PROG(LN, ln)
+BASIC_REQUIRE_PROG(LS, ls)
+BASIC_REQUIRE_PROG(MKDIR, mkdir)
+BASIC_REQUIRE_PROG(MV, mv)
+BASIC_REQUIRE_PROG(PRINTF, printf)
+BASIC_REQUIRE_PROG(SH, sh)
+BASIC_REQUIRE_PROG(SORT, sort)
+BASIC_REQUIRE_PROG(TAIL, tail)
+BASIC_REQUIRE_PROG(TAR, tar)
+BASIC_REQUIRE_PROG(TEE, tee)
+BASIC_REQUIRE_PROG(TOUCH, touch)
+BASIC_REQUIRE_PROG(TR, tr)
+BASIC_REQUIRE_PROG(UNIQ, uniq)
+BASIC_REQUIRE_PROG(UNZIP, unzip)
+BASIC_REQUIRE_PROG(WC, wc)
+BASIC_REQUIRE_PROG(XARGS, xargs)
+BASIC_REQUIRE_PROG(ZIP, zip)
+
+# Then required tools that require some special treatment.
 AC_PROG_AWK
 CHECK_NONEMPTY(AWK)
-AC_PATH_PROG(CAT, cat)
-CHECK_NONEMPTY(CAT)
-AC_PATH_PROG(CHMOD, chmod)
-CHECK_NONEMPTY(CHMOD)
-AC_PATH_PROG(CP, cp)
-CHECK_NONEMPTY(CP)
-AC_PATH_PROG(CPIO, cpio)
-CHECK_NONEMPTY(CPIO)
-AC_PATH_PROG(CUT, cut)
-CHECK_NONEMPTY(CUT)
-AC_PATH_PROG(DATE, date)
-CHECK_NONEMPTY(DATE)
-AC_PATH_PROG(DF, df)
-CHECK_NONEMPTY(DF)
-AC_PATH_PROG(DIFF, diff)
-CHECK_NONEMPTY(DIFF)
-# Warning echo is really, really unportable!!!!! Different
-# behaviour in bash and dash and in a lot of other shells!
-# Use printf for serious work! 
-AC_PATH_PROG(ECHO, echo)
-CHECK_NONEMPTY(ECHO)
+AC_PROG_GREP
+CHECK_NONEMPTY(GREP)
 AC_PROG_EGREP
 CHECK_NONEMPTY(EGREP)
 AC_PROG_FGREP
 CHECK_NONEMPTY(FGREP)
+AC_PROG_SED
+CHECK_NONEMPTY(SED)
 
-AC_PATH_PROG(FIND, find)
-CHECK_NONEMPTY(FIND)
+AC_PATH_PROGS(NAWK, [nawk gawk awk])
+CHECK_NONEMPTY(NAWK)
+
+BASIC_CHECK_GNU_MAKE
+
+BASIC_REQUIRE_PROG(RM, rm)
+RM="$RM -f"
+
 BASIC_CHECK_FIND_DELETE
 AC_SUBST(FIND_DELETE)
 
-AC_PROG_GREP
-CHECK_NONEMPTY(GREP)
-AC_PATH_PROG(HEAD, head)
-CHECK_NONEMPTY(HEAD)
-AC_PATH_PROG(LN, ln)
-CHECK_NONEMPTY(LN)
-AC_PATH_PROG(LS, ls)
-CHECK_NONEMPTY(LS)
-AC_PATH_PROGS(MAKE, [gmake make])
-CHECK_NONEMPTY(MAKE)
-MAKE_VERSION=`$MAKE --version | head -n 1 | grep '3.8[[12346789]]'`
-if test "x$MAKE_VERSION" = x; then
-    AC_MSG_ERROR([You must use GNU make 3.81 or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure.])
-fi
-AC_PATH_PROG(MKDIR, mkdir)
-CHECK_NONEMPTY(MKDIR)
-AC_PATH_PROG(MV, mv)
-CHECK_NONEMPTY(MV)
-AC_PATH_PROGS(NAWK, [nawk gawk awk])
-CHECK_NONEMPTY(NAWK)
-AC_PATH_PROG(PRINTF, printf)
-CHECK_NONEMPTY(PRINTF)
+# Non-required basic tools
+
 AC_PATH_PROG(THEPWDCMD, pwd)
-AC_PATH_PROG(RM, rm)
-CHECK_NONEMPTY(RM)
-RM="$RM -f"
-AC_PROG_SED
-CHECK_NONEMPTY(SED)
-AC_PATH_PROG(SH, sh)
-CHECK_NONEMPTY(SH)
-AC_PATH_PROG(SORT, sort)
-CHECK_NONEMPTY(SORT)
-AC_PATH_PROG(TAR, tar)
-CHECK_NONEMPTY(TAR)
-AC_PATH_PROG(TAIL, tail)
-CHECK_NONEMPTY(TAIL)
-AC_PATH_PROG(TEE, tee)
-CHECK_NONEMPTY(TEE)
-AC_PATH_PROG(TR, tr)
-CHECK_NONEMPTY(TR)
-AC_PATH_PROG(TOUCH, touch)
-CHECK_NONEMPTY(TOUCH)
-AC_PATH_PROG(WC, wc)
-CHECK_NONEMPTY(WC)
-AC_PATH_PROG(XARGS, xargs)
-CHECK_NONEMPTY(XARGS)
-AC_PATH_PROG(ZIP, zip)
-CHECK_NONEMPTY(ZIP)
-AC_PATH_PROG(UNZIP, unzip)
-CHECK_NONEMPTY(UNZIP)
 AC_PATH_PROG(LDD, ldd)
 if test "x$LDD" = "x"; then
     # List shared lib dependencies is used for
@@ -390,16 +496,11 @@
 if test "x$OTOOL" = "x"; then
    OTOOL="true"
 fi
-AC_PATH_PROG(READELF, readelf)
-AC_PATH_PROG(EXPR, expr)
-CHECK_NONEMPTY(EXPR)
-AC_PATH_PROG(FILE, file)
-CHECK_NONEMPTY(FILE)
+AC_PATH_PROGS(READELF, [readelf greadelf])
+AC_PATH_PROGS(OBJDUMP, [objdump gobjdump])
 AC_PATH_PROG(HG, hg)
 ])
 
-
-
 AC_DEFUN_ONCE([BASIC_COMPILE_UNCYGDRIVE],
 [
 # When using cygwin, we need a wrapper binary that renames
@@ -433,6 +534,8 @@
     fi
     AC_MSG_RESULT([yes])
     rm -f $OUTPUT_ROOT/uncygdrive?.??? $OUTPUT_ROOT/uncygdrive.obj
+    # The path to uncygdrive to use should be Unix-style
+    UNCYGDRIVE="$OUTPUT_ROOT/uncygdrive.exe"
 fi
 
 AC_SUBST(UNCYGDRIVE)
--- a/common/autoconf/boot-jdk.m4	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/boot-jdk.m4	Tue Sep 25 11:48:00 2012 -0700
@@ -23,22 +23,186 @@
 # questions.
 #
 
-# Fixes paths on windows to be mixed mode short.
-AC_DEFUN([BOOTJDK_WIN_FIX_PATH],
+# Execute the check given as argument, and verify the result
+# If the Boot JDK was previously found, do nothing
+# $1 A command line (typically autoconf macro) to execute
+AC_DEFUN([BOOTJDK_DO_CHECK],
 [
-    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
-        AC_PATH_PROG(CYGPATH, cygpath)
-        tmp="[$]$1"
-        # Convert to C:/ mixed style path without spaces.
-        tmp=`$CYGPATH -s -m "$tmp"`
-        $1="$tmp"
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+    $1
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring])
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring])
+          AC_MSG_NOTICE([(This might be an JRE instead of an JDK)])
+          BOOT_JDK_FOUND=no
+        else 
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring])
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            [FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`]
+            if test "x$FOUND_VERSION_78" = x; then
+              AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring])
+              AC_MSG_NOTICE([(Your Boot JDK must be version 7 or 8)])
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+              SPACESAFE(BOOT_JDK,[the path to the Boot JDK])
+              AC_MSG_CHECKING([for Boot JDK])
+              AC_MSG_RESULT([$BOOT_JDK ($BOOT_JDK_VERSION)])
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+])
+
+# Test: Is bootjdk explicitely set by command line arguments?
+AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS],
+[
+if test "x$with_boot_jdk" != x; then
+    BOOT_JDK=$with_boot_jdk
+    BOOT_JDK_FOUND=maybe
+    AC_MSG_NOTICE([Found potential Boot JDK using configure arguments])
+fi
+])
+
+# Test: Is bootjdk available from builddeps?
+AC_DEFUN([BOOTJDK_CHECK_BUILDDEPS],
+[
+    BDEPS_CHECK_MODULE(BOOT_JDK, bootjdk, xxx, [BOOT_JDK_FOUND=maybe], [BOOT_JDK_FOUND=no])
+])
+
+# Test: Is $JAVA_HOME set?
+AC_DEFUN([BOOTJDK_CHECK_JAVA_HOME],
+[
+    if test "x$JAVA_HOME" != x; then
+        if test "x$OPENJDK_TARGET_OS" = xwindows; then
+          # On Windows, JAVA_HOME is likely in DOS-style
+          JAVA_HOME_PROCESSED="`$CYGPATH -u "$JAVA_HOME"`"
+        else
+          JAVA_HOME_PROCESSED="$JAVA_HOME"
+        fi
+        if test ! -d "$JAVA_HOME_PROCESSED"; then
+            AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!])
+        else
+          # Aha, the user has set a JAVA_HOME
+          # let us use that as the Boot JDK.
+          BOOT_JDK="$JAVA_HOME_PROCESSED"
+          BOOT_JDK_FOUND=maybe
+          AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME])
+        fi
     fi
 ])
 
-AC_DEFUN([BOOTJDK_MISSING_ERROR],
+# Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
+AC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK],
+[
+    AC_PATH_PROG(JAVAC_CHECK, javac)
+    AC_PATH_PROG(JAVA_CHECK, java)
+    BINARY="$JAVAC_CHECK"
+    if test "x$JAVAC_CHECK" = x; then
+        BINARY="$JAVA_CHECK"
+    fi
+    if test "x$BINARY" != x; then
+        # So there is a java(c) binary, it might be part of a JDK.
+        # Lets find the JDK/JRE directory by following symbolic links.
+        # Linux/GNU systems often have links from /usr/bin/java to 
+        # /etc/alternatives/java to the real JDK binary.
+        SET_FULL_PATH_SPACESAFE(BINARY)
+        REMOVE_SYMBOLIC_LINKS(BINARY)
+        BOOT_JDK=`dirname "$BINARY"`
+        BOOT_JDK=`cd "$BOOT_JDK/.."; pwd`
+        if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then
+            # Looks like we found ourselves an JDK
+            BOOT_JDK_FOUND=maybe
+            AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH])
+        fi
+    fi
+])
+
+# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX)
+AC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME],
+[
+    if test -x /usr/libexec/java_home; then
+        BOOT_JDK=`/usr/libexec/java_home`
+        BOOT_JDK_FOUND=maybe
+        AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home])
+    fi
+])
+
+# Look for a jdk in the given path. If there are multiple, try to select the newest.
+# If found, set BOOT_JDK and BOOT_JDK_FOUND.
+# $1 = Path to directory containing jdk installations.
+# $2 = String to append to the found JDK directory to get the proper JDK home
+AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY],
 [
-    AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk])
-    AC_MSG_ERROR([Cannot continue])
+  BOOT_JDK_PREFIX="$1"
+  BOOT_JDK_SUFFIX="$2"
+  BEST_JDK_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $GREP jdk | $SORT -r | $HEAD -n 1 `
+  if test "x$BEST_JDK_FOUND" != x; then
+    BOOT_JDK="${BOOT_JDK_PREFIX}/${BEST_JDK_FOUND}${BOOT_JDK_SUFFIX}"
+    if test -d "$BOOT_JDK"; then
+      BOOT_JDK_FOUND=maybe
+      AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)])
+    fi
+  fi
+])
+
+# Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given
+# environmental variable as base for where to look.
+# $1 Name of an environmal variable, assumed to point to the Program Files directory.
+AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY],
+[
+  if test "x[$]$1" != x; then
+    BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([`$CYGPATH -u "[$]$1"`/Java])
+  fi
+])
+
+# Test: Is there a JDK installed in default, well-known locations?
+AC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS],
+[
+  if test "x$OPENJDK_TARGET_OS" = xwindows; then
+    BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])])
+    BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])])
+    BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])])
+    BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])])
+    BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])])
+  elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])])
+    BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])])
+  fi
+])
+
+# Check that a command-line tool in the Boot JDK is correct
+# $1 = name of variable to assign
+# $2 = name of binary
+AC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK],
+[
+  AC_MSG_CHECKING([for $2 in Boot JDK])
+  $1=$BOOT_JDK/bin/$2
+  if test ! -x [$]$1; then
+      AC_MSG_RESULT(not found)
+      AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk])
+      AC_MSG_ERROR([Could not find $2 in the Boot JDK])
+  fi
+  AC_MSG_RESULT(ok)
 ])
 
 ###############################################################################
@@ -51,204 +215,74 @@
 BOOT_JDK_FOUND=no
 AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk],
     [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])])
-                    
-if test "x$with_boot_jdk" != x; then
-    BOOT_JDK=$with_boot_jdk
-    BOOT_JDK_FOUND=yes
-fi
-if test "x$BOOT_JDK_FOUND" = xno; then
-    BDEPS_CHECK_MODULE(BOOT_JDK, boot-jdk, xxx, [BOOT_JDK_FOUND=yes], [BOOT_JDK_FOUND=no])
-fi
 
-if test "x$BOOT_JDK_FOUND" = xno; then
-    if test "x$JAVA_HOME" != x; then
-        if test ! -d "$JAVA_HOME"; then
-            AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!])
-            BOOTJDK_MISSING_ERROR
-        fi
-        # Aha, the user has set a JAVA_HOME
-        # let us use that as the Boot JDK.
-        BOOT_JDK="$JAVA_HOME"
-        BOOT_JDK_FOUND=yes
-        # To be on the safe side, lets check that it is a JDK.
-        if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then
-            JAVAC="$BOOT_JDK/bin/javac"
-            JAVA="$BOOT_JDK/bin/java"
-            BOOT_JDK_FOUND=yes
-        else
-            AC_MSG_NOTICE([Your JAVA_HOME points to a JRE! The build needs a JDK! Please point JAVA_HOME to a JDK. JAVA_HOME=[$]JAVA_HOME])
-            BOOTJDK_MISSING_ERROR
-        fi            
-    fi
-fi
+# We look for the Boot JDK through various means, going from more certain to
+# more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if
+# we detected something (if so, the path to the jdk is in BOOT_JDK). But we 
+# must check if this is indeed valid; otherwise we'll continue looking.
 
-if test "x$BOOT_JDK_FOUND" = xno; then
-    AC_PATH_PROG(JAVAC_CHECK, javac)
-    AC_PATH_PROG(JAVA_CHECK, java)
-    BINARY="$JAVAC_CHECK"
-    if test "x$JAVAC_CHECK" = x; then
-        BINARY="$JAVA_CHECK"
-    fi
-    if test "x$BINARY" != x; then
-        # So there is a java(c) binary, it might be part of a JDK.
-        # Lets find the JDK/JRE directory by following symbolic links.
-        # Linux/GNU systems often have links from /usr/bin/java to 
-        # /etc/alternatives/java to the real JDK binary.
-	WHICHCMD_SPACESAFE(BINARY,[path to javac])
-        REMOVE_SYMBOLIC_LINKS(BINARY)
-        BOOT_JDK=`dirname $BINARY`
-        BOOT_JDK=`cd $BOOT_JDK/..; pwd`
-        if test -x $BOOT_JDK/bin/javac && test -x $BOOT_JDK/bin/java; then
-            JAVAC=$BOOT_JDK/bin/javac
-            JAVA=$BOOT_JDK/bin/java
-            BOOT_JDK_FOUND=yes
-        fi
-    fi
-fi
-
-if test "x$BOOT_JDK_FOUND" = xno; then
-    # Try the MacOSX way.
-    if test -x /usr/libexec/java_home; then
-        BOOT_JDK=`/usr/libexec/java_home`
-        if test -x $BOOT_JDK/bin/javac && test -x $BOOT_JDK/bin/java; then
-            JAVAC=$BOOT_JDK/bin/javac
-            JAVA=$BOOT_JDK/bin/java
-            BOOT_JDK_FOUND=yes
-        fi
-    fi
+# Test: Is bootjdk explicitely set by command line arguments?
+BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS])
+if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then
+  # Having specified an argument which is incorrect will produce an instant failure;
+  # we should not go on looking
+  AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK])
 fi
 
+# Test: Is bootjdk available from builddeps?
+BOOTJDK_DO_CHECK([BOOTJDK_CHECK_BUILDDEPS])
+
+# Test: Is $JAVA_HOME set?
+BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME])
+
+# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX)
+BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME])
+
+# Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
+BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK])
+
+# Test: Is there a JDK installed in default, well-known locations?
+BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS])
+
+# If we haven't found anything yet, we've truly lost. Give up.
 if test "x$BOOT_JDK_FOUND" = xno; then
-    AC_PATH_PROG(JAVA_CHECK, java)
-    if test "x$JAVA_CHECK" != x; then
-        # There is a java in the path. But apparently we have not found a javac 
-        # in the path, since that would have been tested earlier.
-        if test "x$OPENJDK_TARGET_OS" = xwindows; then
-            # Now if this is a windows platform. The default installation of a JDK
-            # actually puts the JRE in the path and keeps the JDK out of the path!
-            # Go look in the default installation location.
-            BOOT_JDK=/cygdrive/c/Program\ Files/Java/`ls /cygdrive/c/Program\ Files/Java | grep jdk | sort -r | head --lines 1`
-            if test -d "$BOOT_JDK"; then
-                BOOT_JDK_FOUND=yes
-            fi
-        fi
-        if test "x$BOOT_JDK_FOUND" = xno; then
-            HELP_MSG_MISSING_DEPENDENCY([openjdk])
-            AC_MSG_NOTICE([Found a JRE, not not a JDK! Please remove the JRE from your path and put a JDK there instead. $HELP_MSG])
-            BOOTJDK_MISSING_ERROR
-        fi
-    else
-        HELP_MSG_MISSING_DEPENDENCY([openjdk])
-        AC_MSG_NOTICE([Could not find a JDK. $HELP_MSG])
-        BOOTJDK_MISSING_ERROR
-    fi
+  HELP_MSG_MISSING_DEPENDENCY([openjdk])
+  AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG])
+  AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk])
+  AC_MSG_ERROR([Cannot continue])
 fi
 
-BOOTJDK_WIN_FIX_PATH(BOOT_JDK)
-
-# Now see if we can find the rt.jar, or its nearest equivalent.
+# Setup proper paths for what we found
 BOOT_RTJAR="$BOOT_JDK/jre/lib/rt.jar"
-SPACESAFE(BOOT_RTJAR,[the path to the Boot JDK rt.jar (or nearest equivalent)])
-
-BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar"
-SPACESAFE(BOOT_TOOLSJAR,[the path to the Boot JDK tools.jar (or nearest equivalent)])
-
-if test ! -f $BOOT_RTJAR; then
+if test ! -f "$BOOT_RTJAR"; then
     # On MacOSX it is called classes.jar
-    BOOT_RTJAR=$BOOT_JDK/../Classes/classes.jar
-    if test ! -f $BOOT_RTJAR; then
-        AC_MSG_NOTICE([Cannot find the rt.jar or its equivalent!])
-        AC_MSG_NOTICE([This typically means that configure failed to automatically find a suitable Boot JDK])
-        BOOTJDK_MISSING_ERROR
+    BOOT_RTJAR="$BOOT_JDK/../Classes/classes.jar"
+    if test -f "$BOOT_RTJAR"; then
+      # Remove the .. 
+      BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}"
     fi
-    # Remove the .. 
-    BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}"
-    # The tools.jar is part of classes.jar
-    BOOT_TOOLSJAR="$BOOT_RTJAR"
 fi
-
-AC_SUBST(BOOT_JDK)
+BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar"
+BOOT_JDK="$BOOT_JDK"
 AC_SUBST(BOOT_RTJAR)
 AC_SUBST(BOOT_TOOLSJAR)
-AC_MSG_CHECKING([for Boot JDK])
-AC_MSG_RESULT([$BOOT_JDK])
-AC_MSG_CHECKING([for Boot rt.jar])
-AC_MSG_RESULT([$BOOT_RTJAR])
-AC_MSG_CHECKING([for Boot tools.jar])
-AC_MSG_RESULT([$BOOT_TOOLSJAR])
+AC_SUBST(BOOT_JDK)
 
-# Use the java tool from the Boot JDK.
-AC_MSG_CHECKING([for java in Boot JDK])
-JAVA=$BOOT_JDK/bin/java
-if test ! -x $JAVA; then
-    AC_MSG_NOTICE([Could not find a working java])
-    BOOTJDK_MISSING_ERROR
-fi
-BOOT_JDK_VERSION=`$JAVA -version 2>&1 | head -n 1`
-AC_MSG_RESULT([yes $BOOT_JDK_VERSION])
-AC_SUBST(JAVA)
+# Setup tools from the Boot JDK.
+BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA,java)
+BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC,javac)
+BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH,javah)
+BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAP,javap)
+BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR,jar)
+BOOTJDK_CHECK_TOOL_IN_BOOTJDK(RMIC,rmic)
+BOOTJDK_CHECK_TOOL_IN_BOOTJDK(NATIVE2ASCII,native2ascii)
 
-# Extra M4 quote needed to protect [] in grep expression.
-[FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`]
-if test "x$FOUND_VERSION_78" = x; then
-    HELP_MSG_MISSING_DEPENDENCY([openjdk])
-    AC_MSG_NOTICE([Your boot-jdk must be version 7 or 8. $HELP_MSG])
-    BOOTJDK_MISSING_ERROR
-fi
+# Finally, set some other options...
 
 # When compiling code to be executed by the Boot JDK, force jdk7 compatibility.
 BOOT_JDK_SOURCETARGET="-source 7 -target 7"
 AC_SUBST(BOOT_JDK_SOURCETARGET)
-
-# Use the javac tool from the Boot JDK.
-AC_MSG_CHECKING([for javac in Boot JDK])
-JAVAC=$BOOT_JDK/bin/javac
-if test ! -x $JAVAC; then
-    AC_MSG_ERROR([Could not find a working javac])
-fi
-AC_MSG_RESULT(yes)
-AC_SUBST(JAVAC)
 AC_SUBST(JAVAC_FLAGS)
-
-# Use the javah tool from the Boot JDK.
-AC_MSG_CHECKING([for javah in Boot JDK])
-JAVAH=$BOOT_JDK/bin/javah
-if test ! -x $JAVAH; then
-    AC_MSG_NOTICE([Could not find a working javah])
-    BOOTJDK_MISSING_ERROR
-fi
-AC_MSG_RESULT(yes)
-AC_SUBST(JAVAH)
-
-# Use the jar tool from the Boot JDK.
-AC_MSG_CHECKING([for jar in Boot JDK])
-JAR=$BOOT_JDK/bin/jar
-if test ! -x $JAR; then
-    AC_MSG_NOTICE([Could not find a working jar])
-    BOOTJDK_MISSING_ERROR
-fi
-AC_SUBST(JAR)
-AC_MSG_RESULT(yes)
-
-# Use the rmic tool from the Boot JDK.
-AC_MSG_CHECKING([for rmic in Boot JDK])
-RMIC=$BOOT_JDK/bin/rmic
-if test ! -x $RMIC; then
-    AC_MSG_NOTICE([Could not find a working rmic])
-    BOOTJDK_MISSING_ERROR
-fi
-AC_SUBST(RMIC)
-AC_MSG_RESULT(yes)
-
-# Use the native2ascii tool from the Boot JDK.
-AC_MSG_CHECKING([for native2ascii in Boot JDK])
-NATIVE2ASCII=$BOOT_JDK/bin/native2ascii
-if test ! -x $NATIVE2ASCII; then
-    AC_MSG_NOTICE([Could not find a working native2ascii])
-    BOOTJDK_MISSING_ERROR
-fi
-AC_MSG_RESULT(yes)
-AC_SUBST(NATIVE2ASCII)
 ])
 
 AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/autoconf/bootcycle-spec.gmk.in	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  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.
+#
+
+# Support for building boot cycle builds
+
+# First include the real base spec.gmk file
+include @SPEC@
+
+# Check that the user did not try to specify a different java to use for compiling.
+ifneq ($(firstword $(SJAVAC_SERVER_JAVA)),$(firstword $(JAVA)))
+  $(error Bootcycle builds are not possible if --with-sjavac-server-java is specified)
+endif
+
+# Override specific values to do a boot cycle build
+
+# The bootcycle build has a different output directory
+BUILD_OUTPUT:=@BUILD_OUTPUT@/bootcycle-build
+
+# Use a different Boot JDK
+BOOT_JDK:=@BUILD_OUTPUT@/images/j2sdk-image
+BOOT_RTJAR:=@BUILD_OUTPUT@/images/j2sdk-image/jre/lib/rt.jar
--- a/common/autoconf/build-aux/config.guess	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/build-aux/config.guess	Tue Sep 25 11:48:00 2012 -0700
@@ -22,17 +22,39 @@
 # questions.
 #
 
-# This is a wrapper for the config.guess from autoconf. The latter does not properly
-# detect amd64 systems, since that require isainfo instead of uname. Instead of patching
-# the autoconf system (which might easily get lost in a future update), we wrap it and
-# fix the broken property, if needed.
+# This is a wrapper for the config.guess from autoconf. The latter does not
+# properly detect 64 bit systems on all platforms. Instead of patching the
+# autoconf system (which might easily get lost in a future update), we wrap it
+# and fix the broken property, if needed.
 
 DIR=`dirname $0`
 OUT=`. $DIR/autoconf-config.guess`
+
+# Test and fix solaris on x86_64
 echo $OUT | grep i386-pc-solaris > /dev/null 2> /dev/null
 if test $? = 0; then
-  # isainfo -n returns either i386 or amd64 on Intel systems
+  # isainfo -n returns either i386 or amd64
   REAL_CPU=`isainfo -n`
   OUT=$REAL_CPU`echo $OUT | sed -e 's/[^-]*//'`
 fi
+
+# Test and fix solaris on sparcv9
+echo $OUT | grep sparc-sun-solaris > /dev/null 2> /dev/null
+if test $? = 0; then
+  # isainfo -n returns either sparc or sparcv9
+  REAL_CPU=`isainfo -n`
+  OUT=$REAL_CPU`echo $OUT | sed -e 's/[^-]*//'`
+fi
+
+# Test and fix cygwin on x86_64
+echo $OUT | grep 86-pc-cygwin > /dev/null 2> /dev/null
+if test $? = 0; then
+  case `echo $PROCESSOR_IDENTIFIER | cut -f1 -d' '` in
+    intel64|Intel64|INTEL64|em64t|EM64T|amd64|AMD64|8664|x86_64)
+      REAL_CPU=x86_64
+      OUT=$REAL_CPU`echo $OUT | sed -e 's/[^-]*//'`
+      ;;
+  esac
+fi  
+
 echo $OUT
--- a/common/autoconf/build-performance.m4	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/build-performance.m4	Tue Sep 25 11:48:00 2012 -0700
@@ -30,27 +30,19 @@
     FOUND_CORES=no
     
     if test -f /proc/cpuinfo; then
-        # Looks like a Linux system
+        # Looks like a Linux (or cygwin) system
         NUM_CORES=`cat /proc/cpuinfo  | grep -c processor`
         FOUND_CORES=yes
-    fi
-
-    if test -x /usr/sbin/psrinfo; then
+    elif test -x /usr/sbin/psrinfo; then
         # Looks like a Solaris system
         NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line`
         FOUND_CORES=yes
-    fi
-
-    if test -x /usr/sbin/system_profiler; then
+    elif test -x /usr/sbin/system_profiler; then
         # Looks like a MacOSX system
         NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk  '{print [$]5}'`
         FOUND_CORES=yes
     fi
 
-    if test "x$build_os" = xwindows; then
-        NUM_CORES=4
-    fi
-
     # For c/c++ code we run twice as many concurrent build
     # jobs than we have cores, otherwise we will stall on io.
     CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2`
@@ -66,31 +58,26 @@
 AC_DEFUN([BPERF_CHECK_MEMORY_SIZE],
 [
     AC_MSG_CHECKING([for memory size])
-    # Default to 1024MB
+    # Default to 1024 MB
     MEMORY_SIZE=1024
     FOUND_MEM=no
     
-    if test -f /proc/cpuinfo; then
-        # Looks like a Linux system
+    if test -f /proc/meminfo; then
+        # Looks like a Linux (or cygwin) system
         MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'`
         MEMORY_SIZE=`expr $MEMORY_SIZE / 1024`
         FOUND_MEM=yes
-    fi
-
-    if test -x /usr/sbin/prtconf; then
+    elif test -x /usr/sbin/prtconf; then
         # Looks like a Solaris system
         MEMORY_SIZE=`/usr/sbin/prtconf | grep "Memory size" | awk '{ print [$]3 }'`
         FOUND_MEM=yes
-    fi
-
-    if test -x /usr/sbin/system_profiler; then
+    elif test -x /usr/sbin/system_profiler; then
         # Looks like a MacOSX system
         MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk  '{print [$]2}'`
         MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024`
         FOUND_MEM=yes
-    fi
-
-    if test "x$build_os" = xwindows; then
+    elif test "x$build_os" = xwindows; then
+        # Windows, but without cygwin
         MEMORY_SIZE=`systeminfo | grep 'Total Physical Memory:' | awk '{ print [$]4 }' | sed 's/,//'`
         FOUND_MEM=yes    
     fi
@@ -98,7 +85,7 @@
     if test "x$FOUND_MEM" = xyes; then
         AC_MSG_RESULT([$MEMORY_SIZE MB])
     else
-        AC_MSG_RESULT([could not detect memory size defaulting to 1024MB!])
+        AC_MSG_RESULT([could not detect memory size defaulting to 1024 MB!])
     fi 
 ])
 
@@ -240,46 +227,30 @@
 
 AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC],
 [
-AC_ARG_WITH(server-java, [AS_HELP_STRING([--with-server-java],
-	[use this java binary for running the javac background server and other long running java tasks in the build process,
-     e.g. ---with-server-java="/opt/jrockit/bin/java -server"])])
+AC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java],
+	[use this java binary for running the sjavac background server and other long running java tasks in the build process,
+     e.g. ---with-sjavac-server-java="/opt/jrockit/bin/java -server"])])
 
-if test "x$with_server_java" != x; then
-    SERVER_JAVA="$with_server_java"
-    FOUND_VERSION=`$SERVER_JAVA -version 2>&1 | grep " version \""`
+if test "x$with_sjavac_server_java" != x; then
+    SJAVAC_SERVER_JAVA="$with_sjavac_server_java"
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" = x; then
-        AC_MSG_ERROR([Could not execute server java: $SERVER_JAVA])
+        AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA])
     fi
 else
-    SERVER_JAVA=""
+    SJAVAC_SERVER_JAVA=""
     # Hotspot specific options.
-    ADD_JVM_ARG_IF_OK([-XX:+UseParallelOldGC],SERVER_JAVA,[$JAVA])
-    ADD_JVM_ARG_IF_OK([-verbosegc],SERVER_JAVA,[$JAVA])
+    ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA])
     # JRockit specific options.
-    ADD_JVM_ARG_IF_OK([-Xverbose:gc],SERVER_JAVA,[$JAVA])
-    SERVER_JAVA="$JAVA $SERVER_JAVA"
+    ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA])
+    SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA"
 fi                    
-AC_SUBST(SERVER_JAVA)
+AC_SUBST(SJAVAC_SERVER_JAVA)
 
-AC_MSG_CHECKING([whether to use shared server for javac])
-AC_ARG_ENABLE([javac-server], [AS_HELP_STRING([--enable-javac-server],
-	[enable the shared javac server during the build process @<:@disabled@:>@])],
-	[ENABLE_JAVAC_SERVER="${enableval}"], [ENABLE_JAVAC_SERVER='no'])
-AC_MSG_RESULT([$ENABLE_JAVAC_SERVER])
-if test "x$ENABLE_JAVAC_SERVER" = xyes; then
-    JAVAC_USE_REMOTE=true
-    JAVAC_SERVERS="$OUTPUT_ROOT/javacservers"
-else
-    JAVAC_USE_REMOTE=false
-    JAVAC_SERVERS=
-fi
-AC_SUBST(JAVAC_USE_REMOTE)
-AC_SUBST(JAVAC_SERVERS)
-
-AC_ARG_WITH(javac-server-cores, [AS_HELP_STRING([--with-javac-server-cores],
-	[use at most this number of concurrent threads on the javac server @<:@probed@:>@])])
-if test "x$with_javac_server_cores" != x; then
-    JAVAC_SERVER_CORES="$with_javac_server_cores"
+AC_ARG_WITH(sjavac-server-cores, [AS_HELP_STRING([--with-sjavac-server-cores],
+	[use at most this number of concurrent threads on the sjavac server @<:@probed@:>@])])
+if test "x$with_sjavac_server_cores" != x; then
+    SJAVAC_SERVER_CORES="$with_sjavac_server_cores"
 else
     if test "$NUM_CORES" -gt 16; then
         # We set this arbitrary limit because we want to limit the heap
@@ -287,86 +258,49 @@
         # In the future we will make the javac compilers in the server
         # share more and more state, thus enabling us to use more and
         # more concurrent threads in the server.
-        JAVAC_SERVER_CORES="16"
+        SJAVAC_SERVER_CORES="16"
     else
-        JAVAC_SERVER_CORES="$NUM_CORES"
+        SJAVAC_SERVER_CORES="$NUM_CORES"
     fi
 
     if test "$MEMORY_SIZE" -gt "17000"; then
         MAX_HEAP_MEM=10000
-        ADD_JVM_ARG_IF_OK([-d64],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xmn2G],SERVER_JAVA,[$SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
     elif test "$MEMORY_SIZE" -gt "10000"; then
         MAX_HEAP_MEM=6000
-        ADD_JVM_ARG_IF_OK([-d64],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xmn1G],SERVER_JAVA,[$SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
     elif test "$MEMORY_SIZE" -gt "5000"; then
         MAX_HEAP_MEM=3000
-        ADD_JVM_ARG_IF_OK([-d64],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xmn256M],SERVER_JAVA,[$SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
     elif test "$MEMORY_SIZE" -gt "3800"; then
         MAX_HEAP_MEM=2500
-        ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xmn256M],SERVER_JAVA,[$SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
     elif test "$MEMORY_SIZE" -gt "1900"; then
         MAX_HEAP_MEM=1200
-        ADD_JVM_ARG_IF_OK([-Xms700M -Xmx1200M],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xmn256M],SERVER_JAVA,[$SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-Xms700M -Xmx1400M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
     elif test "$MEMORY_SIZE" -gt "1000"; then
         MAX_HEAP_MEM=900
-        ADD_JVM_ARG_IF_OK([-Xms400M -Xmx900M],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xmn128M],SERVER_JAVA,[$SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
     else
         MAX_HEAP_MEM=512
-        ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SERVER_JAVA,[$SERVER_JAVA])
-        ADD_JVM_ARG_IF_OK([-Xmn128M],SERVER_JAVA,[$SERVER_JAVA])
+        ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
     fi
 
+    ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+    ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+    ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+
     MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501`
-    if test "$JAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then
+    if test "$SJAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then
         AC_MSG_CHECKING([if number of server cores must be reduced])
-        JAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP"
-        AC_MSG_RESULT([yes, to $JAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB])
+        SJAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP"
+        AC_MSG_RESULT([yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB])
     fi
 fi                    
-AC_SUBST(JAVAC_SERVER_CORES)
-
-AC_MSG_CHECKING([whether to track dependencies between Java packages])
-AC_ARG_ENABLE([javac-deps], [AS_HELP_STRING([--enable-javac-deps],
-	[enable the dependency tracking between Java packages @<:@disabled@:>@])],
-	[ENABLE_JAVAC_DEPS="${enableval}"], [ENABLE_JAVAC_DEPS='no'])
-AC_MSG_RESULT([$ENABLE_JAVAC_DEPS])
-if test "x$ENABLE_JAVAC_DEPS" = xyes; then
-    JAVAC_USE_DEPS=true
-else
-    JAVAC_USE_DEPS=false
-fi
-AC_SUBST(JAVAC_USE_DEPS)
-
-AC_MSG_CHECKING([whether to use multiple cores for javac compilation])
-AC_ARG_ENABLE([javac-multi-core], [AS_HELP_STRING([--enable-javac-multi-core],
-	[compile Java packages concurrently @<:@disabled@:>@])],
-	[ENABLE_JAVAC_MULTICORE="${enableval}"], [ENABLE_JAVAC_MULTICORE='no'])
-AC_MSG_RESULT([$ENABLE_JAVAC_MULTICORE])
-if test "x$ENABLE_JAVAC_MULTICORE" = xyes; then
-    JAVAC_USE_MODE=MULTI_CORE_CONCURRENT
-else
-    JAVAC_USE_MODE=SINGLE_THREADED_BATCH
-    if test "x$ENABLE_JAVAC_DEPS" = xyes; then
-        AC_MSG_WARN([Dependency tracking is not supported with single threaded batch compiles of Java source roots. Please add --disable-javac-deps to your configure options.])
-        AC_MSG_WARN([Disabling dependency tracking for you now.])
-        JAVAC_USE_DEPS=false
-    fi
-    if test "x$ENABLE_JAVAC_SERVER" = xyes; then
-        AC_MSG_WARN([The javac server will not be used since single threaded batch compiles are run within their own JVM. Please add --disable-javac-server to your configure options.])
-        AC_MSG_WARN([Disabling javac server for you now.])
-        JAVAC_USE_REMOTE=false
-    fi
-fi
-AC_SUBST(JAVAC_USE_MODE)
+AC_SUBST(SJAVAC_SERVER_CORES)
 
 AC_MSG_CHECKING([whether to use sjavac])
 AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac],
@@ -375,4 +309,11 @@
 AC_MSG_RESULT([$ENABLE_SJAVAC])
 AC_SUBST(ENABLE_SJAVAC)
 
+if test "x$ENABLE_SJAVAC" = xyes; then
+    SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers"
+else
+    SJAVAC_SERVER_DIR=
+fi
+AC_SUBST(SJAVAC_SERVER_DIR)
+
 ])
--- a/common/autoconf/builddeps.conf.example	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/builddeps.conf.example	Tue Sep 25 11:48:00 2012 -0700
@@ -31,7 +31,7 @@
 
 # Translate a configuration triplet/quadruplet into something
 # known by this configuration file.
-# If no rewrite was found, then rewritten_target=${OPENJDK_TARGET_SYSTEM}
+# If no rewrite was found, then rewritten_target=${OPENJDK_TARGET_AUTOCONF_NAME}
 REWRITE_i686_pc_linux_gnu=i686-unknown-linux-gnu
 REWRITE_i386_pc_solaris2_10=i686-sun-solaris2_10
  
--- a/common/autoconf/builddeps.m4	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/builddeps.m4	Tue Sep 25 11:48:00 2012 -0700
@@ -52,19 +52,19 @@
         fi
         # Create build and target names that use _ instead of "-" and ".".
         # This is necessary to use them in variable names.
-        build_var=`echo ${OPENJDK_BUILD_SYSTEM} | tr '-' '_' | tr '.' '_'`
-        target_var=`echo ${OPENJDK_TARGET_SYSTEM} | tr '-' '_' | tr '.' '_'`
+        build_var=`echo ${OPENJDK_BUILD_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'`
+        target_var=`echo ${OPENJDK_TARGET_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'`
         # Extract rewrite information for build and target
         eval rewritten_build=\${REWRITE_${build_var}}
         if test "x$rewritten_build" = x; then
-            rewritten_build=${OPENJDK_BUILD_SYSTEM}
+            rewritten_build=${OPENJDK_BUILD_AUTOCONF_NAME}
             echo Build stays the same $rewritten_build
         else
             echo Rewriting build for builddeps into $rewritten_build
         fi
         eval rewritten_target=\${REWRITE_${target_var}}
         if test "x$rewritten_target" = x; then
-            rewritten_target=${OPENJDK_TARGET_SYSTEM}
+            rewritten_target=${OPENJDK_TARGET_AUTOCONF_NAME}
             echo Target stays the same $rewritten_target
         else
             echo Rewriting target for builddeps into $rewritten_target
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/autoconf/compare.sh.in	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,1669 @@
+#!/bin/bash
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# This script is processed by configure before it's usable. It is run from 
+# the root of the build directory.
+
+
+##########################################################################################
+# Substitutions from autoconf
+
+LEGACY_BUILD_DIR=@OPENJDK_TARGET_OS@-@OPENJDK_TARGET_CPU_LEGACY@
+
+OPENJDK_TARGET_OS="@OPENJDK_TARGET_OS@"
+OPENJDK_TARGET_CPU="@OPENJDK_TARGET_CPU@"
+
+AWK="@AWK@"
+CAT="@CAT@"
+CMP="@CMP@"
+CP="@CP@"
+CUT="@CUT@"
+DIFF="@DIFF@"
+DUMPBIN="@UNCYGDRIVE@ @DUMPBIN@"
+EXPR="@EXPR@"
+FILE="@FILE@"
+FIND="@FIND@"
+GREP="@GREP@"
+JAVAP="@UNCYGDRIVE@ @BOOT_JDK@/bin/javap"
+LDD="@LDD@"
+MKDIR="@MKDIR@"
+NM="@NM@"
+OBJDUMP="@OBJDUMP@"
+OTOOL="@OTOOL@"
+PRINTF="@PRINTF@"
+READELF="@READELF@"
+RM="@RM@"
+SED="@SED@"
+SORT="@SORT@"
+STRIP="@POST_STRIP_CMD@"
+TEE="@TEE@"
+UNIQ="@UNIQ@"
+UNZIP="@UNZIP@"
+
+SRC_ROOT="@SRC_ROOT@"
+
+if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
+    READELF_CMD="otool -v -V -h -X -t -d"
+elif [ -n "$READELF" ] && [ "$OPENJDK_TARGET_OS" != "windows" ]; then
+    READELF_CMD="$READELF -a"
+fi
+
+if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
+    LDD_CMD="$OTOOL -L"
+elif [ -n "$LDD" ]; then
+    LDD_CMD="$LDD"
+fi
+
+##########################################################################################
+# Diff exceptions
+
+if [ "$OPENJDK_TARGET_OS" = "linux" ] && [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
+STRIP_BEFORE_COMPARE="
+./demo/jvmti/compiledMethodLoad/lib/libcompiledMethodLoad.so
+./demo/jvmti/gctest/lib/libgctest.so
+./demo/jvmti/heapTracker/lib/libheapTracker.so
+./demo/jvmti/heapViewer/lib/libheapViewer.so
+./demo/jvmti/hprof/lib/libhprof.so
+./demo/jvmti/minst/lib/libminst.so
+./demo/jvmti/mtrace/lib/libmtrace.so
+./demo/jvmti/versionCheck/lib/libversionCheck.so
+./demo/jvmti/waiters/lib/libwaiters.so
+"
+
+KNOWN_BIN_DIFF="
+"
+
+ACCEPTED_BIN_DIFF="
+./demo/jvmti/compiledMethodLoad/lib/libcompiledMethodLoad.so
+./demo/jvmti/gctest/lib/libgctest.so
+./demo/jvmti/heapTracker/lib/libheapTracker.so
+./demo/jvmti/heapViewer/lib/libheapViewer.so
+./demo/jvmti/hprof/lib/libhprof.so
+./demo/jvmti/minst/lib/libminst.so
+./demo/jvmti/mtrace/lib/libmtrace.so
+./demo/jvmti/versionCheck/lib/libversionCheck.so
+./demo/jvmti/waiters/lib/libwaiters.so
+./jre/lib/amd64/libattach.so
+./jre/lib/amd64/libdt_socket.so
+./jre/lib/amd64/libhprof.so
+./jre/lib/amd64/libinstrument.so
+./jre/lib/amd64/libjava_crw_demo.so
+./jre/lib/amd64/libjsdt.so
+./jre/lib/amd64/libjsig.so
+./jre/lib/amd64/libmanagement.so
+./jre/lib/amd64/libnpt.so
+./jre/lib/amd64/libsaproc.so
+./jre/lib/amd64/libverify.so
+./jre/lib/amd64/server/libjsig.so
+./jre/lib/amd64/server/libjvm.so
+./bin/appletviewer
+./bin/extcheck
+./bin/idlj
+./bin/jar
+./bin/jarsigner
+./bin/java
+./bin/javac
+./bin/javadoc
+./bin/javah
+./bin/javap
+./bin/jcmd
+./bin/jconsole
+./bin/jdb
+./bin/jhat
+./bin/jinfo
+./bin/jmap
+./bin/jps
+./bin/jrunscript
+./bin/jsadebugd
+./bin/jstack
+./bin/jstat
+./bin/jstatd
+./bin/keytool
+./bin/native2ascii
+./bin/orbd
+./bin/pack200
+./bin/policytool
+./bin/rmic
+./bin/rmid
+./bin/rmiregistry
+./bin/schemagen
+./bin/serialver
+./bin/servertool
+./bin/tnameserv
+./bin/wsgen
+./bin/wsimport
+./bin/xjc
+./jre/bin/java
+./jre/bin/keytool
+./jre/bin/orbd
+./jre/bin/pack200
+./jre/bin/policytool
+./jre/bin/rmid
+./jre/bin/rmiregistry
+./jre/bin/servertool
+./jre/bin/tnameserv
+"
+
+KNOWN_SIZE_DIFF="
+"
+
+KNOWN_SYM_DIFF="
+"
+
+KNOWN_ELF_DIFF="
+./demo/jvmti/heapTracker/lib/libheapTracker.so
+./demo/jvmti/hprof/lib/libhprof.so
+./demo/jvmti/waiters/lib/libwaiters.so
+"
+fi
+
+if [ "$OPENJDK_TARGET_OS" = "solaris" ] && [ "$OPENJDK_TARGET_CPU" = "x86" ]; then
+
+STRIP_BEFORE_COMPARE="
+./demo/jni/Poller/lib/libPoller.so
+./demo/jvmti/compiledMethodLoad/lib/libcompiledMethodLoad.so
+./demo/jvmti/gctest/lib/libgctest.so
+./demo/jvmti/heapTracker/lib/libheapTracker.so
+./demo/jvmti/heapViewer/lib/libheapViewer.so
+./demo/jvmti/hprof/lib/libhprof.so
+./demo/jvmti/minst/lib/libminst.so
+./demo/jvmti/mtrace/lib/libmtrace.so
+./demo/jvmti/versionCheck/lib/libversionCheck.so
+./demo/jvmti/waiters/lib/libwaiters.so
+./jre/lib/i386/jexec
+"
+
+SORT_SYMBOLS="
+./jre/lib/i386/client/libjvm.so
+./jre/lib/i386/server/libjvm.so
+"
+
+SKIP_BIN_DIFF="true"
+
+ACCEPTED_SMALL_SIZE_DIFF="
+./demo/jni/Poller/lib/libPoller.so
+./demo/jvmti/compiledMethodLoad/lib/libcompiledMethodLoad.so
+./demo/jvmti/gctest/lib/libgctest.so
+./demo/jvmti/heapTracker/lib/libheapTracker.so
+./demo/jvmti/heapViewer/lib/libheapViewer.so
+./demo/jvmti/hprof/lib/libhprof.so
+./demo/jvmti/minst/lib/libminst.so
+./demo/jvmti/mtrace/lib/libmtrace.so
+./demo/jvmti/versionCheck/lib/libversionCheck.so
+./demo/jvmti/waiters/lib/libwaiters.so
+./jre/lib/i386/client/libjvm.so
+./jre/lib/i386/jli/libjli.so
+./jre/lib/i386/libJdbcOdbc.so
+./jre/lib/i386/libattach.so
+./jre/lib/i386/libawt.so
+./jre/lib/i386/libawt_headless.so
+./jre/lib/i386/libawt_xawt.so
+./jre/lib/i386/libdcpr.so
+./jre/lib/i386/libdt_socket.so
+./jre/lib/i386/libfontmanager.so
+./jre/lib/i386/libhprof.so
+./jre/lib/i386/libinstrument.so
+./jre/lib/i386/libj2gss.so
+./jre/lib/i386/libj2pcsc.so
+./jre/lib/i386/libj2pkcs11.so
+./jre/lib/i386/libj2ucrypto.so
+./jre/lib/i386/libjaas_unix.so
+./jre/lib/i386/libjava.so
+./jre/lib/i386/libjava_crw_demo.so
+./jre/lib/i386/libjawt.so
+./jre/lib/i386/libjdwp.so
+./jre/lib/i386/libjfr.so
+./jre/lib/i386/libjpeg.so
+./jre/lib/i386/libjsdt.so
+./jre/lib/i386/libjsound.so
+./jre/lib/i386/libkcms.so
+./jre/lib/i386/libmanagement.so
+./jre/lib/i386/libmlib_image.so
+./jre/lib/i386/libnet.so
+./jre/lib/i386/libnio.so
+./jre/lib/i386/libnpt.so
+./jre/lib/i386/libsctp.so
+./jre/lib/i386/libsplashscreen.so
+./jre/lib/i386/libsunec.so
+./jre/lib/i386/libsunwjdga.so
+./jre/lib/i386/libt2k.so
+./jre/lib/i386/libunpack.so
+./jre/lib/i386/libverify.so
+./jre/lib/i386/libzip.so
+./jre/lib/i386/server/libjvm.so
+./bin/appletviewer
+./bin/extcheck
+./bin/idlj
+./bin/jar
+./bin/jarsigner
+./bin/java
+./bin/javac
+./bin/javadoc
+./bin/javah
+./bin/javap
+./bin/jcmd
+./bin/jconsole
+./bin/jdb
+./bin/jhat
+./bin/jinfo
+./bin/jmap
+./bin/jps
+./bin/jrunscript
+./bin/jsadebugd
+./bin/jstack
+./bin/jstat
+./bin/jstatd
+./bin/keytool
+./bin/native2ascii
+./bin/orbd
+./bin/pack200
+./bin/policytool
+./bin/rmic
+./bin/rmid
+./bin/rmiregistry
+./bin/schemagen
+./bin/serialver
+./bin/servertool
+./bin/tnameserv
+./bin/unpack200
+./bin/wsgen
+./bin/wsimport
+./bin/xjc
+./jre/bin/java
+./jre/bin/keytool
+./jre/bin/orbd
+./jre/bin/pack200
+./jre/bin/policytool
+./jre/bin/rmid
+./jre/bin/rmiregistry
+./jre/bin/servertool
+./jre/bin/tnameserv
+./jre/bin/unpack200
+./jre/lib/i386/jexec
+"
+
+SKIP_ELF_DIFF="true"
+
+# libjvm.so differs in the random 15 char prefix on some symbols.
+ACCEPTED_DIS_DIFF="
+./jre/lib/i386/client/libjvm.so
+./jre/lib/i386/server/libjvm.so
+"
+
+fi
+
+if [ "$OPENJDK_TARGET_OS" = "solaris" ] && [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
+
+STRIP_BEFORE_COMPARE="
+./demo/jni/Poller/lib/amd64/libPoller.so
+./demo/jvmti/compiledMethodLoad/lib/amd64/libcompiledMethodLoad.so
+./demo/jvmti/gctest/lib/amd64/libgctest.so
+./demo/jvmti/heapTracker/lib/amd64/libheapTracker.so
+./demo/jvmti/heapViewer/lib/amd64/libheapViewer.so
+./demo/jvmti/hprof/lib/amd64/libhprof.so
+./demo/jvmti/minst/lib/amd64/libminst.so
+./demo/jvmti/mtrace/lib/amd64/libmtrace.so
+./demo/jvmti/versionCheck/lib/amd64/libversionCheck.so
+./demo/jvmti/waiters/lib/amd64/libwaiters.so
+"
+
+SORT_SYMBOLS="
+./jre/lib/amd64/server/libjvm.so
+"
+
+SKIP_BIN_DIFF="true"
+
+ACCEPTED_SMALL_SIZE_DIFF="
+./demo/jni/Poller/lib/amd64/libPoller.so
+./demo/jvmti/compiledMethodLoad/lib/amd64/libcompiledMethodLoad.so
+./demo/jvmti/gctest/lib/amd64/libgctest.so
+./demo/jvmti/heapTracker/lib/amd64/libheapTracker.so
+./demo/jvmti/heapViewer/lib/amd64/libheapViewer.so
+./demo/jvmti/hprof/lib/amd64/libhprof.so
+./demo/jvmti/minst/lib/amd64/libminst.so
+./demo/jvmti/mtrace/lib/amd64/libmtrace.so
+./demo/jvmti/versionCheck/lib/amd64/libversionCheck.so
+./demo/jvmti/waiters/lib/amd64/libwaiters.so
+./jre/lib/amd64/jli/libjli.so
+./jre/lib/amd64/libJdbcOdbc.so
+./jre/lib/amd64/libattach.so
+./jre/lib/amd64/libawt.so
+./jre/lib/amd64/libawt_headless.so
+./jre/lib/amd64/libawt_xawt.so
+./jre/lib/amd64/libdcpr.so
+./jre/lib/amd64/libdt_socket.so
+./jre/lib/amd64/libfontmanager.so
+./jre/lib/amd64/libhprof.so
+./jre/lib/amd64/libinstrument.so
+./jre/lib/amd64/libj2gss.so
+./jre/lib/amd64/libj2pcsc.so
+./jre/lib/amd64/libj2pkcs11.so
+./jre/lib/amd64/libj2ucrypto.so
+./jre/lib/amd64/libjaas_unix.so
+./jre/lib/amd64/libjava.so
+./jre/lib/amd64/libjava_crw_demo.so
+./jre/lib/amd64/libjawt.so
+./jre/lib/amd64/libjdwp.so
+./jre/lib/amd64/libjfr.so
+./jre/lib/amd64/libjpeg.so
+./jre/lib/amd64/libjsdt.so
+./jre/lib/amd64/libjsound.so
+./jre/lib/amd64/libkcms.so
+./jre/lib/amd64/libmanagement.so
+./jre/lib/amd64/libmlib_image.so
+./jre/lib/amd64/libnet.so
+./jre/lib/amd64/libnio.so
+./jre/lib/amd64/libnpt.so
+./jre/lib/amd64/libsctp.so
+./jre/lib/amd64/libsplashscreen.so
+./jre/lib/amd64/libsunec.so
+./jre/lib/amd64/libsunwjdga.so
+./jre/lib/amd64/libt2k.so
+./jre/lib/amd64/libunpack.so
+./jre/lib/amd64/libverify.so
+./jre/lib/amd64/libzip.so
+./jre/lib/amd64/server/64/libjvm_db.so
+./jre/lib/amd64/server/64/libjvm_dtrace.so
+./bin/amd64/appletviewer
+./bin/amd64/extcheck
+./bin/amd64/idlj
+./bin/amd64/jar
+./bin/amd64/jarsigner
+./bin/amd64/java
+./bin/amd64/javac
+./bin/amd64/javadoc
+./bin/amd64/javah
+./bin/amd64/javap
+./bin/amd64/jcmd
+./bin/amd64/jconsole
+./bin/amd64/jdb
+./bin/amd64/jhat
+./bin/amd64/jinfo
+./bin/amd64/jmap
+./bin/amd64/jps
+./bin/amd64/jrunscript
+./bin/amd64/jsadebugd
+./bin/amd64/jstack
+./bin/amd64/jstat
+./bin/amd64/jstatd
+./bin/amd64/keytool
+./bin/amd64/native2ascii
+./bin/amd64/orbd
+./bin/amd64/pack200
+./bin/amd64/policytool
+./bin/amd64/rmic
+./bin/amd64/rmid
+./bin/amd64/rmiregistry
+./bin/amd64/schemagen
+./bin/amd64/serialver
+./bin/amd64/servertool
+./bin/amd64/tnameserv
+./bin/amd64/unpack200
+./bin/amd64/wsgen
+./bin/amd64/wsimport
+./bin/amd64/xjc
+./jre/bin/amd64/java
+./jre/bin/amd64/keytool
+./jre/bin/amd64/orbd
+./jre/bin/amd64/pack200
+./jre/bin/amd64/policytool
+./jre/bin/amd64/rmid
+./jre/bin/amd64/rmiregistry
+./jre/bin/amd64/servertool
+./jre/bin/amd64/tnameserv
+./jre/bin/amd64/unpack200
+./jre/lib/amd64/jexec
+"
+
+SKIP_ELF_DIFF="true"
+
+# Can't find an explaination for the diff in libmlib_image.so.
+KNOWN_DIS_DIFF="
+./jre/lib/amd64/libmlib_image.so
+"
+# libjvm.so differs in the random 15 char prefix on some symbols.
+ACCEPTED_DIS_DIFF="
+./jre/lib/amd64/server/libjvm.so
+"
+
+fi
+
+if [ "$OPENJDK_TARGET_OS" = "windows" ] && [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
+
+ACCEPTED_BIN_DIFF="
+./bin/jli.dll
+./demo/jvmti/compiledMethodLoad/lib/compiledMethodLoad.dll
+./demo/jvmti/gctest/lib/gctest.dll
+./demo/jvmti/heapTracker/lib/heapTracker.dll
+./demo/jvmti/heapViewer/lib/heapViewer.dll
+./demo/jvmti/hprof/lib/hprof.dll
+./demo/jvmti/minst/lib/minst.dll
+./demo/jvmti/mtrace/lib/mtrace.dll
+./demo/jvmti/versionCheck/lib/versionCheck.dll
+./demo/jvmti/waiters/lib/waiters.dll
+./jre/bin/attach.dll
+./jre/bin/awt.dll
+./jre/bin/dcpr.dll
+./jre/bin/dt_shmem.dll
+./jre/bin/dt_socket.dll
+./jre/bin/fontmanager.dll
+./jre/bin/hprof.dll
+./jre/bin/instrument.dll
+./jre/bin/j2pcsc.dll
+./jre/bin/j2pkcs11.dll
+./jre/bin/jaas_nt.dll
+./jre/bin/java.dll
+./jre/bin/java_crw_demo.dll
+./jre/bin/jawt.dll
+./jre/bin/JdbcOdbc.dll
+./jre/bin/jdwp.dll
+./jre/bin/jfr.dll
+./jre/bin/jli.dll
+./jre/bin/jpeg.dll
+./jre/bin/jsdt.dll
+./jre/bin/jsound.dll
+./jre/bin/jsoundds.dll
+./jre/bin/kcms.dll
+./jre/bin/management.dll
+./jre/bin/mlib_image.dll
+./jre/bin/net.dll
+./jre/bin/nio.dll
+./jre/bin/npt.dll
+./jre/bin/sawindbg.dll
+./jre/bin/server/jvm.dll
+./jre/bin/splashscreen.dll
+./jre/bin/sunec.dll
+./jre/bin/sunmscapi.dll
+./jre/bin/t2k.dll
+./jre/bin/unpack.dll
+./jre/bin/verify.dll
+./jre/bin/w2k_lsa_auth.dll
+./jre/bin/zip.dll
+./bin/appletviewer.exe
+./bin/extcheck.exe
+./bin/idlj.exe
+./bin/jar.exe
+./bin/jarsigner.exe
+./bin/java.exe
+./bin/javac.exe
+./bin/javadoc.exe
+./bin/javah.exe
+./bin/javap.exe
+./bin/java-rmi.exe
+./bin/javaw.exe
+./bin/jcmd.exe
+./bin/jconsole.exe
+./bin/jdb.exe
+./bin/jhat.exe
+./bin/jinfo.exe
+./bin/jmap.exe
+./bin/jps.exe
+./bin/jrunscript.exe
+./bin/jsadebugd.exe
+./bin/jstack.exe
+./bin/jstat.exe
+./bin/jstatd.exe
+./bin/keytool.exe
+./bin/kinit.exe
+./bin/klist.exe
+./bin/ktab.exe
+./bin/native2ascii.exe
+./bin/orbd.exe
+./bin/pack200.exe
+./bin/policytool.exe
+./bin/rmic.exe
+./bin/rmid.exe
+./bin/rmiregistry.exe
+./bin/schemagen.exe
+./bin/serialver.exe
+./bin/servertool.exe
+./bin/tnameserv.exe
+./bin/unpack200.exe
+./bin/wsgen.exe
+./bin/wsimport.exe
+./bin/xjc.exe
+./jre/bin/java.exe
+./jre/bin/java-rmi.exe
+./jre/bin/javaw.exe
+./jre/bin/keytool.exe
+./jre/bin/kinit.exe
+./jre/bin/klist.exe
+./jre/bin/ktab.exe
+./jre/bin/orbd.exe
+./jre/bin/pack200.exe
+./jre/bin/policytool.exe
+./jre/bin/rmid.exe
+./jre/bin/rmiregistry.exe
+./jre/bin/servertool.exe
+./jre/bin/tnameserv.exe
+./jre/bin/unpack200.exe
+"
+
+KNOWN_SIZE_DIFF="
+./demo/jvmti/heapTracker/lib/heapTracker.dll
+./demo/jvmti/minst/lib/minst.dll
+./jre/bin/awt.dll
+./jre/bin/java_crw_demo.dll
+./bin/java.exe
+./bin/javaw.exe
+./bin/unpack200.exe
+./jre/bin/java.exe
+./jre/bin/javaw.exe
+./jre/bin/unpack200.exe
+"
+
+KNOWN_SYM_DIFF="
+./jre/bin/awt.dll
+./jre/bin/java_crw_demo.dll
+"
+fi
+
+
+
+if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
+ACCEPTED_JARZIP_CONTENTS="
+/META-INF/INDEX.LIST
+"
+
+KNOWN_BIN_DIFF="
+./jre/lib/libJObjC.dylib
+./jre/lib/libsaproc.dylib
+./jre/lib/server/libjvm.dylib
+"
+
+ACCEPTED_BIN_DIFF="
+./bin/appletviewer
+./bin/extcheck
+./bin/idlj
+./bin/jar
+./bin/jarsigner
+./bin/java
+./bin/javac
+./bin/javadoc
+./bin/javah
+./bin/javap
+./bin/jcmd
+./bin/jconsole
+./bin/jdb
+./bin/jhat
+./bin/jinfo
+./bin/jmap
+./bin/jps
+./bin/jrunscript
+./bin/jsadebugd
+./bin/jstack
+./bin/jstat
+./bin/jstatd
+./bin/keytool
+./bin/native2ascii
+./bin/orbd
+./bin/pack200
+./bin/policytool
+./bin/rmic
+./bin/rmid
+./bin/rmiregistry
+./bin/schemagen
+./bin/serialver
+./bin/servertool
+./bin/tnameserv
+./bin/wsgen
+./bin/wsimport
+./bin/xjc
+./jre/bin/java
+./jre/bin/keytool
+./jre/bin/orbd
+./jre/bin/pack200
+./jre/bin/policytool
+./jre/bin/rmid
+./jre/bin/rmiregistry
+./jre/bin/servertool
+./jre/bin/tnameserv
+"
+
+KNOWN_SIZE_DIFF="
+./jre/lib/libJObjC.dylib
+./jre/lib/server/libjvm.dylib
+"
+
+KNOWN_SYM_DIFF="
+./jre/lib/libJObjC.dylib
+./jre/lib/server/libjvm.dylib
+"
+
+KNOWN_ELF_DIFF="
+./jre/lib/libJObjC.dylib
+./jre/lib/server/libjvm.dylib
+"
+
+SKIP_DIS_DIFF="true"
+
+fi
+
+##########################################################################################
+# Compare text files and ignore specific differences:
+#
+#  * Timestamps in Java sources generated by idl2java
+#  * Sorting order and cleanup style in .properties files
+
+diff_text() {
+    OTHER_FILE=$1
+    THIS_FILE=$2
+
+    SUFFIX="${THIS_FILE##*.}"
+
+    TMP=1
+
+    if [[ "$THIS_FILE" = *"META-INF/MANIFEST.MF" ]]; then
+        TMP=$(LANG=C $DIFF $OTHER_FILE $THIS_FILE | \
+            $GREP '^[<>]' | \
+            $SED -e '/[<>] Ant-Version: Apache Ant .*/d' \
+	         -e '/[<>] Created-By: .* (Oracle Corporation).*/d')
+    fi
+    if test "x$SUFFIX" = "xjava"; then
+        TMP=$(LANG=C $DIFF $OTHER_FILE $THIS_FILE | \
+            $GREP '^[<>]' | \
+            $SED -e '/[<>] \* from.*\.idl/d' \
+                 -e '/[<>] \*.*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
+                 -e '/[<>] \*.*[0-9]\{4\} [0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \
+                 -e '/\/\/ Generated from input file.*/d' \
+                 -e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \
+                 -e '/\/\/ java GenerateCharacter.*/d')
+    fi
+    # Ignore date strings in class files.
+    # On Macosx the system sources for generated java classes produce different output on 
+    # consequtive invokations seemingly randomly.
+    # For example a method parameter randomly named "thePoint" or "aPoint". Ignore this.
+    if test "x$SUFFIX" = "xclass"; then
+        $JAVAP -c -constants -l -p ${OTHER_FILE} >  ${OTHER_FILE}.javap
+        $JAVAP -c -constants -l -p ${THIS_FILE} > ${THIS_FILE}.javap
+        TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \
+            $GREP '^[<>]' | \
+            $SED -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
+	         -e '/[<>].*Point   Lcom\/apple\/jobjc\/foundation\/NSPoint;/d' \
+	         -e '/[<>].*public com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*itemsPtr();/d' \
+	         -e '/[<>].*public void setItemsPtr(com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*);/d')
+    fi
+    if test "x$SUFFIX" = "xproperties"; then
+        $CAT $OTHER_FILE | $SED -e 's/\([^\\]\):/\1\\:/g' -e  's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \
+            | $SED -f "$SRC_ROOT/common/bin/unicode2x.sed" \
+  	    | $SED -e '/^#/d' -e '/^$/d' \
+            -e :a -e '/\\$/N; s/\\\n//; ta' \
+  	    -e 's/^[ \t]*//;s/[ \t]*$//' \
+	    -e 's/\\=/=/' | LANG=C $SORT > $OTHER_FILE.cleaned
+        TMP=$(LANG=C $DIFF $OTHER_FILE.cleaned $THIS_FILE)
+    fi
+    if test -n "$TMP"; then
+        echo Files $OTHER_FILE and $THIS_FILE differ
+        return 1
+    fi
+
+    return 0
+}
+
+##########################################################################################
+# Compare directory structure
+
+compare_dirs() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+
+    mkdir -p $WORK_DIR
+
+    (cd $OTHER_DIR && $FIND . -type d | $SORT > $WORK_DIR/other_dirs)
+    (cd $THIS_DIR && $FIND . -type d | $SORT > $WORK_DIR/this_dirs)
+    
+    echo -n Directory structure...
+    if $DIFF $WORK_DIR/other_dirs $WORK_DIR/this_dirs > /dev/null; then
+        echo Identical!
+    else
+        echo Differences found.
+        REGRESSIONS=true
+    # Differences in directories found.
+        ONLY_OTHER=$($DIFF $WORK_DIR/other_dirs $WORK_DIR/this_dirs | $GREP '<')
+        if [ "$ONLY_OTHER" ]; then
+            echo Only in $OTHER
+            echo $ONLY_OTHER | $SED 's|< ./|\t|g' | $SED 's/ /\n/g'
+        fi
+    # Differences in directories found.
+        ONLY_THIS=$($DIFF $WORK_DIR/other_dirs $WORK_DIR/this_dirs | $GREP '>')
+        if [ "$ONLY_THIS" ]; then
+            echo Only in $THIS
+            echo $ONLY_THIS | $SED 's|> ./|\t|g' | $SED 's/ /\n/g'
+        fi
+    fi
+}
+
+
+##########################################################################################
+# Compare file structure
+
+compare_files() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+
+    mkdir -p $WORK_DIR
+
+    (cd $OTHER_DIR && $FIND . -type f | $SORT > $WORK_DIR/other_files)
+    (cd $THIS_DIR && $FIND . -type f | $SORT > $WORK_DIR/this_files)
+    
+    echo -n File names...
+    if diff $WORK_DIR/other_files $WORK_DIR/this_files > /dev/null; then
+        echo Identical!
+    else
+        echo Differences found.
+        REGRESSIONS=true
+    # Differences in directories found.
+        ONLY_OTHER=$(diff $WORK_DIR/other_files $WORK_DIR/this_files | $GREP '<')
+        if [ "$ONLY_OTHER" ]; then
+            echo Only in $OTHER
+            echo "$ONLY_OTHER" | sed 's|< ./|    |g'
+        fi
+    # Differences in directories found.
+        ONLY_THIS=$(diff $WORK_DIR/other_files $WORK_DIR/this_files | $GREP '>')
+        if [ "$ONLY_THIS" ]; then
+            echo Only in $THIS
+            echo "$ONLY_THIS" | sed 's|> ./|    |g'
+        fi
+    fi
+}
+
+
+##########################################################################################
+# Compare permissions
+
+compare_permissions() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+
+    mkdir -p $WORK_DIR
+
+    echo -n Permissions...
+    found=""
+    for f in `cd $OTHER_DIR && $FIND . -type f`
+    do
+        if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
+        if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
+        OP=`ls -l ${OTHER_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
+        TP=`ls -l ${THIS_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
+        if [ "$OP" != "$TP" ]
+        then
+	    if [ -z "$found" ]; then echo ; found="yes"; fi
+	    $PRINTF "\told: ${OP} new: ${TP}\t$f\n"
+        fi
+    done
+    if [ -z "$found" ]; then 
+        echo "Identical!"
+    else
+        REGRESSIONS=true
+    fi
+}
+
+##########################################################################################
+# Compare file command output
+
+compare_file_types() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+
+    $MKDIR -p $WORK_DIR
+
+    echo -n File types...
+    found=""
+    for f in `cd $OTHER_DIR && $FIND . -type f`
+    do
+        if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
+        if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
+        OF=`cd ${OTHER_DIR} && $FILE $f`
+        TF=`cd ${THIS_DIR} && $FILE $f`
+        if [ "$f" = "./src.zip" ] || [ "$f" = "./jre/lib/JObjC.jar" ] || [ "$f" = "./lib/JObjC.jar" ]
+        then
+	    if [ "`echo $OF | $GREP -ic zip`" -gt 0 -a "`echo $TF | $GREP -ic zip`" -gt 0 ]
+	    then
+	        # the way we produces zip-files make it so that directories are stored in old file
+	        # but not in new (only files with full-path)
+	        # this makes file-5.09 report them as different
+	        continue;
+	    fi
+        fi
+        
+        if [ "$OF" != "$TF" ]
+        then
+	    if [ -z "$found" ]; then echo ; found="yes"; fi
+	    $PRINTF "\tother: ${OF}\n\tthis : ${TF}\n"
+        fi
+    done
+    if [ -z "$found" ]; then 
+        echo "Identical!"
+    else
+        REGRESSIONS=true
+    fi
+}
+
+##########################################################################################
+# Compare the rest of the files
+
+compare_general_files() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+    
+    GENERAL_FILES=$(cd $THIS_DIR && $FIND . -type f ! -name "*.so" ! -name "*.jar" ! -name "*.zip" \
+        ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \
+        ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \
+        ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \
+        ! -name "*.lib" \
+        | $GREP -v "./bin/"  | $SORT | $FILTER)
+
+    echo General files...
+    for f in $GENERAL_FILES
+    do
+        if [ -e $OTHER_DIR/$f ]; then
+            DIFF_OUT=$($DIFF $OTHER_DIR/$f $THIS_DIR/$f 2>&1)
+            if [ -n "$DIFF_OUT" ]; then
+                echo $f
+                REGRESSIONS=true
+                if [ "$SHOW_DIFFS" = "true" ]; then
+                    echo "$DIFF_OUT"
+                fi
+            fi
+        fi
+    done
+
+
+}
+
+##########################################################################################
+# Compare zip file
+
+compare_zip_file() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+    ZIP_FILE=$4
+
+    THIS_ZIP=$THIS_DIR/$ZIP_FILE
+    OTHER_ZIP=$OTHER_DIR/$ZIP_FILE
+
+    THIS_SUFFIX="${THIS_ZIP##*.}"
+    OTHER_SUFFIX="${OTHER_ZIP##*.}"
+    if [ "$THIS_SUFFIX" != "$OTHER_SUFFIX" ]; then
+        echo The files do not have the same suffix type!
+        return 2
+    fi
+
+    UNARCHIVE="$UNZIP -q"
+
+    TYPE="$THIS_SUFFIX"
+
+    if $CMP $OTHER_ZIP $THIS_ZIP > /dev/null
+    then
+        return 0
+    fi
+    # Not quite identical, the might still contain the same data.
+    # Unpack the jar/zip files in temp dirs
+    
+    THIS_UNZIPDIR=$WORK_DIR/$ZIP_FILE.this
+    OTHER_UNZIPDIR=$WORK_DIR/$ZIP_FILE.other
+    $RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR
+    $MKDIR -p $THIS_UNZIPDIR
+    $MKDIR -p $OTHER_UNZIPDIR
+    (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)
+    (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)
+
+    CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff
+    LANG=C $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE
+
+    ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE)
+    ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE)
+
+    return_value=0
+
+    if [ -n "$ONLY_OTHER" ]; then
+        echo "        Only OTHER $ZIP_FILE contains:"
+        echo "$ONLY_OTHER" | sed "s|Only in $OTHER_UNZIPDIR|            |"g | sed 's|: |/|g'
+        return_value=1
+    fi
+
+    if [ -n "$ONLY_THIS" ]; then
+        echo "        Only THIS $ZIP_FILE contains:"
+        echo "$ONLY_THIS" | sed "s|Only in $THIS_UNZIPDIR|            |"g | sed 's|: |/|g'
+        return_value=1
+    fi
+
+    DIFFING_FILES=$($GREP differ $CONTENTS_DIFF_FILE | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
+
+    $RM -f $WORK_DIR/$ZIP_FILE.diffs
+    for file in $DIFFING_FILES; do
+	if [[ "$ACCEPTED_JARZIP_CONTENTS" != *"$file"* ]]; then
+            diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs
+	fi
+    done
+
+    if [ -s "$WORK_DIR/$ZIP_FILE.diffs" ]; then
+        return_value=1
+        echo "        Differing files in $ZIP_FILE"
+        $CAT $WORK_DIR/$ZIP_FILE.diffs | $GREP differ | cut -f 2 -d ' ' | \
+            $SED "s|$OTHER_UNZIPDIR|            |g" > $WORK_DIR/$ZIP_FILE.difflist
+        $CAT $WORK_DIR/$ZIP_FILE.difflist
+
+        if [ -n "$SHOW_DIFFS" ]; then
+            for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do
+                if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then
+                    LANG=C $DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap
+                elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then
+                    LANG=C $DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i
+                else
+                    LANG=C $DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i
+                fi
+            done
+        fi
+    fi
+
+    return $return_value
+}
+
+
+##########################################################################################
+# Compare all zip files
+
+compare_all_zip_files() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+
+    ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER )
+
+    if [ -n "$ZIPS" ]; then
+        echo Zip files...
+
+        return_value=0
+        for f in $ZIPS; do
+            if [ -f "$OTHER_DIR/$f" ]; then
+                compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
+                if [ "$?" != "0" ]; then
+                    return_value=1
+                    REGRESSIONS=true
+                fi
+            fi
+        done
+    fi
+
+    return $return_value
+}
+
+##########################################################################################
+# Compare all jar files
+
+compare_all_jar_files() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+
+    # TODO filter?
+    ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" | $SORT | $FILTER)
+
+    if [ -n "$ZIPS" ]; then
+        echo Jar files...
+
+        return_value=0
+        for f in $ZIPS; do
+            if [ -f "$OTHER_DIR/$f" ]; then
+                compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
+                if [ "$?" != "0" ]; then
+                    return_value=1
+                    REGRESSIONS=true
+                fi
+            fi
+        done
+    fi
+
+    return $return_value
+}
+
+##########################################################################################
+# Compare binary (executable/library) file
+
+compare_bin_file() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+    BIN_FILE=$4
+
+    THIS_FILE=$THIS_DIR/$BIN_FILE
+    OTHER_FILE=$OTHER_DIR/$BIN_FILE
+    NAME=$(basename $BIN_FILE)
+    WORK_FILE_BASE=$WORK_DIR/$BIN_FILE
+    FILE_WORK_DIR=$(dirname $WORK_FILE_BASE)
+
+    $MKDIR -p $FILE_WORK_DIR
+
+    ORIG_THIS_FILE="$THIS_FILE"
+    ORIG_OTHER_FILE="$OTHER_FILE"
+
+    if [[ "$STRIP_BEFORE_COMPARE" = *"$BIN_FILE"* ]]; then
+        THIS_STRIPPED_FILE=$FILE_WORK_DIR/this/$NAME
+        OTHER_STRIPPED_FILE=$FILE_WORK_DIR/other/$NAME
+        $MKDIR -p $FILE_WORK_DIR/this $FILE_WORK_DIR/other
+        $CP $THIS_FILE $THIS_STRIPPED_FILE
+        $CP $OTHER_FILE $OTHER_STRIPPED_FILE
+        $STRIP $THIS_STRIPPED_FILE
+        $STRIP $OTHER_STRIPPED_FILE
+        THIS_FILE="$THIS_STRIPPED_FILE"
+        OTHER_FILE="$OTHER_STRIPPED_FILE"
+    fi
+
+    if [ -z "$SKIP_BIN_DIFF" ]; then
+        if cmp $OTHER_FILE $THIS_FILE > /dev/null; then
+        # The files were bytewise identical.
+            if [ -n "$VERBOSE" ]; then
+                echo "        :           :         :         :          : $BIN_FILE"
+            fi
+            return 0
+        fi
+        BIN_MSG=" diff "
+        if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then
+            DIFF_BIN=true
+            if [[ "$KNOWN_BIN_DIFF" != *"$BIN_FILE"* ]]; then
+                BIN_MSG="*$BIN_MSG*"
+                REGRESSIONS=true
+            else
+                BIN_MSG=" $BIN_MSG "
+            fi
+        else
+            BIN_MSG="($BIN_MSG)"
+            DIFF_BIN=
+        fi
+    fi
+
+    THIS_SIZE=$(ls -l "$THIS_FILE" | awk '{ print $5 }')
+    OTHER_SIZE=$(ls -l "$OTHER_FILE" | awk '{ print $5 }')
+    if [ $THIS_SIZE -ne $OTHER_SIZE ]; then
+        DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE)
+        DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE)
+        SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM)
+        if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] && [ "$DIFF_SIZE_REL" -lt 102 ]; then
+            SIZE_MSG="($SIZE_MSG)"
+            DIFF_SIZE=
+        else
+            if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
+                DIFF_SIZE=true
+                if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
+                    SIZE_MSG="*$SIZE_MSG*"
+                    REGRESSIONS=true
+                else
+                    SIZE_MSG=" $SIZE_MSG "
+                fi
+            else
+                SIZE_MSG="($SIZE_MSG)"
+                DIFF_SIZE=
+            fi
+        fi
+    else
+        SIZE_MSG="           "
+        DIFF_SIZE=
+        if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then
+            SIZE_MSG="     !     "
+        fi
+    fi
+
+    if [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then
+        SYM_SORT_CMD="sort"
+    else
+        SYM_SORT_CMD="cat"
+    fi
+
+    # Check symbols
+    if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
+	$DUMPBIN -exports $OTHER_FILE | $GREP " = " | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
+	$DUMPBIN -exports $THIS_FILE  | $GREP " = " | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
+    elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
+        # Some symbols get seemingly random 15 character prefixes. Filter them out.
+        $NM -a $ORIG_OTHER_FILE | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SED 's/^\([a-zA-Z] \.\)[a-zA-Z0-9_\$]\{15,15\}\./\1./g' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
+	$NM -a $ORIG_THIS_FILE  | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SED 's/^\([a-zA-Z] \.\)[a-zA-Z0-9_\$]\{15,15\}\./\1./g' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
+    else
+	$NM -a $ORIG_OTHER_FILE | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
+	$NM -a $ORIG_THIS_FILE  | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
+    fi
+    
+    LANG=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff
+    if [ -s $WORK_FILE_BASE.symbols.diff ]; then
+        SYM_MSG=" diff  "
+        if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then
+            DIFF_SYM=true
+            if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then
+                SYM_MSG="*$SYM_MSG*"
+                REGRESSIONS=true
+            else
+                SYM_MSG=" $SYM_MSG "
+            fi
+        else
+            SYM_MSG="($SYM_MSG)"            
+            DIFF_SYM=
+        fi
+    else
+        SYM_MSG="         "
+        DIFF_SYM=
+        if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then
+            SYM_MSG="    !    "
+        fi
+    fi
+
+    # Check dependencies
+    if [ -n "$LDD_CMD" ];then
+	(cd $FILE_WORK_DIR && $CP $OTHER_FILE . && $LDD_CMD $NAME | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.other | $UNIQ > $WORK_FILE_BASE.deps.other.uniq)
+	(cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.this | $UNIQ > $WORK_FILE_BASE.deps.this.uniq)
+	(cd $FILE_WORK_DIR && $RM -f $NAME)
+	
+	LANG=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this > $WORK_FILE_BASE.deps.diff
+	LANG=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq > $WORK_FILE_BASE.deps.diff.uniq
+	
+	if [ -s $WORK_FILE_BASE.deps.diff ]; then
+            if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then
+		DEP_MSG=" diff  "
+            else
+		DEP_MSG=" redun "
+            fi
+            if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then
+		DIFF_DEP=true
+		if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then
+                    DEP_MSG="*$DEP_MSG*"
+                    REGRESSIONS=true
+		else
+                    DEP_MSG=" $DEP_MSG "
+		fi
+            else
+		DEP_MSG="($DEP_MSG)"
+		DIFF_DEP=
+            fi
+	else
+	    DEP_MSG="         "
+	    DIFF_DEP=
+            if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
+                DEP_MSG="     !      "
+            fi
+	fi
+    fi
+    
+    # Compare readelf output
+    if [ -n "$READELF_CMD" ] && [ -z "$SKIP_ELF_DIFF" ]; then
+        $READELF_CMD $OTHER_FILE > $WORK_FILE_BASE.readelf.other 2>&1
+        $READELF_CMD $THIS_FILE > $WORK_FILE_BASE.readelf.this 2>&1
+        
+        LANG=C $DIFF $WORK_FILE_BASE.readelf.other $WORK_FILE_BASE.readelf.this > $WORK_FILE_BASE.readelf.diff
+        
+        if [ -s $WORK_FILE_BASE.readelf.diff ]; then
+            ELF_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.readelf.diff | awk '{print $5}')
+            ELF_MSG=$($PRINTF "%8d" $ELF_DIFF_SIZE)
+            if [[ "$ACCEPTED_ELF_DIFF" != *"$BIN_FILE"* ]]; then
+                DIFF_ELF=true
+                if [[ "$KNOWN_ELF_DIFF" != *"$BIN_FILE"* ]]; then
+                    ELF_MSG="*$ELF_MSG*"
+                    REGRESSIONS=true
+                else
+                    ELF_MSG=" $ELF_MSG "
+                fi
+            else
+                ELF_MSG="($ELF_MSG)"
+                DIFF_ELF=
+            fi
+        else
+            ELF_MSG="          "
+            DIFF_ELF=
+            if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
+                ELF_MSG="    !    "
+            fi
+        fi
+    fi
+
+    # Compare disassemble output
+    if [ -f "$OBJDUMP" ] && [ -z "$SKIP_DIS_DIFF" ]; then
+        $OBJDUMP -d $OTHER_FILE | $GREP -v $NAME > $WORK_FILE_BASE.dis.other 2>&1
+        $OBJDUMP -d $THIS_FILE  | $GREP -v $NAME > $WORK_FILE_BASE.dis.this  2>&1
+        
+        LANG=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff
+        
+        if [ -s $WORK_FILE_BASE.dis.diff ]; then
+            DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}')
+            DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE)
+            if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then
+                DIFF_DIS=true
+                if [[ "$KNOWN_DIS_DIFF" != *"$BIN_FILE"* ]]; then
+                    DIS_MSG="*$DIS_MSG*"
+                    REGRESSIONS=true
+                else
+                    DIS_MSG=" $DIS_MSG "
+                fi
+            else
+                DIS_MSG="($DIS_MSG)"
+                DIFF_DIS=
+            fi
+        else
+            DIS_MSG="          "
+            DIFF_DIS=
+            if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
+                DIS_MSG="    !    "
+            fi
+        fi
+    fi
+
+
+    if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_ELF$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then
+        if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi
+        if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi
+        if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi
+        if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi
+        if [ -n "$ELF_MSG" ]; then echo -n "$ELF_MSG:"; fi
+        if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi
+        echo " $BIN_FILE"
+        if [ "$SHOW_DIFFS" = "true" ]; then
+            if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then
+                echo "Symbols diff:"
+                $CAT $WORK_FILE_BASE.symbols.diff
+            fi
+            if [ -s "$WORK_FILE_BASE.deps.diff" ]; then
+                echo "Deps diff:"
+                $CAT $WORK_FILE_BASE.deps.diff
+            fi
+            if [ -s "$WORK_FILE_BASE.readelf.diff" ]; then
+                echo "Readelf diff:"
+                $CAT $WORK_FILE_BASE.readelf.diff
+            fi
+            if [ -s "$WORK_FILE_BASE.dis.diff" ]; then
+                echo "Disassembly diff:"
+                $CAT $WORK_FILE_BASE.dis.diff
+            fi
+        fi
+        return 1
+    fi
+    return 0
+}
+
+##########################################################################################
+# Print binary diff header
+
+print_binary_diff_header() {
+    if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi
+    if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n "   Size    :"; fi
+    if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi
+    if [ -z "$SKIP_DEP_DIFF" ]; then echo -n "  Deps   :"; fi
+    if [ -z "$SKIP_ELF_DIFF" ]; then echo -n " Readelf  :"; fi
+    if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass   :"; fi
+    echo
+}
+
+##########################################################################################
+# Compare all libraries
+
+compare_all_libs() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+
+    LIBS=$(cd $THIS_DIR && $FIND . -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' | $SORT | $FILTER)
+
+    if [ -n "$LIBS" ]; then
+        echo Libraries...
+        print_binary_diff_header
+        for l in $LIBS; do
+            if [ -f "$OTHER_DIR/$l" ]; then
+                compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l
+                if [ "$?" != "0" ]; then
+                    return_value=1
+                fi
+            fi
+        done
+    fi
+
+    return $return_value
+}
+
+##########################################################################################
+# Compare all executables
+
+compare_all_execs() {
+    THIS_DIR=$1
+    OTHER_DIR=$2
+    WORK_DIR=$3
+
+    if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
+        EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER)
+    else
+        EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \) | $SORT | $FILTER)
+    fi
+
+    if [ -n "$EXECS" ]; then
+        echo Executables...
+        print_binary_diff_header
+        for e in $EXECS; do
+            if [ -f "$OTHER_DIR/$e" ]; then
+                compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e
+                if [ "$?" != "0" ]; then
+                    return_value=1
+                fi
+            fi
+        done
+    fi
+
+    return $return_value
+}
+
+##########################################################################################
+# Initiate configuration
+
+COMPARE_ROOT=/tmp/cimages.$USER
+$MKDIR -p $COMPARE_ROOT
+if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
+    if [ "$(uname -o)" = "Cygwin" ]; then
+	COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT)
+    fi
+fi
+
+THIS="$( cd "$( dirname "$0" )" && pwd )"
+echo "$THIS"
+THIS_SCRIPT="$0"
+
+if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
+    echo "bash ./compare.sh [OPTIONS] [FILTER]"
+    echo ""
+    echo "-all                Compare all files in all known ways"
+    echo "-names              Compare the file names and directory structure"
+    echo "-perms              Compare the permission bits on all files and directories"
+    echo "-types              Compare the output of the file command on all files"
+    echo "-general            Compare the files not convered by the specialized comparisons"
+    echo "-zips               Compare the contents of all zip files"
+    echo "-jars               Compare the contents of all jar files"
+    echo "-libs               Compare all native libraries"
+    echo "-execs              Compare all executables"
+    echo "-v                  Verbose output, does not hide known differences"
+    echo "-vv                 More verbose output, shows diff output of all comparisons"
+    echo "-o [OTHER]          Compare with build in other directory. Will default to the old build directory"
+    echo ""
+    echo "[FILTER]            List filenames in the image to compare, works for jars, zips, libs and execs"
+    echo "Example:"
+    echo "bash ./common/bin/compareimages.sh CodePointIM.jar"
+    exit 10
+fi
+
+CMP_NAMES=false
+CMP_PERMS=false
+CMP_TYPES=false
+CMP_GENERAL=false
+CMP_ZIPS=false
+CMP_JARS=false
+CMP_LIBS=false
+CMP_EXECS=false
+
+while [ -n "$1" ]; do
+    case "$1" in
+        -v)
+            VERBOSE=true
+            ;;
+        -vv)
+            VERBOSE=true
+            SHOW_DIFFS=true
+            ;;
+        -o)
+            OTHER=$2
+            shift
+            ;;
+        -all)
+            CMP_NAMES=true
+            if [ "$OPENJDK_TARGET_OS" != "windows" ]; then
+                CMP_PERMS=true
+            fi
+            CMP_TYPES=true
+            CMP_GENERAL=true
+            CMP_ZIPS=true
+            CMP_JARS=true
+            CMP_LIBS=true
+            CMP_EXECS=true
+            ;;
+        -names)
+            CMP_NAMES=true
+            ;;
+        -perms)
+            CMP_PERMS=true
+            ;;
+        -types)
+            CMP_TYPES=true
+            ;;
+        -general)
+            CMP_GENERAL=true
+            ;;
+        -zips)
+            CMP_ZIPS=true
+            ;;
+        -jars)
+            CMP_JARS=true
+            ;;
+        -libs)
+            CMP_LIBS=true
+            ;;
+        -execs)
+            CMP_EXECS=true
+            ;;
+        *)
+            CMP_NAMES=false
+            CMP_PERMS=false
+            CMP_TYPES=false
+            CMP_ZIPS=true
+            CMP_JARS=true
+            CMP_LIBS=true
+            CMP_EXECS=true
+            
+            if [ -z "$FILTER" ]; then
+                FILTER="$GREP"
+            fi
+            FILTER="$FILTER -e $1"
+            ;;
+    esac
+    shift
+done
+
+if [ "$CMP_NAMES" = "false" ] && [ "$CMP_TYPES" = "false" ] && [ "$CMP_PERMS" = "false" ] && [ "$CMP_GENERAL" = "false" ] && [ "$CMP_ZIPS" = "false" ] && [ "$CMP_JARS" = "false" ] && [ "$CMP_LIBS" = "false" ] && [ "$CMP_EXECS" = "false" ]; then
+    CMP_NAMES=true
+    CMP_PERMS=true
+    CMP_TYPES=true
+    CMP_GENERAL=true
+    CMP_ZIPS=true
+    CMP_JARS=true
+    CMP_LIBS=true
+    CMP_EXECS=true
+fi
+
+if [ -z "$FILTER" ]; then
+    FILTER="$CAT"
+fi
+
+if [ -z "$OTHER" ]; then
+    OTHER="$THIS/../$LEGACY_BUILD_DIR"
+    if [ -d "$OTHER" ]; then
+        OTHER="$( cd "$OTHER" && pwd )"
+    else
+        echo "Default old build directory does not exist:"
+        echo "$OTHER"
+    fi
+    echo "Comparing to default old build:"
+    echo "$OTHER"
+    echo
+else
+    echo "Comparing to:"
+    echo "$OTHER"
+    echo
+fi
+
+if [ ! -d "$OTHER" ]; then
+    echo "Other build directory does not exist:"
+    echo "$OTHER"
+    exit 1;
+fi
+
+# Figure out the layout of the new build. Which kinds of images have been produced
+if [ -d "$THIS/images/j2sdk-image" ]; then
+    THIS_J2SDK="$THIS/images/j2sdk-image"
+    THIS_J2RE="$THIS/images/j2re-image"
+fi
+if [ -d "$THIS/images/j2sdk-overlay-image" ]; then
+    THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image"
+    THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image"
+fi
+
+# Figure out the layout of the other build (old or new, normal or overlay image)
+if [ -d "$OTHER/j2sdk-image" ]; then
+    if [ -f "$OTHER/j2sdk-image/LICENSE" ]; then
+        OTHER_J2SDK="$OTHER/j2sdk-image"
+        OTHER_J2RE="$OTHER/j2re-image"
+    else
+        OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image"
+        OTHER_J2RE_OVERLAY="$OTHER/j2re-image"
+    fi
+
+fi
+
+if [ -z "$OTHER_J2SDK" ] && [ -n "$OTHER_J2SDK_OVERLAY" ] && [ -z "$THIS_J2SDK_OVERLAY" ]; then
+    echo "OTHER build only has an overlay image while this build does not. Nothing to compare!"
+    exit 1
+fi
+
+
+##########################################################################################
+# Do the work
+
+if [ "$CMP_NAMES" = "true" ]; then
+    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
+        echo -n "J2SDK "
+        compare_dirs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
+        echo -n "J2RE  "
+        compare_dirs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
+        
+        echo -n "J2SDK "
+        compare_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
+        echo -n "J2RE  "
+        compare_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
+    fi
+    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
+        echo -n "J2SDK Overlay "
+        compare_dirs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
+        echo -n "J2RE  Overlay "
+        compare_dirs $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
+        
+        echo -n "J2SDK Overlay "
+        compare_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
+        echo -n "J2RE  Overlay "
+        compare_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
+    fi
+fi
+
+if [ "$CMP_PERMS" = "true" ]; then
+    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
+        echo -n "J2SDK "
+        compare_permissions $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
+        echo -n "J2RE  "
+        compare_permissions $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
+    fi
+    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
+        echo -n "J2SDK Overlay "
+        compare_permissions $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
+        echo -n "J2RE  Overlay "
+        compare_permissions $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
+    fi
+fi
+
+if [ "$CMP_TYPES" = "true" ]; then
+    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
+        echo -n "J2SDK "
+        compare_file_types $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
+        echo -n "J2RE  "
+        compare_file_types $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
+    fi
+    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
+        echo -n "J2SDK Overlay "
+        compare_file_types $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
+        echo -n "J2RE  Overlay "
+        compare_file_types $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
+    fi
+fi
+
+if [ "$CMP_GENERAL" = "true" ]; then
+    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
+        echo -n "J2SDK "
+        compare_general_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
+        echo -n "J2RE  "
+        compare_general_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
+    fi
+    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
+        echo -n "J2SDK Overlay "
+        compare_general_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
+        echo -n "J2RE  Overlay "
+        compare_general_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
+    fi
+fi
+
+if [ "$CMP_ZIPS" = "true" ]; then
+    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
+        compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
+    fi
+fi
+
+if [ "$CMP_JARS" = "true" ]; then
+    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
+        compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
+    fi
+fi
+
+if [ "$CMP_LIBS" = "true" ]; then
+    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
+        compare_all_libs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
+    fi
+    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
+        echo -n "Overlay "
+        compare_all_libs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
+    fi
+fi
+
+if [ "$CMP_EXECS" = "true" ]; then
+    if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
+        compare_all_execs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
+    fi
+    if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
+        echo -n "Overlay "
+        compare_all_execs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
+    fi
+fi
+
+echo
+
+if [ -n "$REGRESSIONS" ]; then
+    echo "REGRESSIONS FOUND!"
+    echo
+    exit 1
+else
+    echo "No regressions found"
+    echo
+    exit 0
+fi
--- a/common/autoconf/configure	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/configure	Tue Sep 25 11:48:00 2012 -0700
@@ -2,7 +2,12 @@
 
 CONFIGURE_COMMAND_LINE="$@"
 conf_script_dir=`dirname $0`
-conf_closed_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
+
+if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
+  conf_custom_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
+else
+  conf_custom_script_dir=$CUSTOM_CONFIG_DIR
+fi
 
 ###
 ### Test that the generated configure is up-to-date
@@ -14,8 +19,12 @@
 print_error_not_up_to_date() {
   echo "Error: The configure source files is newer than the generated files."
   echo "Please run 'sh autogen.sh' to update the generated files."
+  echo "Note that this test might trigger incorrectly sometimes due to hg timestamps".
 }
 
+# NOTE: This test can occasionally go wrong due to the way mercurial handles
+# timestamps. It it supposed to aid during development of build-infra, but should
+# go away before making this the default build system.
 for file in configure.ac *.m4 ; do
   if $TEST $file -nt generated-configure.sh; then
     print_error_not_up_to_date
@@ -23,26 +32,32 @@
   fi
 done
 
-if $TEST -e $conf_closed_script_dir/generated-configure.sh; then
-  # If closed source configure is available, make sure it is up-to-date as well.
-  for file in configure.ac *.m4 $conf_closed_script_dir/*.m4; do
-    if $TEST $file -nt $conf_closed_script_dir/generated-configure.sh; then
+if $TEST -e $conf_custom_script_dir/generated-configure.sh; then
+  # If custom source configure is available, make sure it is up-to-date as well.
+  for file in configure.ac *.m4 $conf_custom_script_dir/*.m4; do
+    if $TEST $file -nt $conf_custom_script_dir/generated-configure.sh; then
       print_error_not_up_to_date
       exit 1
     fi
   done
 
-  # Test if open configure is newer than closed configure, if so, closed needs to
-  # be regenerated.
+  # Test if open configure is newer than custom configure, if so, custom needs to
+  # be regenerated. This test is required to ensure consistency with custom source.
   conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_script_dir/generated-configure.sh  | cut -d" " -f 3`
-  conf_closed_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_closed_script_dir/generated-configure.sh  | cut -d" " -f 3`
-  if $TEST $conf_open_configure_timestamp -gt $conf_closed_configure_timestamp; then
-    print_error_not_up_to_date
+  conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_custom_script_dir/generated-configure.sh  | cut -d" " -f 3`
+  if $TEST $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
+    echo "Error: The generated configure file contains changes not present in the custom generated file."
+    echo "Please run 'sh autogen.sh' to update the generated files."
     exit 1
   fi
   
 fi
 
+# Autoconf calls the configure script recursively sometimes. 
+# Don't start logging twice in that case
+if $TEST "x$conf_debug_configure" = xtrue; then
+  conf_debug_configure=recursive
+fi
 ###
 ### Process command-line arguments
 ###
@@ -63,6 +78,12 @@
   --with-extra-cxxflags=*)
     conf_extra_cxxflags=`expr "X$conf_option" : '[^=]*=\(.*\)'`
     continue ;;
+  --debug-configure)
+    if $TEST "x$conf_debug_configure" != xrecursive; then
+      conf_debug_configure=true
+      export conf_debug_configure
+    fi
+    continue ;;
   *)
     conf_processed_arguments="$conf_processed_arguments $conf_option" ;;
   esac
@@ -104,13 +125,29 @@
 ###
 ### Call the configure script
 ###
-if $TEST -e $conf_closed_script_dir/generated-configure.sh; then
-  # Closed source configure available; run that instead
-  . $conf_closed_script_dir/generated-configure.sh $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
+if $TEST -e $conf_custom_script_dir/generated-configure.sh; then
+  # Custom source configure available; run that instead
+  echo Running custom generated-configure.sh
+  conf_script_to_run=$conf_custom_script_dir/generated-configure.sh
 else
-  . $conf_script_dir/generated-configure.sh $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
+  echo Running generated-configure.sh
+  conf_script_to_run=$conf_script_dir/generated-configure.sh
+fi  
+
+if $TEST "x$conf_debug_configure" != x; then
+  # Turn on shell debug output if requested (initial or recursive)
+  set -x
 fi
 
+if $TEST "x$conf_debug_configure" = xtrue; then
+  # Turn on logging, but don't turn on twice when called recursive
+  conf_debug_logfile=./debug-configure.log
+  (exec 3>&1 ; (. $conf_script_to_run $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags" 2>&1 1>&3 ) | tee -a $conf_debug_logfile 1>&2 ; exec 3>&-) | tee -a $conf_debug_logfile
+else
+  . $conf_script_to_run $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
+fi
+
+conf_result_code=$?
 ###
 ### Post-processing
 ###
@@ -119,3 +156,5 @@
 if $TEST -d "$OUTPUT_ROOT"; then
   mv -f config.log "$OUTPUT_ROOT" 2> /dev/null
 fi
+
+exit $conf_result_code
--- a/common/autoconf/configure.ac	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/configure.ac	Tue Sep 25 11:48:00 2012 -0700
@@ -53,9 +53,9 @@
 m4_include([toolchain.m4])
 
 # This line needs to be here, verbatim, after all includes.
-# It is replaced with closed functionality when building
-# closed sources.
-AC_DEFUN_ONCE([CLOSED_HOOK])
+# It is replaced with custom functionality when building
+# custom sources.
+AC_DEFUN_ONCE([CUSTOM_HOOK])
 
 ###############################################################################
 #
@@ -65,6 +65,12 @@
 
 # Basic initialization that must happen first of all
 BASIC_INIT
+
+# Now we can determine OpenJDK build and target platforms. This is required to
+# have early on.
+PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET
+
+# Continue setting up basic stuff.
 BASIC_SETUP_PATHS
 BASIC_SETUP_LOGGING
 
@@ -75,28 +81,18 @@
 # Without these, we can't properly run the rest of the configure script.
 BASIC_SETUP_TOOLS
 
+# Check if pkg-config is available.
+PKG_PROG_PKG_CONFIG
+
+# After basic tools have been setup, we can check build os specific details.
+PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION
+
 # Setup builddeps, for automatic downloading of tools we need.
 # This is needed before we can call BDEPS_CHECK_MODULE, which is done in
 # boot-jdk setup, but we need to have basic tools setup first.
 BDEPS_CONFIGURE_BUILDDEPS
 BDEPS_SCAN_FOR_BUILDDEPS
 
-# Check if pkg-config is available.
-PKG_PROG_PKG_CONFIG
-
-###############################################################################
-#
-# Determine OpenJDK build and target platforms.
-#
-###############################################################################
-
-PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET
-PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION
-
-# With knowledge of the build platform, setup more basic things.
-BASIC_SETUP_PATH_SEP
-BASIC_SETUP_SEARCHPATH
-
 ###############################################################################
 #
 # Determine OpenJDK variants, options and version numbers.
@@ -148,7 +144,7 @@
 # FIXME: Currently we must test this after paths but before flags. Fix!
 
 # And we can test some aspects on the target using configure macros.
-PLATFORM_TEST_OPENJDK_TARGET_BITS
+PLATFORM_SETUP_OPENJDK_TARGET_BITS
 PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS
 
 # Configure flags for the tools
@@ -213,8 +209,8 @@
 # Check for some common pitfalls
 BASIC_TEST_USABILITY_ISSUES
 
-# At the end, call the closed hook. (Dummy macro if no closed sources available)
-CLOSED_HOOK
+# At the end, call the custom hook. (Dummy macro if no custom sources available)
+CUSTOM_HOOK
 
 # We're messing a bit with internal autoconf variables to put the config.status
 # in the output directory instead of the current directory.
@@ -222,5 +218,8 @@
 # Create the actual output files. Now the main work of configure is done.
 AC_OUTPUT
 
+# Make the compare script executable
+$CHMOD +x $OUTPUT_ROOT/compare.sh
+
 # Finally output some useful information to the user
 HELP_PRINT_SUMMARY_AND_WARNINGS
--- a/common/autoconf/generated-configure.sh	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/generated-configure.sh	Tue Sep 25 11:48:00 2012 -0700
@@ -597,13 +597,10 @@
 LIBOBJS
 CCACHE
 USE_PRECOMPILED_HEADER
+SJAVAC_SERVER_DIR
 ENABLE_SJAVAC
-JAVAC_USE_MODE
-JAVAC_USE_DEPS
-JAVAC_SERVER_CORES
-JAVAC_SERVERS
-JAVAC_USE_REMOTE
-SERVER_JAVA
+SJAVAC_SERVER_CORES
+SJAVAC_SERVER_JAVA
 MEMORY_SIZE
 CONCURRENT_BUILD_JOBS
 NUM_CORES
@@ -635,6 +632,7 @@
 ZIP_DEBUGINFO_FILES
 ENABLE_DEBUG_SYMBOLS
 UNCYGDRIVE
+LDFLAGS_CXX_JDK
 LDFLAGS_JDKEXE_SUFFIX
 LDFLAGS_JDKLIB_SUFFIX
 LDFLAGS_JDKEXE
@@ -644,6 +642,9 @@
 CFLAGS_JDKEXE
 CFLAGS_JDKLIB
 PACKAGE_PATH
+LEGACY_EXTRA_LDFLAGS
+LEGACY_EXTRA_CXXFLAGS
+LEGACY_EXTRA_CFLAGS
 CXX_FLAG_DEPS
 C_FLAG_DEPS
 CXX_O_FLAG_NONE
@@ -656,6 +657,7 @@
 C_O_FLAG_HIGHEST
 POST_MCS_CMD
 POST_STRIP_CMD
+SET_EXECUTABLE_ORIGIN
 SET_SHARED_LIBRARY_ORIGIN
 CXX_FLAG_REORDER
 C_FLAG_REORDER
@@ -669,14 +671,11 @@
 STATIC_LIBRARY
 SHARED_LIBRARY
 OBJ_SUFFIX
-ENDIAN
-ARCH_DATA_MODEL
-LP64
+LIPO
 OBJCOPY
 MCS
 STRIP
 NM
-ASFLAGS
 AS
 CXXCPP
 CPP
@@ -706,30 +705,18 @@
 LDFLAGS
 CFLAGS
 CC
-HOSTLD
-HOSTCXX
-HOSTCC
-DEFINE_CROSS_COMPILE_ARCH
+BUILD_LD
+BUILD_CXX
+BUILD_CC
 MSVCR100DLL
 CHECK_FOR_VCINSTALLDIR
 SETUPDEVENV
+CYGWIN_LINK
 AR_OUT_OPTION
 LD_OUT_OPTION
 EXE_OUT_OPTION
 CC_OUT_OPTION
-SYS_ROOT
-HOTSPOT_DIST
-JAXWS_DIST
-JAXP_DIST
-CORBA_DIST
-LANGTOOLS_DIST
-IMAGES_OUTPUTDIR
-JDK_OUTPUTDIR
-HOTSPOT_OUTPUTDIR
-JAXWS_OUTPUTDIR
-JAXP_OUTPUTDIR
-CORBA_OUTPUTDIR
-LANGTOOLS_OUTPUTDIR
+BUILD_OUTPUT
 OVERRIDE_SRC_ROOT
 ADD_SRC_ROOT
 JDK_TOPDIR
@@ -739,17 +726,11 @@
 CORBA_TOPDIR
 LANGTOOLS_TOPDIR
 BOOT_JDK_JVMARGS
-NATIVE2ASCII
-RMIC
-JAR
-JAVAH
 JAVAC_FLAGS
-JAVAC
 BOOT_JDK_SOURCETARGET
-JAVA
+BOOT_JDK
 BOOT_TOOLSJAR
 BOOT_RTJAR
-BOOT_JDK
 JAVA_CHECK
 JAVAC_CHECK
 OUTPUT_ROOT
@@ -777,9 +758,6 @@
 CACERTS_FILE
 TEST_IN_BUILD
 DISABLE_NIMBUS
-GENERATE_DOCS
-ENABLE_DOCS
-BUILD_HEADLESS_ONLY
 BUILD_HEADLESS
 SUPPORT_HEADFUL
 SUPPORT_HEADLESS
@@ -790,6 +768,7 @@
 FASTDEBUG
 VARIANT
 DEBUG_LEVEL
+MACOSX_UNIVERSAL
 JVM_VARIANT_ZEROSHARK
 JVM_VARIANT_ZERO
 JVM_VARIANT_KERNEL
@@ -797,39 +776,98 @@
 JVM_VARIANT_SERVER
 JVM_VARIANTS
 JDK_VARIANT
-MINIMIZE_RAM_USAGE
-JAVASE_EMBEDDED
-PATH_SEP
-CYGPATH
+BDEPS_FTP
+BDEPS_UNZIP
 OS_VERSION_MICRO
 OS_VERSION_MINOR
 OS_VERSION_MAJOR
+PKG_CONFIG
+HG
+OBJDUMP
+READELF
+OTOOL
+LDD
+THEPWDCMD
+FIND_DELETE
+RM
+MAKE
+CHECK_TOOLSDIR_MAKE
+CHECK_TOOLSDIR_GMAKE
+CHECK_MAKE
+CHECK_GMAKE
+NAWK
+SED
+FGREP
+EGREP
+GREP
+AWK
+ZIP
+XARGS
+WC
+UNZIP
+UNIQ
+TR
+TOUCH
+TEE
+TAR
+TAIL
+SORT
+SH
+PRINTF
+MV
+MKDIR
+LS
+LN
+HEAD
+FIND
+FILE
+EXPR
+ECHO
+DIFF
+DF
+DATE
+CUT
+CPIO
+CP
+CMP
+CHMOD
+CAT
+BASENAME
+PKGHANDLER
+BUILD_LOG_WRAPPER
+BUILD_LOG_PREVIOUS
+BUILD_LOG
+SYS_ROOT
+PATH_SEP
+CYGPATH
+SRC_ROOT
+READLINK
+DEFINE_CROSS_COMPILE_ARCH
+LP64
+OPENJDK_TARGET_OS_API_DIR
+OPENJDK_TARGET_CPU_JLI_CFLAGS
+OPENJDK_TARGET_CPU_OSARCH
+OPENJDK_TARGET_CPU_ISADIR
+OPENJDK_TARGET_CPU_LIBDIR
+OPENJDK_TARGET_CPU_LEGACY_LIB
+OPENJDK_TARGET_CPU_LEGACY
 REQUIRED_OS_VERSION
 REQUIRED_OS_NAME
-LEGACY_OPENJDK_BUILD_CPU3
-LEGACY_OPENJDK_BUILD_CPU2
-LEGACY_OPENJDK_BUILD_CPU1
+COMPILE_TYPE
 OPENJDK_BUILD_CPU_ENDIAN
 OPENJDK_BUILD_CPU_BITS
 OPENJDK_BUILD_CPU_ARCH
 OPENJDK_BUILD_CPU
-LEGACY_OPENJDK_BUILD_OS_API
 OPENJDK_BUILD_OS_API
-OPENJDK_BUILD_OS_FAMILY
 OPENJDK_BUILD_OS
-LEGACY_OPENJDK_TARGET_CPU3
-LEGACY_OPENJDK_TARGET_CPU2
-LEGACY_OPENJDK_TARGET_CPU1
 OPENJDK_TARGET_CPU_ENDIAN
 OPENJDK_TARGET_CPU_BITS
 OPENJDK_TARGET_CPU_ARCH
 OPENJDK_TARGET_CPU
-LEGACY_OPENJDK_TARGET_OS_API
 OPENJDK_TARGET_OS_API
-OPENJDK_TARGET_OS_FAMILY
 OPENJDK_TARGET_OS
-OPENJDK_BUILD_SYSTEM
-OPENJDK_TARGET_SYSTEM
+OPENJDK_BUILD_AUTOCONF_NAME
+OPENJDK_TARGET_AUTOCONF_NAME
 target_os
 target_vendor
 target_cpu
@@ -842,60 +880,9 @@
 build_vendor
 build_cpu
 build
-PKG_CONFIG
-BDEPS_FTP
-BDEPS_UNZIP
-HG
-FILE
-EXPR
-READELF
-OTOOL
-LDD
-UNZIP
-ZIP
-XARGS
-WC
-TOUCH
-TR
-TEE
-TAIL
-TAR
-SORT
-SH
-SED
-RM
-THEPWDCMD
-PRINTF
-NAWK
-MV
-MKDIR
-MAKE
-LS
-LN
-HEAD
-FIND_DELETE
-FIND
-FGREP
-EGREP
-GREP
-ECHO
-DIFF
-DF
-DATE
-CUT
-CPIO
-CP
-CHMOD
-CAT
-AWK
-PKGHANDLER
-BUILD_LOG_WRAPPER
-BUILD_LOG_PREVIOUS
-BUILD_LOG
-SRC_ROOT
-READLINK
 DATE_WHEN_CONFIGURED
 CONFIGURE_COMMAND_LINE
+CUSTOM_MAKE_DIR
 target_alias
 host_alias
 build_alias
@@ -937,12 +924,16 @@
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
+with_custom_make_dir
+with_target_bits
+with_sys_root
+with_tools_dir
+with_devkit
 with_builddeps_conf
 with_builddeps_server
 with_builddeps_dir
 with_builddeps_group
 enable_list_builddeps
-with_target_bits
 with_jdk_variant
 with_jvm_variants
 enable_debug
@@ -950,7 +941,6 @@
 enable_openjdk_only
 enable_jigsaw
 enable_headful
-enable_docs
 enable_nimbus
 enable_hotspot_test_in_build
 with_cacerts_file
@@ -968,9 +958,6 @@
 with_override_hotspot
 with_override_jdk
 with_msvcr100dll
-with_sys_root
-with_tools_dir
-with_devkit
 with_extra_cflags
 with_extra_cxxflags
 with_extra_ldflags
@@ -989,11 +976,8 @@
 enable_static_link_stdc__
 with_num_cores
 with_memory_size
-with_server_java
-enable_javac_server
-with_javac_server_cores
-enable_javac_deps
-enable_javac_multi_core
+with_sjavac_server_java
+with_sjavac_server_cores
 enable_sjavac
 enable_precompiled_headers
 enable_ccache
@@ -1649,8 +1633,6 @@
   --enable-jigsaw         build Jigsaw images (not yet available) [disabled]
   --disable-headful       build headful support (graphical UI support)
                           [enabled]
-  --enable-docs           enable generation of Javadoc documentation
-                          [disabled]
   --disable-nimbus        disable Nimbus L&F [enabled]
   --enable-hotspot-test-in-build
                           enable running of Queens test after Hotspot build
@@ -1666,12 +1648,6 @@
   --disable-static-link-stdc++
                           disable static linking of the C++ runtime on Linux
                           [enabled]
-  --enable-javac-server   enable the shared javac server during the build
-                          process [disabled]
-  --enable-javac-deps     enable the dependency tracking between Java packages
-                          [disabled]
-  --enable-javac-multi-core
-                          compile Java packages concurrently [disabled]
   --enable-sjavac         use sjavac to do fast incremental compiles
                           [disabled]
   --disable-precompiled-headers
@@ -1681,6 +1657,16 @@
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-custom-make-dir  directory containing custom build/make files
+  --with-target-bits      build 32-bit or 64-bit binaries (for platforms that
+                          support it), e.g. --with-target-bits=32 [guessed]
+  --with-sys-root         pass this sys-root to the compilers and linker
+                          (useful if the sys-root encoded in the cross
+                          compiler tools is incorrect)
+  --with-tools-dir        search this directory for (cross-compiling)
+                          compilers and tools
+  --with-devkit           use this directory as base for tools-dir and
+                          sys-root (for cross-compiling)
   --with-builddeps-conf   use this configuration file for the builddeps
   --with-builddeps-server download and use build dependencies from this server
                           url, e.g.
@@ -1689,9 +1675,7 @@
                           [d/localhome/builddeps]
   --with-builddeps-group  chgrp the downloaded build dependencies to this
                           group
-  --with-target-bits      build 32-bit or 64-bit binaries (for platforms that
-                          support it), e.g. --with-target-bits=32 [guessed]
-  --with-jdk-variant      JDK variant to build (normal, embedded) [normal]
+  --with-jdk-variant      JDK variant to build (normal) [normal]
   --with-jvm-variants     JVM variants (separated by commas) to build (server,
                           client, kernel, zero, zeroshark) [server]
   --with-debug-level      set the debug level (release, fastdebug, slowdebug)
@@ -1724,12 +1708,6 @@
   --with-override-hotspot use this hotspot dir for the build
   --with-override-jdk     use this jdk dir for the build
   --with-msvcr100dll      copy this msvcr100.dll into the built JDK
-  --with-sys-root         pass this sys-root to the compilers and linker
-                          (useful if the sys-root encoded in the cross
-                          compiler tools is incorrect)
-  --with-tools-dir        search this directory for compilers and tools
-  --with-devkit           use this directory as base for tools-dir and
-                          sys-root
   --with-extra-cflags     extra flags to be used when compiling jdk c-files
   --with-extra-cxxflags   extra flags to be used when compiling jdk c++-files
   --with-extra-ldflags    extra flags to be used when linking jdk
@@ -1753,13 +1731,15 @@
                           --with-num-cores=8 [probed]
   --with-memory-size      memory (in MB) available in the build system, e.g.
                           --with-memory-size=1024 [probed]
-  --with-server-java      use this java binary for running the javac
+  --with-sjavac-server-java
+                          use this java binary for running the sjavac
                           background server and other long running java tasks
                           in the build process, e.g.
-                          ---with-server-java="/opt/jrockit/bin/java -server"
-  --with-javac-server-cores
+                          ---with-sjavac-server-java="/opt/jrockit/bin/java
+                          -server"
+  --with-sjavac-server-cores
                           use at most this number of concurrent threads on the
-                          javac server [probed]
+                          sjavac server [probed]
   --with-ccache-dir       where to store ccache files [~/.ccache]
 
 Some influential environment variables:
@@ -2053,6 +2033,97 @@
 
 } # ac_fn_cxx_try_cpp
 
+# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES
+# ---------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_cxx_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval "test \"\${$3+set}\"" = set; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval "test \"\${$3+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ----------------------------------------- ##
+## Report this to build-dev@openjdk.java.net ##
+## ----------------------------------------- ##"
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval "test \"\${$3+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_cxx_check_header_mongrel
+
 # ac_fn_cxx_try_run LINENO
 # ------------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
@@ -2095,6 +2166,37 @@
 
 } # ac_fn_cxx_try_run
 
+# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES
+# ---------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_cxx_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval "test \"\${$3+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_cxx_check_header_compile
+
 # ac_fn_cxx_compute_int LINENO EXPR VAR INCLUDES
 # ----------------------------------------------
 # Tries to find the compile-time value of EXPR in a program that includes
@@ -2273,37 +2375,6 @@
 
 } # ac_fn_cxx_compute_int
 
-# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES
-# ---------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_cxx_check_header_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_cxx_check_header_compile
-
 # ac_fn_cxx_try_link LINENO
 # -------------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded.
@@ -2507,97 +2578,6 @@
   eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 
 } # ac_fn_c_check_header_mongrel
-
-# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES
-# ---------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_cxx_check_header_mongrel ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval "test \"\${$3+set}\"" = set; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
-  $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_header_compiler=yes
-else
-  ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <$2>
-_ACEOF
-if ac_fn_cxx_try_cpp "$LINENO"; then :
-  ac_header_preproc=yes
-else
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #((
-  yes:no: )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-  no:yes:* )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-( $as_echo "## ----------------------------------------- ##
-## Report this to build-dev@openjdk.java.net ##
-## ----------------------------------------- ##"
-     ) | sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_cxx_check_header_mongrel
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -2952,7 +2932,7 @@
 
 
 # Do not change or remove the following line, it is needed for consistency checks:
-# DATE_WHEN_GENERATED: 1341161875
+# DATE_WHEN_GENERATED: 1347963060
 
 ac_aux_dir=
 for ac_dir in build-aux "$srcdir"/build-aux; do
@@ -3083,10 +3063,7 @@
 
 
 
-
-
-
-
+# Setup basic configuration paths, and platform-specific stuff related to PATHs.
 
 
 
@@ -3096,10 +3073,25 @@
 
 #%%% Simple tools %%%
 
-
-
-
-
+# Check if we have found a usable version of make
+# $1: the path to a potential make binary (or empty)
+# $2: the description on how we found this
+
+
+# Goes looking for a usable version of GNU make.
+
+
+
+
+# Test that variable $1 denoting a program is not empty. If empty, exit with an error.
+# $1: variable to check
+# $2: executable name to print in warning (optional)
+
+
+# Does AC_PATH_PROG followed by CHECK_NONEMPTY.
+# Arguments as AC_PATH_PROG:
+# $1: variable to set
+# $2: executable name to look for
 
 
 
@@ -3176,9 +3168,43 @@
 # questions.
 #
 
-# Fixes paths on windows to be mixed mode short.
-
-
+# Execute the check given as argument, and verify the result
+# If the Boot JDK was previously found, do nothing
+# $1 A command line (typically autoconf macro) to execute
+
+
+# Test: Is bootjdk explicitely set by command line arguments?
+
+
+# Test: Is bootjdk available from builddeps?
+
+
+# Test: Is $JAVA_HOME set?
+
+
+# Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
+
+
+# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX)
+
+
+# Look for a jdk in the given path. If there are multiple, try to select the newest.
+# If found, set BOOT_JDK and BOOT_JDK_FOUND.
+# $1 = Path to directory containing jdk installations.
+# $2 = String to append to the found JDK directory to get the proper JDK home
+
+
+# Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given
+# environmental variable as base for where to look.
+# $1 Name of an environmal variable, assumed to point to the Program Files directory.
+
+
+# Test: Is there a JDK installed in default, well-known locations?
+
+
+# Check that a command-line tool in the Boot JDK is correct
+# $1 = name of variable to assign
+# $2 = name of binary
 
 
 ###############################################################################
@@ -3360,6 +3386,18 @@
 
 
 
+# Support for customization of the build process. Some build files
+# will include counterparts from this location, if they exist. This allows
+# for a degree of customization of the build targets and the rules/recipes
+# to create them
+
+# Check whether --with-custom-make-dir was given.
+if test "${with_custom_make_dir+set}" = set; then :
+  withval=$with_custom_make_dir; CUSTOM_MAKE_DIR=$with_custom_make_dir
+fi
+
+
+
 #
 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -3424,14 +3462,31 @@
 # questions.
 #
 
-
-
-
-
-
-
-
-
+# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
+# Converts autoconf style CPU name to OpenJDK style, into
+# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
+
+
+# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
+# Converts autoconf style OS name to OpenJDK style, into
+# VAR_OS and VAR_OS_API.
+
+
+# Expects $host_os $host_cpu $build_os and $build_cpu
+# and $with_target_bits to have been setup!
+#
+# Translate the standard triplet(quadruplet) definition
+# of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
+# OPENJDK_BUILD_OS, etc.
+
+
+# Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
+# accordingly. Must be done after setting up build and target system, but before
+# doing anything else with these values.
+
+
+    # Setup the legacy variables, for controlling the old makefiles.
+    #
 
 
 
@@ -3441,6 +3496,8 @@
 
 
 
+# Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
+# Add -mX to various FLAGS variables.
 
 
 
@@ -3519,8 +3576,8 @@
 
 
 # This line needs to be here, verbatim, after all includes.
-# It is replaced with closed functionality when building
-# closed sources.
+# It is replaced with custom functionality when building
+# custom sources.
 
 
 ###############################################################################
@@ -3536,6 +3593,501 @@
 DATE_WHEN_CONFIGURED=`LANG=C date`
 
 
+
+# Now we can determine OpenJDK build and target platforms. This is required to
+# have early on.
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if test "${ac_cv_build+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if test "${ac_cv_host+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
+$as_echo_n "checking target system type... " >&6; }
+if test "${ac_cv_target+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$target_alias" = x; then
+  ac_cv_target=$ac_cv_host
+else
+  ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
+$as_echo "$ac_cv_target" >&6; }
+case $ac_cv_target in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;;
+esac
+target=$ac_cv_target
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_target
+shift
+target_cpu=$1
+target_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+target_os=$*
+IFS=$ac_save_IFS
+case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
+
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
+  test "$program_prefix$program_suffix$program_transform_name" = \
+    NONENONEs,x,x, &&
+  program_prefix=${target_alias}-
+
+# Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
+# is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
+# product you're building. The target of this build is called "host". Since this is confusing to most people, we
+# have not adopted that system, but use "target" as the platform we are building for. In some places though we need
+# to use the configure naming style.
+
+
+
+
+
+    # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
+    # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
+    # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
+    # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.
+    OPENJDK_TARGET_AUTOCONF_NAME="$host"
+    OPENJDK_BUILD_AUTOCONF_NAME="$build"
+
+
+
+    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
+
+  case "$host_os" in
+    *linux*)
+      VAR_OS=linux
+      VAR_OS_API=posix
+      ;;
+    *solaris*)
+      VAR_OS=solaris
+      VAR_OS_API=posix
+      ;;
+    *darwin*)
+      VAR_OS=macosx
+      VAR_OS_API=posix
+      ;;
+    *bsd*)
+      VAR_OS=bsd
+      VAR_OS_API=posix
+      ;;
+    *cygwin*|*windows*)
+      VAR_OS=windows
+      VAR_OS_API=winapi
+      ;;
+    *)
+      as_fn_error $? "unsupported operating system $host_os" "$LINENO" 5
+      ;;
+  esac
+
+
+  # First argument is the cpu name from the trip/quad
+  case "$host_cpu" in
+    x86_64)
+      VAR_CPU=x86_64
+      VAR_CPU_ARCH=x86
+      VAR_CPU_BITS=64
+      VAR_CPU_ENDIAN=little
+      ;;
+    i?86)
+      VAR_CPU=x86
+      VAR_CPU_ARCH=x86
+      VAR_CPU_BITS=32
+      VAR_CPU_ENDIAN=little
+      ;;
+    arm*)
+      VAR_CPU=arm
+      VAR_CPU_ARCH=arm
+      VAR_CPU_BITS=32
+      VAR_CPU_ENDIAN=little
+      ;;
+    powerpc)
+      VAR_CPU=ppc
+      VAR_CPU_ARCH=ppc
+      VAR_CPU_BITS=32
+      VAR_CPU_ENDIAN=big
+       ;;
+    powerpc64)
+      VAR_CPU=ppc64
+      VAR_CPU_ARCH=ppc
+      VAR_CPU_BITS=64
+      VAR_CPU_ENDIAN=big
+       ;;
+    sparc)
+      VAR_CPU=sparc
+      VAR_CPU_ARCH=sparc
+      VAR_CPU_BITS=32
+      VAR_CPU_ENDIAN=big
+       ;;
+    sparcv9)
+      VAR_CPU=sparcv9
+      VAR_CPU_ARCH=sparc
+      VAR_CPU_BITS=64
+      VAR_CPU_ENDIAN=big
+       ;;
+    *)
+      as_fn_error $? "unsupported cpu $host_cpu" "$LINENO" 5
+      ;;
+  esac
+
+    # ... and setup our own variables. (Do this explicitely to facilitate searching)
+    OPENJDK_TARGET_OS="$VAR_OS"
+    OPENJDK_TARGET_OS_API="$VAR_OS_API"
+    OPENJDK_TARGET_CPU="$VAR_CPU"
+    OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
+    OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
+    OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
+
+
+
+
+
+
+
+    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
+
+  case "$build_os" in
+    *linux*)
+      VAR_OS=linux
+      VAR_OS_API=posix
+      ;;
+    *solaris*)
+      VAR_OS=solaris
+      VAR_OS_API=posix
+      ;;
+    *darwin*)
+      VAR_OS=macosx
+      VAR_OS_API=posix
+      ;;
+    *bsd*)
+      VAR_OS=bsd
+      VAR_OS_API=posix
+      ;;
+    *cygwin*|*windows*)
+      VAR_OS=windows
+      VAR_OS_API=winapi
+      ;;
+    *)
+      as_fn_error $? "unsupported operating system $build_os" "$LINENO" 5
+      ;;
+  esac
+
+
+  # First argument is the cpu name from the trip/quad
+  case "$build_cpu" in
+    x86_64)
+      VAR_CPU=x86_64
+      VAR_CPU_ARCH=x86
+      VAR_CPU_BITS=64
+      VAR_CPU_ENDIAN=little
+      ;;
+    i?86)
+      VAR_CPU=x86
+      VAR_CPU_ARCH=x86
+      VAR_CPU_BITS=32
+      VAR_CPU_ENDIAN=little
+      ;;
+    arm*)
+      VAR_CPU=arm
+      VAR_CPU_ARCH=arm
+      VAR_CPU_BITS=32
+      VAR_CPU_ENDIAN=little
+      ;;
+    powerpc)
+      VAR_CPU=ppc
+      VAR_CPU_ARCH=ppc
+      VAR_CPU_BITS=32
+      VAR_CPU_ENDIAN=big
+       ;;
+    powerpc64)
+      VAR_CPU=ppc64
+      VAR_CPU_ARCH=ppc
+      VAR_CPU_BITS=64
+      VAR_CPU_ENDIAN=big
+       ;;
+    sparc)
+      VAR_CPU=sparc
+      VAR_CPU_ARCH=sparc
+      VAR_CPU_BITS=32
+      VAR_CPU_ENDIAN=big
+       ;;
+    sparcv9)
+      VAR_CPU=sparcv9
+      VAR_CPU_ARCH=sparc
+      VAR_CPU_BITS=64
+      VAR_CPU_ENDIAN=big
+       ;;
+    *)
+      as_fn_error $? "unsupported cpu $build_cpu" "$LINENO" 5
+      ;;
+  esac
+
+    # ..and setup our own variables. (Do this explicitely to facilitate searching)
+    OPENJDK_BUILD_OS="$VAR_OS"
+    OPENJDK_BUILD_OS_API="$VAR_OS_API"
+    OPENJDK_BUILD_CPU="$VAR_CPU"
+    OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
+    OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
+    OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
+
+
+
+
+
+
+
+
+
+# Check whether --with-target-bits was given.
+if test "${with_target_bits+set}" = set; then :
+  withval=$with_target_bits;
+fi
+
+
+  # We have three types of compiles:
+  # native  == normal compilation, target system == build system
+  # cross   == traditional cross compilation, target system != build system; special toolchain needed
+  # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
+  #
+  if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
+    # We're doing a proper cross-compilation
+    COMPILE_TYPE="cross"
+  else
+    COMPILE_TYPE="native"
+  fi
+
+  if test "x$with_target_bits" != x; then
+    if test "x$COMPILE_TYPE" = "xcross"; then
+      as_fn_error $? "It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either." "$LINENO" 5
+    fi
+
+    if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+      # A reduced build is requested
+      COMPILE_TYPE="reduced"
+      OPENJDK_TARGET_CPU_BITS=32
+      if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
+        OPENJDK_TARGET_CPU=x86
+      elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
+        OPENJDK_TARGET_CPU=sparc
+      else
+        as_fn_error $? "Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9" "$LINENO" 5
+      fi
+    elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      as_fn_error $? "It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead." "$LINENO" 5
+    elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: --with-target-bits are set to build platform address size; argument has no meaning" >&5
+$as_echo "$as_me: --with-target-bits are set to build platform address size; argument has no meaning" >&6;}
+    else
+      as_fn_error $? "--with-target-bits can only be 32 or 64, you specified $with_target_bits!" "$LINENO" 5
+    fi
+  fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compilation type" >&5
+$as_echo_n "checking for compilation type... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $COMPILE_TYPE" >&5
+$as_echo "$COMPILE_TYPE" >&6; }
+
+
+    if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
+       REQUIRED_OS_NAME=SunOS
+       REQUIRED_OS_VERSION=5.10
+    fi
+    if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
+       REQUIRED_OS_NAME=Linux
+       REQUIRED_OS_VERSION=2.6
+    fi
+    if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+        REQUIRED_OS_NAME=Windows
+        if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
+            REQUIRED_OS_VERSION=5.2
+        else
+            REQUIRED_OS_VERSION=5.1
+        fi
+    fi
+    if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
+        REQUIRED_OS_NAME=Darwin
+        REQUIRED_OS_VERSION=11.2
+    fi
+
+
+
+
+
+    # Also store the legacy naming of the cpu.
+    # Ie i586 and amd64 instead of x86 and x86_64
+    OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then
+      OPENJDK_TARGET_CPU_LEGACY="i586"
+    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+      # On all platforms except MacOSX replace x86_64 with amd64.
+      OPENJDK_TARGET_CPU_LEGACY="amd64"
+    fi
+
+
+    # And the second legacy naming of the cpu.
+    # Ie i386 and amd64 instead of x86 and x86_64.
+    OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then
+      OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
+    elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+      OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
+    fi
+
+
+    # This is the name of the cpu (but using i386 and amd64 instead of
+    # x86 and x86_64, respectively), preceeded by a /, to be used when
+    # locating libraries. On macosx, it's empty, though.
+    OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
+    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+        OPENJDK_TARGET_CPU_LIBDIR=""
+    fi
+
+
+    # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
+    # /amd64 or /sparcv9. This string is appended to some library paths, like this:
+    # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
+    OPENJDK_TARGET_CPU_ISADIR=""
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+      if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+          OPENJDK_TARGET_CPU_ISADIR="/amd64"
+      elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
+          OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
+      fi
+    fi
+
+
+    # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
+    OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
+      # On linux only, we replace x86 with i386.
+      OPENJDK_TARGET_CPU_OSARCH="i386"
+    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+      # On all platforms except macosx, we replace x86_64 with amd64.
+      OPENJDK_TARGET_CPU_OSARCH="amd64"
+    fi
+
+
+    OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then
+      OPENJDK_TARGET_CPU_JLI="i386"
+    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+      # On all platforms except macosx, we replace x86_64 with amd64.
+      OPENJDK_TARGET_CPU_JLI="amd64"
+    fi
+    # Now setup the -D flags for building libjli.
+    OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+      if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
+        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
+      elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
+        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
+      fi
+    fi
+
+
+    # Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
+    if test "x$OPENJDK_TARGET_OS_API" = xposix; then
+        OPENJDK_TARGET_OS_API_DIR="solaris"
+    fi
+    if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
+        OPENJDK_TARGET_OS_API_DIR="windows"
+    fi
+
+
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+        A_LP64="LP64:="
+        ADD_LP64="-D_LP64=1"
+    fi
+    LP64=$A_LP64
+
+
+    if test "x$COMPILE_TYPE" = "xcross"; then
+      # FIXME: ... or should this include reduced builds..?
+      DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
+    else
+      DEFINE_CROSS_COMPILE_ARCH=""
+    fi
+
+
+
+
+# Continue setting up basic stuff.
+
 # Locate the directory of this script.
 SCRIPT="$0"
 
@@ -3622,7 +4174,6 @@
 
 AUTOCONF_DIR=`dirname $0`
 
-
 # Where is the source? It is located two levels above the configure script.
 CURDIR="$PWD"
 cd "$AUTOCONF_DIR/../.."
@@ -3642,7 +4193,11 @@
     HAS_SPACE=`echo "$SRC_ROOT" | grep " "`
     if test "x$HAS_SPACE" != x; then
         if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
             SRC_ROOT=`$CYGPATH -s -m -a "$SRC_ROOT"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            SRC_ROOT=`$ECHO "$SRC_ROOT" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
             SRC_ROOT=`$CYGPATH -u "$SRC_ROOT"`
         else
             as_fn_error $? "You cannot have spaces in the path to the source root! \"$SRC_ROOT\"" "$LINENO" 5
@@ -3655,7 +4210,11 @@
     HAS_SPACE=`echo "$CURDIR" | grep " "`
     if test "x$HAS_SPACE" != x; then
         if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
             CURDIR=`$CYGPATH -s -m -a "$CURDIR"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            CURDIR=`$ECHO "$CURDIR" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
             CURDIR=`$CYGPATH -u "$CURDIR"`
         else
             as_fn_error $? "You cannot have spaces in the path to the current directory! \"$CURDIR\"" "$LINENO" 5
@@ -3663,6 +4222,101 @@
     fi
 
 
+if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
+    # Add extra search paths on solaris for utilities like ar and as etc...
+    PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin"
+fi
+
+# For cygwin we need cygpath first, since it is used everywhere.
+# Extract the first word of "cygpath", so it can be a program name with args.
+set dummy cygpath; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CYGPATH+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CYGPATH in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CYGPATH="$CYGPATH" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CYGPATH="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CYGPATH=$ac_cv_path_CYGPATH
+if test -n "$CYGPATH"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGPATH" >&5
+$as_echo "$CYGPATH" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+PATH_SEP=":"
+if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+    if test "x$CYGPATH" = x; then
+        as_fn_error $? "Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path" "$LINENO" 5
+    fi
+    PATH_SEP=";"
+fi
+
+
+# You can force the sys-root if the sys-root encoded into the cross compiler tools
+# is not correct.
+
+# Check whether --with-sys-root was given.
+if test "${with_sys_root+set}" = set; then :
+  withval=$with_sys_root;
+fi
+
+
+if test "x$with_sys_root" != x; then
+  SYS_ROOT=$with_sys_root
+else
+  SYS_ROOT=/
+fi
+
+
+
+# Check whether --with-tools-dir was given.
+if test "${with_tools_dir+set}" = set; then :
+  withval=$with_tools_dir; TOOLS_DIR=$with_tools_dir
+fi
+
+
+
+# Check whether --with-devkit was given.
+if test "${with_devkit+set}" = set; then :
+  withval=$with_devkit;
+    if test "x$with_sys_root" != x; then
+      as_fn_error $? "Cannot specify both --with-devkit and --with-sys-root at the same time" "$LINENO" 5
+    fi
+    if test "x$with_tools_dir" != x; then
+      as_fn_error $? "Cannot specify both --with-devkit and --with-tools-dir at the same time" "$LINENO" 5
+    fi
+    TOOLS_DIR=$with_devkit/bin
+    SYS_ROOT=$with_devkit/$host_alias/libc
+
+fi
+
+
+
 
 # Setup default logging of stdout and stderr to build.log in the output root.
 BUILD_LOG='$(OUTPUT_ROOT)/build.log'
@@ -3721,6 +4375,1958 @@
 
 # Setup simple tools, that do not need have cross compilation support.
 # Without these, we can't properly run the rest of the configure script.
+
+# Start with tools that do not need have cross compilation support
+# and can be expected to be found in the default PATH. These tools are
+# used by configure. Nor are these tools expected to be found in the
+# devkit from the builddeps server either, since they are
+# needed to download the devkit.
+
+# First are all the simple required tools.
+
+    for ac_prog in basename
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_BASENAME+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $BASENAME in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BASENAME="$BASENAME" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_BASENAME="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+BASENAME=$ac_cv_path_BASENAME
+if test -n "$BASENAME"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BASENAME" >&5
+$as_echo "$BASENAME" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$BASENAME" && break
+done
+
+
+    if test "x$BASENAME" = x; then
+        if test "xbasename" = x; then
+          PROG_NAME=basename
+        else
+          PROG_NAME=basename
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in cat
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CAT+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CAT in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CAT="$CAT" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CAT="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CAT=$ac_cv_path_CAT
+if test -n "$CAT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CAT" >&5
+$as_echo "$CAT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CAT" && break
+done
+
+
+    if test "x$CAT" = x; then
+        if test "xcat" = x; then
+          PROG_NAME=cat
+        else
+          PROG_NAME=cat
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in chmod
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CHMOD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CHMOD in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CHMOD="$CHMOD" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CHMOD="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CHMOD=$ac_cv_path_CHMOD
+if test -n "$CHMOD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHMOD" >&5
+$as_echo "$CHMOD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CHMOD" && break
+done
+
+
+    if test "x$CHMOD" = x; then
+        if test "xchmod" = x; then
+          PROG_NAME=chmod
+        else
+          PROG_NAME=chmod
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in cmp
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CMP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CMP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CMP="$CMP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CMP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CMP=$ac_cv_path_CMP
+if test -n "$CMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CMP" >&5
+$as_echo "$CMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CMP" && break
+done
+
+
+    if test "x$CMP" = x; then
+        if test "xcmp" = x; then
+          PROG_NAME=cmp
+        else
+          PROG_NAME=cmp
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in cp
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CP="$CP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CP=$ac_cv_path_CP
+if test -n "$CP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CP" >&5
+$as_echo "$CP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CP" && break
+done
+
+
+    if test "x$CP" = x; then
+        if test "xcp" = x; then
+          PROG_NAME=cp
+        else
+          PROG_NAME=cp
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in cpio
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CPIO+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CPIO in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CPIO="$CPIO" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CPIO="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CPIO=$ac_cv_path_CPIO
+if test -n "$CPIO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPIO" >&5
+$as_echo "$CPIO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CPIO" && break
+done
+
+
+    if test "x$CPIO" = x; then
+        if test "xcpio" = x; then
+          PROG_NAME=cpio
+        else
+          PROG_NAME=cpio
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in cut
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CUT+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CUT in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CUT="$CUT" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CUT="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CUT=$ac_cv_path_CUT
+if test -n "$CUT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUT" >&5
+$as_echo "$CUT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CUT" && break
+done
+
+
+    if test "x$CUT" = x; then
+        if test "xcut" = x; then
+          PROG_NAME=cut
+        else
+          PROG_NAME=cut
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in date
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_DATE+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $DATE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_DATE="$DATE" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_DATE="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+DATE=$ac_cv_path_DATE
+if test -n "$DATE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DATE" >&5
+$as_echo "$DATE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$DATE" && break
+done
+
+
+    if test "x$DATE" = x; then
+        if test "xdate" = x; then
+          PROG_NAME=date
+        else
+          PROG_NAME=date
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in df
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_DF+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $DF in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_DF="$DF" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_DF="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+DF=$ac_cv_path_DF
+if test -n "$DF"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DF" >&5
+$as_echo "$DF" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$DF" && break
+done
+
+
+    if test "x$DF" = x; then
+        if test "xdf" = x; then
+          PROG_NAME=df
+        else
+          PROG_NAME=df
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in gdiff diff
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_DIFF+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $DIFF in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_DIFF="$DIFF" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_DIFF="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+DIFF=$ac_cv_path_DIFF
+if test -n "$DIFF"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DIFF" >&5
+$as_echo "$DIFF" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$DIFF" && break
+done
+
+
+    if test "x$DIFF" = x; then
+        if test "xgdiff diff" = x; then
+          PROG_NAME=diff
+        else
+          PROG_NAME=gdiff diff
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in echo
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_ECHO+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ECHO in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ECHO="$ECHO" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_ECHO="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ECHO=$ac_cv_path_ECHO
+if test -n "$ECHO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ECHO" >&5
+$as_echo "$ECHO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ECHO" && break
+done
+
+
+    if test "x$ECHO" = x; then
+        if test "xecho" = x; then
+          PROG_NAME=echo
+        else
+          PROG_NAME=echo
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in expr
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_EXPR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $EXPR in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_EXPR="$EXPR" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_EXPR="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+EXPR=$ac_cv_path_EXPR
+if test -n "$EXPR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $EXPR" >&5
+$as_echo "$EXPR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$EXPR" && break
+done
+
+
+    if test "x$EXPR" = x; then
+        if test "xexpr" = x; then
+          PROG_NAME=expr
+        else
+          PROG_NAME=expr
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in file
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_FILE+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FILE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FILE="$FILE" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_FILE="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FILE=$ac_cv_path_FILE
+if test -n "$FILE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FILE" >&5
+$as_echo "$FILE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$FILE" && break
+done
+
+
+    if test "x$FILE" = x; then
+        if test "xfile" = x; then
+          PROG_NAME=file
+        else
+          PROG_NAME=file
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in find
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_FIND+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FIND in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FIND="$FIND" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_FIND="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FIND=$ac_cv_path_FIND
+if test -n "$FIND"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FIND" >&5
+$as_echo "$FIND" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$FIND" && break
+done
+
+
+    if test "x$FIND" = x; then
+        if test "xfind" = x; then
+          PROG_NAME=find
+        else
+          PROG_NAME=find
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in head
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_HEAD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $HEAD in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_HEAD="$HEAD" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_HEAD="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+HEAD=$ac_cv_path_HEAD
+if test -n "$HEAD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HEAD" >&5
+$as_echo "$HEAD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$HEAD" && break
+done
+
+
+    if test "x$HEAD" = x; then
+        if test "xhead" = x; then
+          PROG_NAME=head
+        else
+          PROG_NAME=head
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in ln
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_LN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $LN in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_LN="$LN" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_LN="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+LN=$ac_cv_path_LN
+if test -n "$LN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LN" >&5
+$as_echo "$LN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$LN" && break
+done
+
+
+    if test "x$LN" = x; then
+        if test "xln" = x; then
+          PROG_NAME=ln
+        else
+          PROG_NAME=ln
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in ls
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_LS+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $LS in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_LS="$LS" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_LS="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+LS=$ac_cv_path_LS
+if test -n "$LS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LS" >&5
+$as_echo "$LS" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$LS" && break
+done
+
+
+    if test "x$LS" = x; then
+        if test "xls" = x; then
+          PROG_NAME=ls
+        else
+          PROG_NAME=ls
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in mkdir
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_MKDIR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MKDIR in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_MKDIR="$MKDIR" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_MKDIR="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+MKDIR=$ac_cv_path_MKDIR
+if test -n "$MKDIR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR" >&5
+$as_echo "$MKDIR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$MKDIR" && break
+done
+
+
+    if test "x$MKDIR" = x; then
+        if test "xmkdir" = x; then
+          PROG_NAME=mkdir
+        else
+          PROG_NAME=mkdir
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in mv
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_MV+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MV in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_MV="$MV" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_MV="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+MV=$ac_cv_path_MV
+if test -n "$MV"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MV" >&5
+$as_echo "$MV" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$MV" && break
+done
+
+
+    if test "x$MV" = x; then
+        if test "xmv" = x; then
+          PROG_NAME=mv
+        else
+          PROG_NAME=mv
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in printf
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_PRINTF+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PRINTF in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PRINTF="$PRINTF" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PRINTF="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PRINTF=$ac_cv_path_PRINTF
+if test -n "$PRINTF"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PRINTF" >&5
+$as_echo "$PRINTF" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$PRINTF" && break
+done
+
+
+    if test "x$PRINTF" = x; then
+        if test "xprintf" = x; then
+          PROG_NAME=printf
+        else
+          PROG_NAME=printf
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in sh
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_SH+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $SH in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_SH="$SH" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_SH="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+SH=$ac_cv_path_SH
+if test -n "$SH"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SH" >&5
+$as_echo "$SH" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$SH" && break
+done
+
+
+    if test "x$SH" = x; then
+        if test "xsh" = x; then
+          PROG_NAME=sh
+        else
+          PROG_NAME=sh
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in sort
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_SORT+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $SORT in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_SORT="$SORT" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_SORT="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+SORT=$ac_cv_path_SORT
+if test -n "$SORT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5
+$as_echo "$SORT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$SORT" && break
+done
+
+
+    if test "x$SORT" = x; then
+        if test "xsort" = x; then
+          PROG_NAME=sort
+        else
+          PROG_NAME=sort
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in tail
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_TAIL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $TAIL in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_TAIL="$TAIL" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_TAIL="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+TAIL=$ac_cv_path_TAIL
+if test -n "$TAIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAIL" >&5
+$as_echo "$TAIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$TAIL" && break
+done
+
+
+    if test "x$TAIL" = x; then
+        if test "xtail" = x; then
+          PROG_NAME=tail
+        else
+          PROG_NAME=tail
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in tar
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_TAR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $TAR in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_TAR="$TAR" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_TAR="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+TAR=$ac_cv_path_TAR
+if test -n "$TAR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR" >&5
+$as_echo "$TAR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$TAR" && break
+done
+
+
+    if test "x$TAR" = x; then
+        if test "xtar" = x; then
+          PROG_NAME=tar
+        else
+          PROG_NAME=tar
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in tee
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_TEE+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $TEE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_TEE="$TEE" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_TEE="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+TEE=$ac_cv_path_TEE
+if test -n "$TEE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TEE" >&5
+$as_echo "$TEE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$TEE" && break
+done
+
+
+    if test "x$TEE" = x; then
+        if test "xtee" = x; then
+          PROG_NAME=tee
+        else
+          PROG_NAME=tee
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in touch
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_TOUCH+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $TOUCH in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_TOUCH="$TOUCH" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_TOUCH="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+TOUCH=$ac_cv_path_TOUCH
+if test -n "$TOUCH"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TOUCH" >&5
+$as_echo "$TOUCH" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$TOUCH" && break
+done
+
+
+    if test "x$TOUCH" = x; then
+        if test "xtouch" = x; then
+          PROG_NAME=touch
+        else
+          PROG_NAME=touch
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in tr
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_TR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $TR in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_TR="$TR" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_TR="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+TR=$ac_cv_path_TR
+if test -n "$TR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TR" >&5
+$as_echo "$TR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$TR" && break
+done
+
+
+    if test "x$TR" = x; then
+        if test "xtr" = x; then
+          PROG_NAME=tr
+        else
+          PROG_NAME=tr
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in uniq
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_UNIQ+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $UNIQ in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_UNIQ="$UNIQ" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_UNIQ="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+UNIQ=$ac_cv_path_UNIQ
+if test -n "$UNIQ"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNIQ" >&5
+$as_echo "$UNIQ" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$UNIQ" && break
+done
+
+
+    if test "x$UNIQ" = x; then
+        if test "xuniq" = x; then
+          PROG_NAME=uniq
+        else
+          PROG_NAME=uniq
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in unzip
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_UNZIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $UNZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_UNZIP="$UNZIP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_UNZIP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+UNZIP=$ac_cv_path_UNZIP
+if test -n "$UNZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNZIP" >&5
+$as_echo "$UNZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$UNZIP" && break
+done
+
+
+    if test "x$UNZIP" = x; then
+        if test "xunzip" = x; then
+          PROG_NAME=unzip
+        else
+          PROG_NAME=unzip
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in wc
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_WC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $WC in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_WC="$WC" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_WC="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+WC=$ac_cv_path_WC
+if test -n "$WC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WC" >&5
+$as_echo "$WC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$WC" && break
+done
+
+
+    if test "x$WC" = x; then
+        if test "xwc" = x; then
+          PROG_NAME=wc
+        else
+          PROG_NAME=wc
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in xargs
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_XARGS+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $XARGS in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_XARGS="$XARGS" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_XARGS="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+XARGS=$ac_cv_path_XARGS
+if test -n "$XARGS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XARGS" >&5
+$as_echo "$XARGS" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$XARGS" && break
+done
+
+
+    if test "x$XARGS" = x; then
+        if test "xxargs" = x; then
+          PROG_NAME=xargs
+        else
+          PROG_NAME=xargs
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+    for ac_prog in zip
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_ZIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ZIP="$ZIP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_ZIP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ZIP=$ac_cv_path_ZIP
+if test -n "$ZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
+$as_echo "$ZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ZIP" && break
+done
+
+
+    if test "x$ZIP" = x; then
+        if test "xzip" = x; then
+          PROG_NAME=zip
+        else
+          PROG_NAME=zip
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+# Then required tools that require some special treatment.
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+
+    if test "x$AWK" = x; then
+        if test "x" = x; then
+          PROG_NAME=awk
+        else
+          PROG_NAME=
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
 $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
 if test "${ac_cv_path_GREP+set}" = set; then :
@@ -3785,455 +6391,16 @@
 
 
 
-# Start with tools that do not need have cross compilation support
-# and can be expected to be found in the default PATH. These tools are
-# used by configure. Nor are these tools expected to be found in the
-# devkit from the builddeps server either, since they are
-# needed to download the devkit.
-for ac_prog in gawk mawk nawk awk
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_AWK+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$AWK"; then
-  ac_cv_prog_AWK="$AWK" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_AWK="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-AWK=$ac_cv_prog_AWK
-if test -n "$AWK"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
-$as_echo "$AWK" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$AWK" && break
-done
-
-
-    # Test that variable AWK is not empty.
-    if test "" = "$AWK"; then as_fn_error $? "Could not find awk !" "$LINENO" 5 ; fi
-
-# Extract the first word of "cat", so it can be a program name with args.
-set dummy cat; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CAT+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $CAT in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_CAT="$CAT" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_CAT="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-CAT=$ac_cv_path_CAT
-if test -n "$CAT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CAT" >&5
-$as_echo "$CAT" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable CAT is not empty.
-    if test "" = "$CAT"; then as_fn_error $? "Could not find cat !" "$LINENO" 5 ; fi
-
-# Extract the first word of "chmod", so it can be a program name with args.
-set dummy chmod; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CHMOD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $CHMOD in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_CHMOD="$CHMOD" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_CHMOD="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-CHMOD=$ac_cv_path_CHMOD
-if test -n "$CHMOD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHMOD" >&5
-$as_echo "$CHMOD" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable CHMOD is not empty.
-    if test "" = "$CHMOD"; then as_fn_error $? "Could not find chmod !" "$LINENO" 5 ; fi
-
-# Extract the first word of "cp", so it can be a program name with args.
-set dummy cp; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $CP in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_CP="$CP" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_CP="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-CP=$ac_cv_path_CP
-if test -n "$CP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CP" >&5
-$as_echo "$CP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable CP is not empty.
-    if test "" = "$CP"; then as_fn_error $? "Could not find cp !" "$LINENO" 5 ; fi
-
-# Extract the first word of "cpio", so it can be a program name with args.
-set dummy cpio; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CPIO+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $CPIO in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_CPIO="$CPIO" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_CPIO="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-CPIO=$ac_cv_path_CPIO
-if test -n "$CPIO"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPIO" >&5
-$as_echo "$CPIO" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable CPIO is not empty.
-    if test "" = "$CPIO"; then as_fn_error $? "Could not find cpio !" "$LINENO" 5 ; fi
-
-# Extract the first word of "cut", so it can be a program name with args.
-set dummy cut; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CUT+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $CUT in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_CUT="$CUT" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_CUT="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-CUT=$ac_cv_path_CUT
-if test -n "$CUT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUT" >&5
-$as_echo "$CUT" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable CUT is not empty.
-    if test "" = "$CUT"; then as_fn_error $? "Could not find cut !" "$LINENO" 5 ; fi
-
-# Extract the first word of "date", so it can be a program name with args.
-set dummy date; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_DATE+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $DATE in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_DATE="$DATE" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_DATE="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-DATE=$ac_cv_path_DATE
-if test -n "$DATE"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DATE" >&5
-$as_echo "$DATE" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable DATE is not empty.
-    if test "" = "$DATE"; then as_fn_error $? "Could not find date !" "$LINENO" 5 ; fi
-
-# Extract the first word of "df", so it can be a program name with args.
-set dummy df; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_DF+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $DF in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_DF="$DF" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_DF="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-DF=$ac_cv_path_DF
-if test -n "$DF"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DF" >&5
-$as_echo "$DF" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable DF is not empty.
-    if test "" = "$DF"; then as_fn_error $? "Could not find df !" "$LINENO" 5 ; fi
-
-# Extract the first word of "diff", so it can be a program name with args.
-set dummy diff; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_DIFF+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $DIFF in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_DIFF="$DIFF" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_DIFF="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-DIFF=$ac_cv_path_DIFF
-if test -n "$DIFF"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DIFF" >&5
-$as_echo "$DIFF" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable DIFF is not empty.
-    if test "" = "$DIFF"; then as_fn_error $? "Could not find diff !" "$LINENO" 5 ; fi
-
-# Warning echo is really, really unportable!!!!! Different
-# behaviour in bash and dash and in a lot of other shells!
-# Use printf for serious work!
-# Extract the first word of "echo", so it can be a program name with args.
-set dummy echo; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_ECHO+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ECHO in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ECHO="$ECHO" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_ECHO="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-ECHO=$ac_cv_path_ECHO
-if test -n "$ECHO"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ECHO" >&5
-$as_echo "$ECHO" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable ECHO is not empty.
-    if test "" = "$ECHO"; then as_fn_error $? "Could not find echo !" "$LINENO" 5 ; fi
+    if test "x$GREP" = x; then
+        if test "x" = x; then
+          PROG_NAME=grep
+        else
+          PROG_NAME=
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
 $as_echo_n "checking for egrep... " >&6; }
@@ -4303,8 +6470,16 @@
 
 
 
-    # Test that variable EGREP is not empty.
-    if test "" = "$EGREP"; then as_fn_error $? "Could not find egrep !" "$LINENO" 5 ; fi
+    if test "x$EGREP" = x; then
+        if test "x" = x; then
+          PROG_NAME=egrep
+        else
+          PROG_NAME=
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
 $as_echo_n "checking for fgrep... " >&6; }
@@ -4374,597 +6549,17 @@
 
 
 
-    # Test that variable FGREP is not empty.
-    if test "" = "$FGREP"; then as_fn_error $? "Could not find fgrep !" "$LINENO" 5 ; fi
-
-
-# Extract the first word of "find", so it can be a program name with args.
-set dummy find; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_FIND+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $FIND in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_FIND="$FIND" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_FIND="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-FIND=$ac_cv_path_FIND
-if test -n "$FIND"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FIND" >&5
-$as_echo "$FIND" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable FIND is not empty.
-    if test "" = "$FIND"; then as_fn_error $? "Could not find find !" "$LINENO" 5 ; fi
-
-
-    # Test if find supports -delete
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if find supports -delete" >&5
-$as_echo_n "checking if find supports -delete... " >&6; }
-    FIND_DELETE="-delete"
-
-    DELETEDIR=`mktemp -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?)
-
-    echo Hejsan > $DELETEDIR/TestIfFindSupportsDelete
-
-    TEST_DELETE=`$FIND "$DELETEDIR" -name TestIfFindSupportsDelete $FIND_DELETE 2>&1`
-    if test -f $DELETEDIR/TestIfFindSupportsDelete; then
-        # No, it does not.
-        rm $DELETEDIR/TestIfFindSupportsDelete
-        FIND_DELETE="-exec rm \{\} \+"
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-    else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-    fi
-    rmdir $DELETEDIR
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if test "${ac_cv_path_GREP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in grep ggrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-
-    # Test that variable GREP is not empty.
-    if test "" = "$GREP"; then as_fn_error $? "Could not find grep !" "$LINENO" 5 ; fi
-
-# Extract the first word of "head", so it can be a program name with args.
-set dummy head; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_HEAD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $HEAD in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_HEAD="$HEAD" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_HEAD="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-HEAD=$ac_cv_path_HEAD
-if test -n "$HEAD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HEAD" >&5
-$as_echo "$HEAD" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable HEAD is not empty.
-    if test "" = "$HEAD"; then as_fn_error $? "Could not find head !" "$LINENO" 5 ; fi
-
-# Extract the first word of "ln", so it can be a program name with args.
-set dummy ln; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_LN+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $LN in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_LN="$LN" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_LN="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-LN=$ac_cv_path_LN
-if test -n "$LN"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LN" >&5
-$as_echo "$LN" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable LN is not empty.
-    if test "" = "$LN"; then as_fn_error $? "Could not find ln !" "$LINENO" 5 ; fi
-
-# Extract the first word of "ls", so it can be a program name with args.
-set dummy ls; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_LS+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $LS in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_LS="$LS" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_LS="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-LS=$ac_cv_path_LS
-if test -n "$LS"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LS" >&5
-$as_echo "$LS" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable LS is not empty.
-    if test "" = "$LS"; then as_fn_error $? "Could not find ls !" "$LINENO" 5 ; fi
-
-for ac_prog in gmake make
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_MAKE+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $MAKE in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_MAKE="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-MAKE=$ac_cv_path_MAKE
-if test -n "$MAKE"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKE" >&5
-$as_echo "$MAKE" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$MAKE" && break
-done
-
-
-    # Test that variable MAKE is not empty.
-    if test "" = "$MAKE"; then as_fn_error $? "Could not find make !" "$LINENO" 5 ; fi
-
-MAKE_VERSION=`$MAKE --version | head -n 1 | grep '3.8[12346789]'`
-if test "x$MAKE_VERSION" = x; then
-    as_fn_error $? "You must use GNU make 3.81 or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure." "$LINENO" 5
-fi
-# Extract the first word of "mkdir", so it can be a program name with args.
-set dummy mkdir; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_MKDIR+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $MKDIR in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_MKDIR="$MKDIR" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_MKDIR="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-MKDIR=$ac_cv_path_MKDIR
-if test -n "$MKDIR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR" >&5
-$as_echo "$MKDIR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable MKDIR is not empty.
-    if test "" = "$MKDIR"; then as_fn_error $? "Could not find mkdir !" "$LINENO" 5 ; fi
-
-# Extract the first word of "mv", so it can be a program name with args.
-set dummy mv; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_MV+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $MV in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_MV="$MV" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_MV="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-MV=$ac_cv_path_MV
-if test -n "$MV"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MV" >&5
-$as_echo "$MV" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable MV is not empty.
-    if test "" = "$MV"; then as_fn_error $? "Could not find mv !" "$LINENO" 5 ; fi
-
-for ac_prog in nawk gawk awk
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_NAWK+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $NAWK in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_NAWK="$NAWK" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_NAWK="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-NAWK=$ac_cv_path_NAWK
-if test -n "$NAWK"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NAWK" >&5
-$as_echo "$NAWK" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$NAWK" && break
-done
-
-
-    # Test that variable NAWK is not empty.
-    if test "" = "$NAWK"; then as_fn_error $? "Could not find nawk !" "$LINENO" 5 ; fi
-
-# Extract the first word of "printf", so it can be a program name with args.
-set dummy printf; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PRINTF+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $PRINTF in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_PRINTF="$PRINTF" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_PRINTF="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-PRINTF=$ac_cv_path_PRINTF
-if test -n "$PRINTF"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PRINTF" >&5
-$as_echo "$PRINTF" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable PRINTF is not empty.
-    if test "" = "$PRINTF"; then as_fn_error $? "Could not find printf !" "$LINENO" 5 ; fi
-
-# Extract the first word of "pwd", so it can be a program name with args.
-set dummy pwd; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_THEPWDCMD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $THEPWDCMD in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_THEPWDCMD="$THEPWDCMD" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_THEPWDCMD="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-THEPWDCMD=$ac_cv_path_THEPWDCMD
-if test -n "$THEPWDCMD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THEPWDCMD" >&5
-$as_echo "$THEPWDCMD" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-# Extract the first word of "rm", so it can be a program name with args.
-set dummy rm; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_RM+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $RM in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_RM="$RM" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_RM="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-RM=$ac_cv_path_RM
-if test -n "$RM"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RM" >&5
-$as_echo "$RM" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable RM is not empty.
-    if test "" = "$RM"; then as_fn_error $? "Could not find rm !" "$LINENO" 5 ; fi
-
-RM="$RM -f"
+    if test "x$FGREP" = x; then
+        if test "x" = x; then
+          PROG_NAME=fgrep
+        else
+          PROG_NAME=
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
 $as_echo_n "checking for a sed that does not truncate output... " >&6; }
 if test "${ac_cv_path_SED+set}" = set; then :
@@ -5035,492 +6630,746 @@
   rm -f conftest.sed
 
 
-    # Test that variable SED is not empty.
-    if test "" = "$SED"; then as_fn_error $? "Could not find sed !" "$LINENO" 5 ; fi
-
-# Extract the first word of "sh", so it can be a program name with args.
-set dummy sh; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_SH+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $SH in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_SH="$SH" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_SH="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-SH=$ac_cv_path_SH
-if test -n "$SH"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SH" >&5
-$as_echo "$SH" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable SH is not empty.
-    if test "" = "$SH"; then as_fn_error $? "Could not find sh !" "$LINENO" 5 ; fi
-
-# Extract the first word of "sort", so it can be a program name with args.
-set dummy sort; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_SORT+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $SORT in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_SORT="$SORT" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_SORT="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-SORT=$ac_cv_path_SORT
-if test -n "$SORT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5
-$as_echo "$SORT" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable SORT is not empty.
-    if test "" = "$SORT"; then as_fn_error $? "Could not find sort !" "$LINENO" 5 ; fi
-
-# Extract the first word of "tar", so it can be a program name with args.
-set dummy tar; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_TAR+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $TAR in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_TAR="$TAR" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_TAR="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-TAR=$ac_cv_path_TAR
-if test -n "$TAR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR" >&5
-$as_echo "$TAR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable TAR is not empty.
-    if test "" = "$TAR"; then as_fn_error $? "Could not find tar !" "$LINENO" 5 ; fi
-
-# Extract the first word of "tail", so it can be a program name with args.
-set dummy tail; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_TAIL+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $TAIL in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_TAIL="$TAIL" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_TAIL="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-TAIL=$ac_cv_path_TAIL
-if test -n "$TAIL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAIL" >&5
-$as_echo "$TAIL" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable TAIL is not empty.
-    if test "" = "$TAIL"; then as_fn_error $? "Could not find tail !" "$LINENO" 5 ; fi
-
-# Extract the first word of "tee", so it can be a program name with args.
-set dummy tee; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_TEE+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $TEE in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_TEE="$TEE" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_TEE="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-TEE=$ac_cv_path_TEE
-if test -n "$TEE"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TEE" >&5
-$as_echo "$TEE" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable TEE is not empty.
-    if test "" = "$TEE"; then as_fn_error $? "Could not find tee !" "$LINENO" 5 ; fi
-
-# Extract the first word of "tr", so it can be a program name with args.
-set dummy tr; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_TR+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $TR in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_TR="$TR" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_TR="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-TR=$ac_cv_path_TR
-if test -n "$TR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TR" >&5
-$as_echo "$TR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable TR is not empty.
-    if test "" = "$TR"; then as_fn_error $? "Could not find tr !" "$LINENO" 5 ; fi
-
-# Extract the first word of "touch", so it can be a program name with args.
-set dummy touch; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_TOUCH+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $TOUCH in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_TOUCH="$TOUCH" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_TOUCH="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-TOUCH=$ac_cv_path_TOUCH
-if test -n "$TOUCH"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TOUCH" >&5
-$as_echo "$TOUCH" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable TOUCH is not empty.
-    if test "" = "$TOUCH"; then as_fn_error $? "Could not find touch !" "$LINENO" 5 ; fi
-
-# Extract the first word of "wc", so it can be a program name with args.
-set dummy wc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_WC+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $WC in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_WC="$WC" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_WC="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-WC=$ac_cv_path_WC
-if test -n "$WC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WC" >&5
-$as_echo "$WC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable WC is not empty.
-    if test "" = "$WC"; then as_fn_error $? "Could not find wc !" "$LINENO" 5 ; fi
-
-# Extract the first word of "xargs", so it can be a program name with args.
-set dummy xargs; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_XARGS+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $XARGS in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_XARGS="$XARGS" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_XARGS="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-XARGS=$ac_cv_path_XARGS
-if test -n "$XARGS"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XARGS" >&5
-$as_echo "$XARGS" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable XARGS is not empty.
-    if test "" = "$XARGS"; then as_fn_error $? "Could not find xargs !" "$LINENO" 5 ; fi
-
-# Extract the first word of "zip", so it can be a program name with args.
-set dummy zip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_ZIP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ZIP in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ZIP="$ZIP" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_ZIP="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-ZIP=$ac_cv_path_ZIP
-if test -n "$ZIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
-$as_echo "$ZIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable ZIP is not empty.
-    if test "" = "$ZIP"; then as_fn_error $? "Could not find zip !" "$LINENO" 5 ; fi
-
-# Extract the first word of "unzip", so it can be a program name with args.
-set dummy unzip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_UNZIP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $UNZIP in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_UNZIP="$UNZIP" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_UNZIP="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-UNZIP=$ac_cv_path_UNZIP
-if test -n "$UNZIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNZIP" >&5
-$as_echo "$UNZIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable UNZIP is not empty.
-    if test "" = "$UNZIP"; then as_fn_error $? "Could not find unzip !" "$LINENO" 5 ; fi
+    if test "x$SED" = x; then
+        if test "x" = x; then
+          PROG_NAME=sed
+        else
+          PROG_NAME=
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+for ac_prog in nawk gawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_NAWK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $NAWK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_NAWK="$NAWK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_NAWK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+NAWK=$ac_cv_path_NAWK
+if test -n "$NAWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NAWK" >&5
+$as_echo "$NAWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$NAWK" && break
+done
+
+
+    if test "x$NAWK" = x; then
+        if test "x" = x; then
+          PROG_NAME=nawk
+        else
+          PROG_NAME=
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+
+  # We need to find a recent version of GNU make. Especially on Solaris, this can be tricky.
+  if test "x$MAKE" != x; then
+    # User has supplied a make, test it.
+    if test ! -f "$MAKE"; then
+      as_fn_error $? "The specified make (by MAKE=$MAKE) is not found." "$LINENO" 5
+    fi
+
+  MAKE_CANDIDATE=""$MAKE""
+  DESCRIPTION="user supplied MAKE="
+  if test "x$MAKE_CANDIDATE" != x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5
+$as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;}
+
+    # Translate "gcc -E" into "`which gcc` -E" ie
+    # extract the full path to the binary and at the
+    # same time maintain any arguments passed to it.
+    # The command MUST exist in the path, or else!
+    tmp="$MAKE_CANDIDATE"
+    car="${tmp%% *}"
+    tmp="$MAKE_CANDIDATE EOL"
+    cdr="${tmp#* }"
+    # On windows we want paths without spaces.
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+
+    # Translate long cygdrive or C:\sdfsf path
+    # into a short mixed mode path that has no
+    # spaces in it.
+    tmp="$car"
+
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+        tmp=`$CYGPATH -u "$car"`
+        tmp=`which "$tmp"`
+        # If file exists with .exe appended, that's the real filename
+        # and cygpath needs that to convert to short style path.
+        if test -f "${tmp}.exe"; then
+           tmp="${tmp}.exe"
+        elif test -f "${tmp}.cmd"; then
+           tmp="${tmp}.cmd"
+        fi
+        # Convert to C:/ mixed style path without spaces.
+         tmp=`$CYGPATH -s -m "$tmp"`
+    fi
+    car="$tmp"
+
+    else
+        # "which" is not portable, but is used here
+        # because we know that the command exists!
+        car=`which $car`
+    fi
+    if test "x$cdr" != xEOL; then
+        MAKE_CANDIDATE="$car ${cdr% *}"
+    else
+        MAKE_CANDIDATE="$car"
+    fi
+
+    MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
+    IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
+    if test "x$IS_GNU_MAKE" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5
+$as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;}
+    else
+      IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'`
+      if test "x$IS_MODERN_MAKE" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5
+$as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;}
+      else
+        FOUND_MAKE=$MAKE_CANDIDATE
+      fi
+    fi
+  fi
+
+    if test "x$FOUND_MAKE" = x; then
+      as_fn_error $? "The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer." "$LINENO" 5
+    fi
+  else
+    # Try our hardest to locate a correct version of GNU make
+    for ac_prog in gmake
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CHECK_GMAKE+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CHECK_GMAKE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CHECK_GMAKE="$CHECK_GMAKE" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CHECK_GMAKE="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CHECK_GMAKE=$ac_cv_path_CHECK_GMAKE
+if test -n "$CHECK_GMAKE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_GMAKE" >&5
+$as_echo "$CHECK_GMAKE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CHECK_GMAKE" && break
+done
+
+
+  MAKE_CANDIDATE=""$CHECK_GMAKE""
+  DESCRIPTION="gmake in PATH"
+  if test "x$MAKE_CANDIDATE" != x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5
+$as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;}
+
+    # Translate "gcc -E" into "`which gcc` -E" ie
+    # extract the full path to the binary and at the
+    # same time maintain any arguments passed to it.
+    # The command MUST exist in the path, or else!
+    tmp="$MAKE_CANDIDATE"
+    car="${tmp%% *}"
+    tmp="$MAKE_CANDIDATE EOL"
+    cdr="${tmp#* }"
+    # On windows we want paths without spaces.
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+
+    # Translate long cygdrive or C:\sdfsf path
+    # into a short mixed mode path that has no
+    # spaces in it.
+    tmp="$car"
+
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+        tmp=`$CYGPATH -u "$car"`
+        tmp=`which "$tmp"`
+        # If file exists with .exe appended, that's the real filename
+        # and cygpath needs that to convert to short style path.
+        if test -f "${tmp}.exe"; then
+           tmp="${tmp}.exe"
+        elif test -f "${tmp}.cmd"; then
+           tmp="${tmp}.cmd"
+        fi
+        # Convert to C:/ mixed style path without spaces.
+         tmp=`$CYGPATH -s -m "$tmp"`
+    fi
+    car="$tmp"
+
+    else
+        # "which" is not portable, but is used here
+        # because we know that the command exists!
+        car=`which $car`
+    fi
+    if test "x$cdr" != xEOL; then
+        MAKE_CANDIDATE="$car ${cdr% *}"
+    else
+        MAKE_CANDIDATE="$car"
+    fi
+
+    MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
+    IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
+    if test "x$IS_GNU_MAKE" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5
+$as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;}
+    else
+      IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'`
+      if test "x$IS_MODERN_MAKE" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5
+$as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;}
+      else
+        FOUND_MAKE=$MAKE_CANDIDATE
+      fi
+    fi
+  fi
+
+
+    if test "x$FOUND_MAKE" = x; then
+      for ac_prog in make
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CHECK_MAKE+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CHECK_MAKE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CHECK_MAKE="$CHECK_MAKE" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CHECK_MAKE="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CHECK_MAKE=$ac_cv_path_CHECK_MAKE
+if test -n "$CHECK_MAKE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_MAKE" >&5
+$as_echo "$CHECK_MAKE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CHECK_MAKE" && break
+done
+
+
+  MAKE_CANDIDATE=""$CHECK_MAKE""
+  DESCRIPTION="make in PATH"
+  if test "x$MAKE_CANDIDATE" != x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5
+$as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;}
+
+    # Translate "gcc -E" into "`which gcc` -E" ie
+    # extract the full path to the binary and at the
+    # same time maintain any arguments passed to it.
+    # The command MUST exist in the path, or else!
+    tmp="$MAKE_CANDIDATE"
+    car="${tmp%% *}"
+    tmp="$MAKE_CANDIDATE EOL"
+    cdr="${tmp#* }"
+    # On windows we want paths without spaces.
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+
+    # Translate long cygdrive or C:\sdfsf path
+    # into a short mixed mode path that has no
+    # spaces in it.
+    tmp="$car"
+
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+        tmp=`$CYGPATH -u "$car"`
+        tmp=`which "$tmp"`
+        # If file exists with .exe appended, that's the real filename
+        # and cygpath needs that to convert to short style path.
+        if test -f "${tmp}.exe"; then
+           tmp="${tmp}.exe"
+        elif test -f "${tmp}.cmd"; then
+           tmp="${tmp}.cmd"
+        fi
+        # Convert to C:/ mixed style path without spaces.
+         tmp=`$CYGPATH -s -m "$tmp"`
+    fi
+    car="$tmp"
+
+    else
+        # "which" is not portable, but is used here
+        # because we know that the command exists!
+        car=`which $car`
+    fi
+    if test "x$cdr" != xEOL; then
+        MAKE_CANDIDATE="$car ${cdr% *}"
+    else
+        MAKE_CANDIDATE="$car"
+    fi
+
+    MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
+    IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
+    if test "x$IS_GNU_MAKE" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5
+$as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;}
+    else
+      IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'`
+      if test "x$IS_MODERN_MAKE" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5
+$as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;}
+      else
+        FOUND_MAKE=$MAKE_CANDIDATE
+      fi
+    fi
+  fi
+
+    fi
+
+    if test "x$FOUND_MAKE" = x; then
+      if test "x$TOOLS_DIR" != x; then
+        # We have a tools-dir, check that as well before giving up.
+        OLD_PATH=$PATH
+        PATH=$TOOLS_DIR:$PATH
+        for ac_prog in gmake
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CHECK_TOOLSDIR_GMAKE+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CHECK_TOOLSDIR_GMAKE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CHECK_TOOLSDIR_GMAKE="$CHECK_TOOLSDIR_GMAKE" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CHECK_TOOLSDIR_GMAKE="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CHECK_TOOLSDIR_GMAKE=$ac_cv_path_CHECK_TOOLSDIR_GMAKE
+if test -n "$CHECK_TOOLSDIR_GMAKE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_TOOLSDIR_GMAKE" >&5
+$as_echo "$CHECK_TOOLSDIR_GMAKE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CHECK_TOOLSDIR_GMAKE" && break
+done
+
+
+  MAKE_CANDIDATE=""$CHECK_TOOLSDIR_GMAKE""
+  DESCRIPTION="gmake in tools-dir"
+  if test "x$MAKE_CANDIDATE" != x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5
+$as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;}
+
+    # Translate "gcc -E" into "`which gcc` -E" ie
+    # extract the full path to the binary and at the
+    # same time maintain any arguments passed to it.
+    # The command MUST exist in the path, or else!
+    tmp="$MAKE_CANDIDATE"
+    car="${tmp%% *}"
+    tmp="$MAKE_CANDIDATE EOL"
+    cdr="${tmp#* }"
+    # On windows we want paths without spaces.
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+
+    # Translate long cygdrive or C:\sdfsf path
+    # into a short mixed mode path that has no
+    # spaces in it.
+    tmp="$car"
+
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+        tmp=`$CYGPATH -u "$car"`
+        tmp=`which "$tmp"`
+        # If file exists with .exe appended, that's the real filename
+        # and cygpath needs that to convert to short style path.
+        if test -f "${tmp}.exe"; then
+           tmp="${tmp}.exe"
+        elif test -f "${tmp}.cmd"; then
+           tmp="${tmp}.cmd"
+        fi
+        # Convert to C:/ mixed style path without spaces.
+         tmp=`$CYGPATH -s -m "$tmp"`
+    fi
+    car="$tmp"
+
+    else
+        # "which" is not portable, but is used here
+        # because we know that the command exists!
+        car=`which $car`
+    fi
+    if test "x$cdr" != xEOL; then
+        MAKE_CANDIDATE="$car ${cdr% *}"
+    else
+        MAKE_CANDIDATE="$car"
+    fi
+
+    MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
+    IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
+    if test "x$IS_GNU_MAKE" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5
+$as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;}
+    else
+      IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'`
+      if test "x$IS_MODERN_MAKE" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5
+$as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;}
+      else
+        FOUND_MAKE=$MAKE_CANDIDATE
+      fi
+    fi
+  fi
+
+        if test "x$FOUND_MAKE" = x; then
+          for ac_prog in make
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CHECK_TOOLSDIR_MAKE+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CHECK_TOOLSDIR_MAKE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CHECK_TOOLSDIR_MAKE="$CHECK_TOOLSDIR_MAKE" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CHECK_TOOLSDIR_MAKE="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CHECK_TOOLSDIR_MAKE=$ac_cv_path_CHECK_TOOLSDIR_MAKE
+if test -n "$CHECK_TOOLSDIR_MAKE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_TOOLSDIR_MAKE" >&5
+$as_echo "$CHECK_TOOLSDIR_MAKE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CHECK_TOOLSDIR_MAKE" && break
+done
+
+
+  MAKE_CANDIDATE=""$CHECK_TOOLSDIR_MAKE""
+  DESCRIPTION="make in tools-dir"
+  if test "x$MAKE_CANDIDATE" != x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5
+$as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;}
+
+    # Translate "gcc -E" into "`which gcc` -E" ie
+    # extract the full path to the binary and at the
+    # same time maintain any arguments passed to it.
+    # The command MUST exist in the path, or else!
+    tmp="$MAKE_CANDIDATE"
+    car="${tmp%% *}"
+    tmp="$MAKE_CANDIDATE EOL"
+    cdr="${tmp#* }"
+    # On windows we want paths without spaces.
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+
+    # Translate long cygdrive or C:\sdfsf path
+    # into a short mixed mode path that has no
+    # spaces in it.
+    tmp="$car"
+
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+        tmp=`$CYGPATH -u "$car"`
+        tmp=`which "$tmp"`
+        # If file exists with .exe appended, that's the real filename
+        # and cygpath needs that to convert to short style path.
+        if test -f "${tmp}.exe"; then
+           tmp="${tmp}.exe"
+        elif test -f "${tmp}.cmd"; then
+           tmp="${tmp}.cmd"
+        fi
+        # Convert to C:/ mixed style path without spaces.
+         tmp=`$CYGPATH -s -m "$tmp"`
+    fi
+    car="$tmp"
+
+    else
+        # "which" is not portable, but is used here
+        # because we know that the command exists!
+        car=`which $car`
+    fi
+    if test "x$cdr" != xEOL; then
+        MAKE_CANDIDATE="$car ${cdr% *}"
+    else
+        MAKE_CANDIDATE="$car"
+    fi
+
+    MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
+    IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
+    if test "x$IS_GNU_MAKE" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5
+$as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;}
+    else
+      IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'`
+      if test "x$IS_MODERN_MAKE" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5
+$as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;}
+      else
+        FOUND_MAKE=$MAKE_CANDIDATE
+      fi
+    fi
+  fi
+
+        fi
+        PATH=$OLD_PATH
+      fi
+    fi
+
+    if test "x$FOUND_MAKE" = x; then
+      as_fn_error $? "Cannot find GNU make 3.81 or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure." "$LINENO" 5
+    fi
+  fi
+
+  MAKE=$FOUND_MAKE
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)" >&5
+$as_echo "$as_me: Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)" >&6;}
+
+
+
+    for ac_prog in rm
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_RM+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $RM in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_RM="$RM" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_RM="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+RM=$ac_cv_path_RM
+if test -n "$RM"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RM" >&5
+$as_echo "$RM" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$RM" && break
+done
+
+
+    if test "x$RM" = x; then
+        if test "xrm" = x; then
+          PROG_NAME=rm
+        else
+          PROG_NAME=rm
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5
+$as_echo "$as_me: Could not find $PROG_NAME!" >&6;}
+        as_fn_error $? "Cannot continue" "$LINENO" 5
+    fi
+
+
+RM="$RM -f"
+
+
+    # Test if find supports -delete
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if find supports -delete" >&5
+$as_echo_n "checking if find supports -delete... " >&6; }
+    FIND_DELETE="-delete"
+
+    DELETEDIR=`mktemp -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?)
+
+    echo Hejsan > $DELETEDIR/TestIfFindSupportsDelete
+
+    TEST_DELETE=`$FIND "$DELETEDIR" -name TestIfFindSupportsDelete $FIND_DELETE 2>&1`
+    if test -f $DELETEDIR/TestIfFindSupportsDelete; then
+        # No, it does not.
+        rm $DELETEDIR/TestIfFindSupportsDelete
+        FIND_DELETE="-exec rm \{\} \+"
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    fi
+    rmdir $DELETEDIR
+
+
+
+# Non-required basic tools
+
+# Extract the first word of "pwd", so it can be a program name with args.
+set dummy pwd; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_THEPWDCMD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $THEPWDCMD in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_THEPWDCMD="$THEPWDCMD" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_THEPWDCMD="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+THEPWDCMD=$ac_cv_path_THEPWDCMD
+if test -n "$THEPWDCMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THEPWDCMD" >&5
+$as_echo "$THEPWDCMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
 
 # Extract the first word of "ldd", so it can be a program name with args.
 set dummy ldd; ac_word=$2
@@ -5611,8 +7460,10 @@
 if test "x$OTOOL" = "x"; then
    OTOOL="true"
 fi
-# Extract the first word of "readelf", so it can be a program name with args.
-set dummy readelf; ac_word=$2
+for ac_prog in readelf greadelf
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_path_READELF+set}" = set; then :
@@ -5651,93 +7502,53 @@
 fi
 
 
-# Extract the first word of "expr", so it can be a program name with args.
-set dummy expr; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_EXPR+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $EXPR in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_EXPR="$EXPR" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_EXPR="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-EXPR=$ac_cv_path_EXPR
-if test -n "$EXPR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $EXPR" >&5
-$as_echo "$EXPR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable EXPR is not empty.
-    if test "" = "$EXPR"; then as_fn_error $? "Could not find expr !" "$LINENO" 5 ; fi
-
-# Extract the first word of "file", so it can be a program name with args.
-set dummy file; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_FILE+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $FILE in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_FILE="$FILE" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_FILE="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-FILE=$ac_cv_path_FILE
-if test -n "$FILE"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FILE" >&5
-$as_echo "$FILE" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-    # Test that variable FILE is not empty.
-    if test "" = "$FILE"; then as_fn_error $? "Could not find file !" "$LINENO" 5 ; fi
+  test -n "$READELF" && break
+done
+
+for ac_prog in objdump gobjdump
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_OBJDUMP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $OBJDUMP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_OBJDUMP="$OBJDUMP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_OBJDUMP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+OBJDUMP=$ac_cv_path_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$OBJDUMP" && break
+done
 
 # Extract the first word of "hg", so it can be a program name with args.
 set dummy hg; ac_word=$2
@@ -5781,199 +7592,6 @@
 
 
 
-# Setup builddeps, for automatic downloading of tools we need.
-# This is needed before we can call BDEPS_CHECK_MODULE, which is done in
-# boot-jdk setup, but we need to have basic tools setup first.
-
-
-# Check whether --with-builddeps-conf was given.
-if test "${with_builddeps_conf+set}" = set; then :
-  withval=$with_builddeps_conf;
-fi
-
-
-
-# Check whether --with-builddeps-server was given.
-if test "${with_builddeps_server+set}" = set; then :
-  withval=$with_builddeps_server;
-fi
-
-
-
-# Check whether --with-builddeps-dir was given.
-if test "${with_builddeps_dir+set}" = set; then :
-  withval=$with_builddeps_dir;
-else
-  with_builddeps_dir=/localhome/builddeps
-fi
-
-
-
-# Check whether --with-builddeps-group was given.
-if test "${with_builddeps_group+set}" = set; then :
-  withval=$with_builddeps_group;
-fi
-
-
-# Check whether --enable-list-builddeps was given.
-if test "${enable_list_builddeps+set}" = set; then :
-  enableval=$enable_list_builddeps; LIST_BUILDDEPS="${enableval}"
-else
-  LIST_BUILDDEPS='no'
-fi
-
-
-if test "x$LIST_BUILDDEPS" = xyes; then
-    echo
-    echo List of build dependencies known to the configure script,
-    echo that can be used in builddeps.conf files:
-    cat $AUTOCONF_DIR/*.ac $AUTOCONF_DIR/*.m4 | grep BDEPS_CHECK_MODULE\( | cut -f 2 -d ',' | tr -d ' ' | sort
-    echo
-    exit 1
-fi
-
-
-
-    if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then
-        if test "x$with_builddeps_conf" != x; then
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for supplied builddeps configuration file" >&5
-$as_echo_n "checking for supplied builddeps configuration file... " >&6; }
-            builddepsfile=$with_builddeps_conf
-            if test -s $builddepsfile; then
-                . $builddepsfile
-                { $as_echo "$as_me:${as_lineno-$LINENO}: result: loaded!" >&5
-$as_echo "loaded!" >&6; }
-            else
-               as_fn_error $? "The given builddeps conf file $with_builddeps_conf could not be loaded!" "$LINENO" 5
-           fi
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for builddeps.conf files in sources..." >&5
-$as_echo_n "checking for builddeps.conf files in sources...... " >&6; }
-            builddepsfile=`mktemp`
-            touch $builddepsfile
-            # Put all found confs into a single file.
-            find ${SRC_ROOT} -name builddeps.conf -exec cat \{\} \; >> $builddepsfile
-            # Source the file to acquire the variables
-            if test -s $builddepsfile; then
-                . $builddepsfile
-                { $as_echo "$as_me:${as_lineno-$LINENO}: result: found at least one!" >&5
-$as_echo "found at least one!" >&6; }
-            else
-               as_fn_error $? "Could not find any builddeps.conf at all!" "$LINENO" 5
-           fi
-        fi
-        # Create build and target names that use _ instead of "-" and ".".
-        # This is necessary to use them in variable names.
-        build_var=`echo ${OPENJDK_BUILD_SYSTEM} | tr '-' '_' | tr '.' '_'`
-        target_var=`echo ${OPENJDK_TARGET_SYSTEM} | tr '-' '_' | tr '.' '_'`
-        # Extract rewrite information for build and target
-        eval rewritten_build=\${REWRITE_${build_var}}
-        if test "x$rewritten_build" = x; then
-            rewritten_build=${OPENJDK_BUILD_SYSTEM}
-            echo Build stays the same $rewritten_build
-        else
-            echo Rewriting build for builddeps into $rewritten_build
-        fi
-        eval rewritten_target=\${REWRITE_${target_var}}
-        if test "x$rewritten_target" = x; then
-            rewritten_target=${OPENJDK_TARGET_SYSTEM}
-            echo Target stays the same $rewritten_target
-        else
-            echo Rewriting target for builddeps into $rewritten_target
-        fi
-        rewritten_build_var=`echo ${rewritten_build} | tr '-' '_' | tr '.' '_'`
-        rewritten_target_var=`echo ${rewritten_target} | tr '-' '_' | tr '.' '_'`
-    fi
-    for ac_prog in 7z unzip
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$BDEPS_UNZIP"; then
-  ac_cv_prog_BDEPS_UNZIP="$BDEPS_UNZIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_BDEPS_UNZIP="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-BDEPS_UNZIP=$ac_cv_prog_BDEPS_UNZIP
-if test -n "$BDEPS_UNZIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BDEPS_UNZIP" >&5
-$as_echo "$BDEPS_UNZIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$BDEPS_UNZIP" && break
-done
-
-    if test "x$BDEPS_UNZIP" = x7z; then
-        BDEPS_UNZIP="7z x"
-    fi
-
-    for ac_prog in wget lftp ftp
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$BDEPS_FTP"; then
-  ac_cv_prog_BDEPS_FTP="$BDEPS_FTP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_BDEPS_FTP="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-BDEPS_FTP=$ac_cv_prog_BDEPS_FTP
-if test -n "$BDEPS_FTP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BDEPS_FTP" >&5
-$as_echo "$BDEPS_FTP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$BDEPS_FTP" && break
-done
-
-
-
 # Check if pkg-config is available.
 
 
@@ -6092,676 +7710,7 @@
 
 fi
 
-###############################################################################
-#
-# Determine OpenJDK build and target platforms.
-#
-###############################################################################
-
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-$as_echo_n "checking build system type... " >&6; }
-if test "${ac_cv_build+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_build_alias=$build_alias
-test "x$ac_build_alias" = x &&
-  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-test "x$ac_build_alias" = x &&
-  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-$as_echo "$ac_cv_build" >&6; }
-case $ac_cv_build in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;;
-esac
-build=$ac_cv_build
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_build
-shift
-build_cpu=$1
-build_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-build_os=$*
-IFS=$ac_save_IFS
-case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-$as_echo_n "checking host system type... " >&6; }
-if test "${ac_cv_host+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$host_alias" = x; then
-  ac_cv_host=$ac_cv_build
-else
-  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
-$as_echo "$ac_cv_host" >&6; }
-case $ac_cv_host in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;;
-esac
-host=$ac_cv_host
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_host
-shift
-host_cpu=$1
-host_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-host_os=$*
-IFS=$ac_save_IFS
-case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
-$as_echo_n "checking target system type... " >&6; }
-if test "${ac_cv_target+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$target_alias" = x; then
-  ac_cv_target=$ac_cv_host
-else
-  ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
-$as_echo "$ac_cv_target" >&6; }
-case $ac_cv_target in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;;
-esac
-target=$ac_cv_target
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_target
-shift
-target_cpu=$1
-target_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-target_os=$*
-IFS=$ac_save_IFS
-case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
-
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-test -n "$target_alias" &&
-  test "$program_prefix$program_suffix$program_transform_name" = \
-    NONENONEs,x,x, &&
-  program_prefix=${target_alias}-
-
-# Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target"
-# is confusing; it assumes you are cross-compiling a cross-compiler (!)  and "target" is thus the target of the
-# product you're building. The target of this build is called "host". Since this is confusing to most people, we
-# have not adopted that system, but use "target" as the platform we are building for. In some places though we need
-# to use the configure naming style.
-
-
-
-
-
-# Check whether --with-target-bits was given.
-if test "${with_target_bits+set}" = set; then :
-  withval=$with_target_bits;
-fi
-
-
-if test "x$with_target_bits" != x && \
-   test "x$with_target_bits" != x32 && \
-   test "x$with_target_bits" != x64 ; then
-    as_fn_error $? "--with-target-bits can only be 32 or 64, you specified $with_target_bits!" "$LINENO" 5
-fi
-# Translate the standard cpu-vendor-kernel-os quadruplets into
-# the new TARGET_.... and BUILD_... and the legacy names used by
-# the openjdk build.
-# It uses $host_os $host_cpu $build_os $build_cpu and $with_target_bits
-
-    # Expects $host_os $host_cpu $build_os and $build_cpu
-    # and $with_target_bits to have been setup!
-    #
-    # Translate the standard triplet(quadruplet) definition
-    # of the target/build system into
-    # OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
-    # OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
-    # OPENJDK_TARGET_OS_API=posix,winapi
-    #
-    # OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
-    # OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
-    # OPENJDK_TARGET_CPU_BITS=32,64
-    # OPENJDK_TARGET_CPU_ENDIAN=big,little
-    #
-    # The same values are setup for BUILD_...
-    #
-    # And the legacy variables, for controlling the old makefiles.
-    # LEGACY_OPENJDK_TARGET_CPU1=i586,amd64/x86_64,sparc,sparcv9,arm,arm64...
-    # LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,sparc,sparcv9,arm,arm64...
-    # LEGACY_OPENJDK_TARGET_CPU3=sparcv9,amd64 (but only on solaris)
-    # LEGACY_OPENJDK_TARGET_OS_API=solaris,windows
-    #
-    # We also copy the autoconf trip/quadruplet
-    # verbatim to OPENJDK_TARGET_SYSTEM (from the autoconf "host") and OPENJDK_BUILD_SYSTEM
-    OPENJDK_TARGET_SYSTEM="$host"
-    OPENJDK_BUILD_SYSTEM="$build"
-
-
-
-
-
-  case "$host_os" in
-    *linux*)
-      VAR_OS=linux
-      VAR_OS_API=posix
-      VAR_OS_FAMILY=gnu
-      ;;
-    *solaris*)
-      VAR_OS=solaris
-      VAR_OS_API=posix
-      VAR_OS_FAMILY=sysv
-      ;;
-    *darwin*)
-      VAR_OS=macosx
-      VAR_OS_API=posix
-      VAR_OS_FAMILY=bsd
-      ;;
-    *bsd*)
-      VAR_OS=bsd
-      VAR_OS_API=posix
-      VAR_OS_FAMILY=bsd
-      ;;
-    *cygwin*|*windows*)
-      VAR_OS=windows
-      VAR_OS_API=winapi
-      VAR_OS_FAMILY=windows
-      ;;
-    *)
-      as_fn_error $? "unsupported operating system $host_os" "$LINENO" 5
-      ;;
-  esac
-
-    OPENJDK_TARGET_OS="$VAR_OS"
-    OPENJDK_TARGET_OS_FAMILY="$VAR_OS_FAMILY"
-    OPENJDK_TARGET_OS_API="$VAR_OS_API"
-
-
-
-
-
-    if test "x$OPENJDK_TARGET_OS_API" = xposix; then
-        LEGACY_OPENJDK_TARGET_OS_API="solaris"
-    fi
-    if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
-        LEGACY_OPENJDK_TARGET_OS_API="windows"
-    fi
-
-
-
-
-  # First argument is the cpu name from the trip/quad
-  case "$host_cpu" in
-    x86_64)
-      VAR_CPU=x64
-      VAR_CPU_ARCH=x86
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=amd64
-      ;;
-    i?86)
-      VAR_CPU=ia32
-      VAR_CPU_ARCH=x86
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=i586
-      ;;
-    alpha*)
-      VAR_CPU=alpha
-      VAR_CPU_ARCH=alpha
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=alpha
-      ;;
-    arm*)
-      VAR_CPU=arm
-      VAR_CPU_ARCH=arm
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=arm
-      ;;
-    mips)
-      VAR_CPU=mips
-      VAR_CPU_ARCH=mips
-      VAR_CPU_BITS=woot
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=mips
-       ;;
-    mipsel)
-      VAR_CPU=mipsel
-      VAR_CPU_ARCH=mips
-      VAR_CPU_BITS=woot
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=mipsel
-       ;;
-    powerpc)
-      VAR_CPU=ppc
-      VAR_CPU_ARCH=ppc
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=ppc
-       ;;
-    powerpc64)
-      VAR_CPU=ppc64
-      VAR_CPU_ARCH=ppc
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=ppc64
-       ;;
-    sparc)
-      VAR_CPU=sparc
-      VAR_CPU_ARCH=sparc
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=sparc
-       ;;
-    sparc64)
-      VAR_CPU=sparcv9
-      VAR_CPU_ARCH=sparc
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=sparcv9
-       ;;
-    s390)
-      VAR_CPU=s390
-      VAR_CPU_ARCH=s390
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=s390
-      VAR_LEGACY_CPU=s390
-       ;;
-    s390x)
-      VAR_CPU=s390x
-      VAR_CPU_ARCH=s390
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=s390x
-       ;;
-    *)
-      as_fn_error $? "unsupported cpu $host_cpu" "$LINENO" 5
-      ;;
-  esac
-
-  # Workaround cygwin not knowing about 64 bit.
-  if test "x$VAR_OS" = "xwindows"; then
-      if test "x$PROCESSOR_IDENTIFIER" != "x"; then
-          PROC_ARCH=`echo $PROCESSOR_IDENTIFIER | $CUT -f1 -d' '`
-          case "$PROC_ARCH" in
-            intel64|Intel64|INTEL64|em64t|EM64T|amd64|AMD64|8664|x86_64)
-              VAR_CPU=x64
-              VAR_CPU_BITS=64
-              VAR_LEGACY_CPU=amd64
-              ;;
-          esac
-      fi
-  fi
-
-  # on solaris x86...default seems to be 32-bit
-  if test "x$VAR_OS" = "xsolaris" && \
-     test "x$with_target_bits" = "x" && \
-     test "x$VAR_CPU_ARCH" = "xx86"
-  then
-      with_target_bits=32
-  fi
-
-  if test "x$VAR_CPU_ARCH" = "xx86"; then
-      if test "x$with_target_bits" = "x64"; then
-          VAR_CPU=x64
-          VAR_CPU_BITS=64
-          VAR_LEGACY_CPU=amd64
-      fi
-      if test "x$with_target_bits" = "x32"; then
-          VAR_CPU=ia32
-          VAR_CPU_BITS=32
-          VAR_LEGACY_CPU=i586
-      fi
-  fi
-
-  if test "x$VAR_CPU_ARCH" = "xsparc"; then
-      if test "x$with_target_bits" = "x64"; then
-          VAR_CPU=sparcv9
-          VAR_CPU_BITS=64
-          VAR_LEGACY_CPU=sparcv9
-      fi
-  fi
-
-    OPENJDK_TARGET_CPU="$VAR_CPU"
-    OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
-    OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
-    OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
-
-
-
-
-
-
-    # Also store the legacy naming of the cpu.
-    # Ie i586 and amd64 instead of ia32 and x64
-    LEGACY_OPENJDK_TARGET_CPU1="$VAR_LEGACY_CPU"
-
-
-    # And the second legacy naming of the cpu.
-    # Ie i386 and amd64 instead of ia32 and x64.
-    LEGACY_OPENJDK_TARGET_CPU2="$LEGACY_OPENJDK_TARGET_CPU1"
-    if test "x$LEGACY_OPENJDK_TARGET_CPU1" = xi586; then
-        LEGACY_OPENJDK_TARGET_CPU2=i386
-    fi
-
-
-    # And the third legacy naming of the cpu.
-    # Ie only amd64 or sparcv9, used for the ISA_DIR on Solaris.
-    LEGACY_OPENJDK_TARGET_CPU3=""
-    if test "x$OPENJDK_TARGET_CPU" = xx64; then
-        LEGACY_OPENJDK_TARGET_CPU3=amd64
-    fi
-    if test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
-        LEGACY_OPENJDK_TARGET_CPU3=sparcv9
-    fi
-
-
-
-
-
-  case "$build_os" in
-    *linux*)
-      VAR_OS=linux
-      VAR_OS_API=posix
-      VAR_OS_FAMILY=gnu
-      ;;
-    *solaris*)
-      VAR_OS=solaris
-      VAR_OS_API=posix
-      VAR_OS_FAMILY=sysv
-      ;;
-    *darwin*)
-      VAR_OS=macosx
-      VAR_OS_API=posix
-      VAR_OS_FAMILY=bsd
-      ;;
-    *bsd*)
-      VAR_OS=bsd
-      VAR_OS_API=posix
-      VAR_OS_FAMILY=bsd
-      ;;
-    *cygwin*|*windows*)
-      VAR_OS=windows
-      VAR_OS_API=winapi
-      VAR_OS_FAMILY=windows
-      ;;
-    *)
-      as_fn_error $? "unsupported operating system $build_os" "$LINENO" 5
-      ;;
-  esac
-
-    OPENJDK_BUILD_OS="$VAR_OS"
-    OPENJDK_BUILD_OS_FAMILY="$VAR_OS_FAMILY"
-    OPENJDK_BUILD_OS_API="$VAR_OS_API"
-
-
-
-
-
-    if test "x$OPENJDK_BUILD_OS_API" = xposix; then
-        LEGACY_OPENJDK_BUILD_OS_API="solaris"
-    fi
-    if test "x$OPENJDK_BUILD_OS_API" = xwinapi; then
-        LEGACY_OPENJDK_BUILD_OS_API="windows"
-    fi
-
-
-
-
-  # First argument is the cpu name from the trip/quad
-  case "$build_cpu" in
-    x86_64)
-      VAR_CPU=x64
-      VAR_CPU_ARCH=x86
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=amd64
-      ;;
-    i?86)
-      VAR_CPU=ia32
-      VAR_CPU_ARCH=x86
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=i586
-      ;;
-    alpha*)
-      VAR_CPU=alpha
-      VAR_CPU_ARCH=alpha
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=alpha
-      ;;
-    arm*)
-      VAR_CPU=arm
-      VAR_CPU_ARCH=arm
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=arm
-      ;;
-    mips)
-      VAR_CPU=mips
-      VAR_CPU_ARCH=mips
-      VAR_CPU_BITS=woot
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=mips
-       ;;
-    mipsel)
-      VAR_CPU=mipsel
-      VAR_CPU_ARCH=mips
-      VAR_CPU_BITS=woot
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=mipsel
-       ;;
-    powerpc)
-      VAR_CPU=ppc
-      VAR_CPU_ARCH=ppc
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=ppc
-       ;;
-    powerpc64)
-      VAR_CPU=ppc64
-      VAR_CPU_ARCH=ppc
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=ppc64
-       ;;
-    sparc)
-      VAR_CPU=sparc
-      VAR_CPU_ARCH=sparc
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=sparc
-       ;;
-    sparc64)
-      VAR_CPU=sparcv9
-      VAR_CPU_ARCH=sparc
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=sparcv9
-       ;;
-    s390)
-      VAR_CPU=s390
-      VAR_CPU_ARCH=s390
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=s390
-      VAR_LEGACY_CPU=s390
-       ;;
-    s390x)
-      VAR_CPU=s390x
-      VAR_CPU_ARCH=s390
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=s390x
-       ;;
-    *)
-      as_fn_error $? "unsupported cpu $build_cpu" "$LINENO" 5
-      ;;
-  esac
-
-  # Workaround cygwin not knowing about 64 bit.
-  if test "x$VAR_OS" = "xwindows"; then
-      if test "x$PROCESSOR_IDENTIFIER" != "x"; then
-          PROC_ARCH=`echo $PROCESSOR_IDENTIFIER | $CUT -f1 -d' '`
-          case "$PROC_ARCH" in
-            intel64|Intel64|INTEL64|em64t|EM64T|amd64|AMD64|8664|x86_64)
-              VAR_CPU=x64
-              VAR_CPU_BITS=64
-              VAR_LEGACY_CPU=amd64
-              ;;
-          esac
-      fi
-  fi
-
-  # on solaris x86...default seems to be 32-bit
-  if test "x$VAR_OS" = "xsolaris" && \
-     test "x$with_target_bits" = "x" && \
-     test "x$VAR_CPU_ARCH" = "xx86"
-  then
-      with_target_bits=32
-  fi
-
-  if test "x$VAR_CPU_ARCH" = "xx86"; then
-      if test "x$with_target_bits" = "x64"; then
-          VAR_CPU=x64
-          VAR_CPU_BITS=64
-          VAR_LEGACY_CPU=amd64
-      fi
-      if test "x$with_target_bits" = "x32"; then
-          VAR_CPU=ia32
-          VAR_CPU_BITS=32
-          VAR_LEGACY_CPU=i586
-      fi
-  fi
-
-  if test "x$VAR_CPU_ARCH" = "xsparc"; then
-      if test "x$with_target_bits" = "x64"; then
-          VAR_CPU=sparcv9
-          VAR_CPU_BITS=64
-          VAR_LEGACY_CPU=sparcv9
-      fi
-  fi
-
-    OPENJDK_BUILD_CPU="$VAR_CPU"
-    OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
-    OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
-    OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
-
-
-
-
-
-
-    # Also store the legacy naming of the cpu.
-    # Ie i586 and amd64 instead of ia32 and x64
-    LEGACY_OPENJDK_BUILD_CPU1="$VAR_LEGACY_CPU"
-
-
-    # And the second legacy naming of the cpu.
-    # Ie i386 and amd64 instead of ia32 and x64.
-    LEGACY_OPENJDK_BUILD_CPU2="$LEGACY_OPENJDK_BUILD_CPU1"
-    if test "x$LEGACY_OPENJDK_BUILD_CPU1" = xi586; then
-        LEGACY_OPENJDK_BUILD_CPU2=i386
-    fi
-
-
-    # And the third legacy naming of the cpu.
-    # Ie only amd64 or sparcv9, used for the ISA_DIR on Solaris.
-    LEGACY_OPENJDK_BUILD_CPU3=""
-    if test "x$OPENJDK_BUILD_CPU" = xx64; then
-        LEGACY_OPENJDK_BUILD_CPU3=amd64
-    fi
-    if test "x$OPENJDK_BUILD_CPU" = xsparcv9; then
-        LEGACY_OPENJDK_BUILD_CPU3=sparcv9
-    fi
-
-
-
-    if test "x$OPENJDK_TARGET_OS" != xsolaris; then
-        LEGACY_OPENJDK_TARGET_CPU3=""
-        LEGACY_OPENJDK_BUILD_CPU3=""
-    fi
-
-    # On MacOSX and MacOSX only, we have a different name for the x64 CPU in ARCH (LEGACY_OPENJDK_TARGET_CPU1) ...
-    if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$OPENJDK_TARGET_CPU" = xx64; then
-        LEGACY_OPENJDK_TARGET_CPU1="x86_64"
-    fi
-
-
-    if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
-       REQUIRED_OS_NAME=SunOS
-       REQUIRED_OS_VERSION=5.10
-    fi
-    if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
-       REQUIRED_OS_NAME=Linux
-       REQUIRED_OS_VERSION=2.6
-    fi
-    if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
-        REQUIRED_OS_NAME=Windows
-        REQUIRED_OS_VERSION=5.1
-    fi
-    if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
-        REQUIRED_OS_NAME=Darwin
-        REQUIRED_OS_VERSION=11.2
-    fi
-
-
-
-
-
-
-# The LEGACY_OPENJDK_TARGET_CPU3 is the setting for ISA_DIR.
-if test "x$LEGACY_OPENJDK_TARGET_CPU3" != x; then
-   LEGACY_OPENJDK_TARGET_CPU3="/${LEGACY_OPENJDK_TARGET_CPU3}"
-fi
-
-# Now the following vars are defined.
-# OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
-# OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
-# OPENJDK_TARGET_OS_API=posix,winapi
-#
-# OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
-# OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
-# OPENJDK_TARGET_CPU_BITS=32,64
-# OPENJDK_TARGET_CPU_ENDIAN=big,little
-#
-# There is also a:
-# LEGACY_OPENJDK_TARGET_CPU1=i586,amd64,....  # used to set the old var ARCH
-# LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,.... # used to set the old var LIBARCH
-# LEGACY_OPENJDK_TARGET_CPU3=only sparcv9,amd64 # used to set the ISA_DIR on Solaris
-# There was also a BUILDARCH that had i486,amd64,... but we do not use that
-# in the new build.
-# LEGACY_OPENJDK_TARGET_OS_API=solaris,windows # used to select source roots
-
+# After basic tools have been setup, we can check build os specific details.
 
 ###############################################################################
 
@@ -6776,63 +7725,197 @@
 
 
 
-# With knowledge of the build platform, setup more basic things.
-
-# For cygwin we need cygpath first, since it is used everywhere.
-# Extract the first word of "cygpath", so it can be a program name with args.
-set dummy cygpath; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CYGPATH+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $CYGPATH in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_CYGPATH="$CYGPATH" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_CYGPATH="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-CYGPATH=$ac_cv_path_CYGPATH
-if test -n "$CYGPATH"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGPATH" >&5
-$as_echo "$CYGPATH" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-PATH_SEP=":"
-if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
-    if test "x$CYGPATH" = x; then
-        as_fn_error $? "Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path" "$LINENO" 5
-    fi
-    PATH_SEP=";"
-fi
-
-
-
-if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
-    # Add extra search paths on solaris for utilities like ar and as etc...
-    PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin"
-fi
+# Setup builddeps, for automatic downloading of tools we need.
+# This is needed before we can call BDEPS_CHECK_MODULE, which is done in
+# boot-jdk setup, but we need to have basic tools setup first.
+
+
+# Check whether --with-builddeps-conf was given.
+if test "${with_builddeps_conf+set}" = set; then :
+  withval=$with_builddeps_conf;
+fi
+
+
+
+# Check whether --with-builddeps-server was given.
+if test "${with_builddeps_server+set}" = set; then :
+  withval=$with_builddeps_server;
+fi
+
+
+
+# Check whether --with-builddeps-dir was given.
+if test "${with_builddeps_dir+set}" = set; then :
+  withval=$with_builddeps_dir;
+else
+  with_builddeps_dir=/localhome/builddeps
+fi
+
+
+
+# Check whether --with-builddeps-group was given.
+if test "${with_builddeps_group+set}" = set; then :
+  withval=$with_builddeps_group;
+fi
+
+
+# Check whether --enable-list-builddeps was given.
+if test "${enable_list_builddeps+set}" = set; then :
+  enableval=$enable_list_builddeps; LIST_BUILDDEPS="${enableval}"
+else
+  LIST_BUILDDEPS='no'
+fi
+
+
+if test "x$LIST_BUILDDEPS" = xyes; then
+    echo
+    echo List of build dependencies known to the configure script,
+    echo that can be used in builddeps.conf files:
+    cat $AUTOCONF_DIR/*.ac $AUTOCONF_DIR/*.m4 | grep BDEPS_CHECK_MODULE\( | cut -f 2 -d ',' | tr -d ' ' | sort
+    echo
+    exit 1
+fi
+
+
+
+    if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then
+        if test "x$with_builddeps_conf" != x; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for supplied builddeps configuration file" >&5
+$as_echo_n "checking for supplied builddeps configuration file... " >&6; }
+            builddepsfile=$with_builddeps_conf
+            if test -s $builddepsfile; then
+                . $builddepsfile
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: loaded!" >&5
+$as_echo "loaded!" >&6; }
+            else
+               as_fn_error $? "The given builddeps conf file $with_builddeps_conf could not be loaded!" "$LINENO" 5
+           fi
+        else
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for builddeps.conf files in sources..." >&5
+$as_echo_n "checking for builddeps.conf files in sources...... " >&6; }
+            builddepsfile=`mktemp`
+            touch $builddepsfile
+            # Put all found confs into a single file.
+            find ${SRC_ROOT} -name builddeps.conf -exec cat \{\} \; >> $builddepsfile
+            # Source the file to acquire the variables
+            if test -s $builddepsfile; then
+                . $builddepsfile
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: found at least one!" >&5
+$as_echo "found at least one!" >&6; }
+            else
+               as_fn_error $? "Could not find any builddeps.conf at all!" "$LINENO" 5
+           fi
+        fi
+        # Create build and target names that use _ instead of "-" and ".".
+        # This is necessary to use them in variable names.
+        build_var=`echo ${OPENJDK_BUILD_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'`
+        target_var=`echo ${OPENJDK_TARGET_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'`
+        # Extract rewrite information for build and target
+        eval rewritten_build=\${REWRITE_${build_var}}
+        if test "x$rewritten_build" = x; then
+            rewritten_build=${OPENJDK_BUILD_AUTOCONF_NAME}
+            echo Build stays the same $rewritten_build
+        else
+            echo Rewriting build for builddeps into $rewritten_build
+        fi
+        eval rewritten_target=\${REWRITE_${target_var}}
+        if test "x$rewritten_target" = x; then
+            rewritten_target=${OPENJDK_TARGET_AUTOCONF_NAME}
+            echo Target stays the same $rewritten_target
+        else
+            echo Rewriting target for builddeps into $rewritten_target
+        fi
+        rewritten_build_var=`echo ${rewritten_build} | tr '-' '_' | tr '.' '_'`
+        rewritten_target_var=`echo ${rewritten_target} | tr '-' '_' | tr '.' '_'`
+    fi
+    for ac_prog in 7z unzip
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$BDEPS_UNZIP"; then
+  ac_cv_prog_BDEPS_UNZIP="$BDEPS_UNZIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_BDEPS_UNZIP="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+BDEPS_UNZIP=$ac_cv_prog_BDEPS_UNZIP
+if test -n "$BDEPS_UNZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BDEPS_UNZIP" >&5
+$as_echo "$BDEPS_UNZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$BDEPS_UNZIP" && break
+done
+
+    if test "x$BDEPS_UNZIP" = x7z; then
+        BDEPS_UNZIP="7z x"
+    fi
+
+    for ac_prog in wget lftp ftp
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$BDEPS_FTP"; then
+  ac_cv_prog_BDEPS_FTP="$BDEPS_FTP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_BDEPS_FTP="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+BDEPS_FTP=$ac_cv_prog_BDEPS_FTP
+if test -n "$BDEPS_FTP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BDEPS_FTP" >&5
+$as_echo "$BDEPS_FTP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$BDEPS_FTP" && break
+done
+
 
 
 ###############################################################################
@@ -6848,7 +7931,7 @@
 # Check which variant of the JDK that we want to build.
 # Currently we have:
 #    normal:   standard edition
-#    embedded: cut down to a smaller footprint
+# but the custom make system may add other variants
 #
 # Effectively the JDK variant gives a name to a specific set of
 # modules to compile into the JDK. In the future, these modules
@@ -6864,18 +7947,10 @@
 
 
 if test "x$with_jdk_variant" = xnormal || test "x$with_jdk_variant" = x; then
-    JAVASE_EMBEDDED=""
-    MINIMIZE_RAM_USAGE=""
     JDK_VARIANT="normal"
-elif test "x$with_jdk_variant" = xembedded; then
-    JAVASE_EMBEDDED="JAVASE_EMBEDDED:=true"
-    MINIMIZE_RAM_USAGE="MINIMIZE_RAM_USAGE:=true"
-    JDK_VARIANT="embedded"
-else
-    as_fn_error $? "The available JDK variants are: normal, embedded" "$LINENO" 5
-fi
-
-
+else
+    as_fn_error $? "The available JDK variants are: normal" "$LINENO" 5
+fi
 
 
 
@@ -6904,11 +7979,7 @@
 
 
 if test "x$with_jvm_variants" = x; then
-    if test "x$JDK_VARIANT" = xembedded; then
-        with_jvm_variants="client"
-    else
-        with_jvm_variants="server"
-    fi
+     with_jvm_variants="server"
 fi
 
 JVM_VARIANTS=",$with_jvm_variants,"
@@ -6953,6 +8024,11 @@
 
 
 
+if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
+   MACOSX_UNIVERSAL="true"
+fi
+
+
 
 
 
@@ -7058,6 +8134,14 @@
 
 HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_EXPORT"
 
+# On Macosx universal binaries are produced, but they only contain
+# 64 bit intel. This invalidates control of which jvms are built
+# from configure, but only server is valid anyway. Fix this
+# when hotspot makefiles are rewritten.
+if test "x$MACOSX_UNIVERSAL" = xtrue; then
+    HOTSPOT_TARGET=universal_product
+fi
+
 #####
 
 
@@ -7133,14 +8217,12 @@
 
 if test "x$SUPPORT_HEADFUL" = xyes; then
     # We are building both headful and headless.
-    BUILD_HEADLESS_ONLY=""
     headful_msg="inlude support for both headful and headless"
 fi
 
 if test "x$SUPPORT_HEADFUL" = xno; then
     # Thus we are building headless only.
     BUILD_HEADLESS="BUILD_HEADLESS:=true"
-    BUILD_HEADLESS_ONLY="BUILD_HEADLESS_ONLY:=true"
     headful_msg="headless only"
 fi
 
@@ -7151,29 +8233,6 @@
 
 
 
-
-###############################################################################
-#
-# Should we run the painfully slow javadoc tool?
-#
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build documentation" >&5
-$as_echo_n "checking whether to build documentation... " >&6; }
-# Check whether --enable-docs was given.
-if test "${enable_docs+set}" = set; then :
-  enableval=$enable_docs; ENABLE_DOCS="${enableval}"
-else
-  ENABLE_DOCS='no'
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ENABLE_DOCS" >&5
-$as_echo "$ENABLE_DOCS" >&6; }
-
-GENERATE_DOCS=false
-if test "x$ENABLE_DOCS" = xyes; then
-    GENERATE_DOCS=true
-fi
-
-
 ###############################################################################
 #
 # Should we compile nimbus swing L&F? We can probably remove this option
@@ -7238,25 +8297,21 @@
 #
 COMPRESS_JARS=false
 
-# default for embedded is yes...
-if test "x$JDK_VARIANT" = "xembedded"; then
-   COMPRESS_JARS=true
-fi
 
 
 ###############################################################################
 #
 # Should we compile JFR
-#   default no, except for on closed-jdk and !embedded
+#   default no, except for on closed-jdk
 #
 ENABLE_JFR=no
 
 # Is the JFR source present
 
 #
-# For closed && !embedded default is yes if the source is present
-#
-if test "x${OPENJDK}" != "xtrue" && test "x$JDK_VARIANT" != "xembedded" && test -d "$SRC_ROOT/jdk/src/closed/share/native/oracle/jfr"; then
+# For closed default is yes
+#
+if test "x${OPENJDK}" != "xtrue"; then
    ENABLE_JFR=yes
 fi
 
@@ -7374,7 +8429,11 @@
     HAS_SPACE=`echo "$OUTPUT_ROOT" | grep " "`
     if test "x$HAS_SPACE" != x; then
         if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
             OUTPUT_ROOT=`$CYGPATH -s -m -a "$OUTPUT_ROOT"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            OUTPUT_ROOT=`$ECHO "$OUTPUT_ROOT" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
             OUTPUT_ROOT=`$CYGPATH -u "$OUTPUT_ROOT"`
         else
             as_fn_error $? "You cannot have spaces in the path to the output root! \"$OUTPUT_ROOT\"" "$LINENO" 5
@@ -7395,7 +8454,16 @@
 # The spec.gmk file contains all variables for the make system.
 ac_config_files="$ac_config_files $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in"
 
-# The spec.sh file contains variables for compare{images|-objects}.sh scrips.
+# The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
+ac_config_files="$ac_config_files $OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in"
+
+# The bootcycle-spec.gmk file contains support for boot cycle builds.
+ac_config_files="$ac_config_files $OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in"
+
+# The compare.sh is used to compare the build output to other builds.
+ac_config_files="$ac_config_files $OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in"
+
+# Spec.sh is currently used by compare-objects.sh
 ac_config_files="$ac_config_files $OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in"
 
 # The generated Makefile knows where the spec.gmk is and where the source is.
@@ -7423,41 +8491,129 @@
 fi
 
 
+# We look for the Boot JDK through various means, going from more certain to
+# more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if
+# we detected something (if so, the path to the jdk is in BOOT_JDK). But we
+# must check if this is indeed valid; otherwise we'll continue looking.
+
+# Test: Is bootjdk explicitely set by command line arguments?
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
 if test "x$with_boot_jdk" != x; then
     BOOT_JDK=$with_boot_jdk
-    BOOT_JDK_FOUND=yes
-fi
-if test "x$BOOT_JDK_FOUND" = xno; then
+    BOOT_JDK_FOUND=maybe
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using configure arguments" >&5
+$as_echo "$as_me: Found potential Boot JDK using configure arguments" >&6;}
+fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then
+  # Having specified an argument which is incorrect will produce an instant failure;
+  # we should not go on looking
+  as_fn_error $? "The path given by --with-boot-jdk does not contain a valid Boot JDK" "$LINENO" 5
+fi
+
+# Test: Is bootjdk available from builddeps?
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
 
 
     if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then
         # Source the builddeps file again, to make sure it uses the latest variables!
         . $builddepsfile
         # Look for a target and build machine specific resource!
-        eval resource=\${builddep_boot-jdk_BUILD_${rewritten_build_var}_TARGET_${rewritten_target_var}}
+        eval resource=\${builddep_bootjdk_BUILD_${rewritten_build_var}_TARGET_${rewritten_target_var}}
         if test "x$resource" = x; then
             # Ok, lets instead look for a target specific resource
-            eval resource=\${builddep_boot-jdk_TARGET_${rewritten_target_var}}
+            eval resource=\${builddep_bootjdk_TARGET_${rewritten_target_var}}
         fi
         if test "x$resource" = x; then
             # Ok, lets instead look for a build specific resource
-            eval resource=\${builddep_boot-jdk_BUILD_${rewritten_build_var}}
+            eval resource=\${builddep_bootjdk_BUILD_${rewritten_build_var}}
         fi
         if test "x$resource" = x; then
             # Ok, lets instead look for a generic resource
-            # (The boot-jdk comes from M4 and not the shell, thus no need for eval here.)
-            resource=${builddep_boot-jdk}
+            # (The bootjdk comes from M4 and not the shell, thus no need for eval here.)
+            resource=${builddep_bootjdk}
         fi
         if test "x$resource" != x; then
-            { $as_echo "$as_me:${as_lineno-$LINENO}: Using builddeps $resource for boot-jdk" >&5
-$as_echo "$as_me: Using builddeps $resource for boot-jdk" >&6;}
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Using builddeps $resource for bootjdk" >&5
+$as_echo "$as_me: Using builddeps $resource for bootjdk" >&6;}
 	    # If the resource in the builddeps.conf file is an existing directory,
 	    # for example /java/linux/cups
 	    if test -d ${resource}; then
 	       depdir=${resource}
 	    else
 
-# boot-jdk is for example mymodule
+# bootjdk is for example mymodule
 # $resource is for example libs/general/libmymod_1_2_3.zip
 # $with_builddeps_server is for example ftp://mybuilddeps.myserver.com/builddeps
 # $with_builddeps_dir is for example /localhome/builddeps
@@ -7470,15 +8626,15 @@
     extension=${filename#*.}
     installdir=$with_builddeps_dir/$filebase
     if test ! -f $installdir/$filename.unpacked; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Downloading build dependency boot-jdk from $with_builddeps_server/$resource and installing into $installdir" >&5
-$as_echo "$as_me: Downloading build dependency boot-jdk from $with_builddeps_server/$resource and installing into $installdir" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Downloading build dependency bootjdk from $with_builddeps_server/$resource and installing into $installdir" >&5
+$as_echo "$as_me: Downloading build dependency bootjdk from $with_builddeps_server/$resource and installing into $installdir" >&6;}
         if test ! -d $installdir; then
             mkdir -p $installdir
         fi
         if test ! -d $installdir; then
             as_fn_error $? "Could not create directory $installdir" "$LINENO" 5
         fi
-        tmpfile=`mktemp $installdir/boot-jdk.XXXXXXXXX`
+        tmpfile=`mktemp $installdir/bootjdk.XXXXXXXXX`
         touch $tmpfile
         if test ! -f $tmpfile; then
             as_fn_error $? "Could not create files in directory $installdir" "$LINENO" 5
@@ -7549,11 +8705,11 @@
             # was updated to point at the current build dependency install directory.
             . $builddepsfile
             # Now extract variables from the builddeps.conf files.
-            theroot=${builddep_boot-jdk_ROOT}
-            thecflags=${builddep_boot-jdk_CFLAGS}
-            thelibs=${builddep_boot-jdk_LIBS}
+            theroot=${builddep_bootjdk_ROOT}
+            thecflags=${builddep_bootjdk_CFLAGS}
+            thelibs=${builddep_bootjdk_LIBS}
             if test "x$depdir" = x; then
-                as_fn_error $? "Could not download build dependency boot-jdk" "$LINENO" 5
+                as_fn_error $? "Could not download build dependency bootjdk" "$LINENO" 5
             fi
             BOOT_JDK=$depdir
             if test "x$theroot" != x; then
@@ -7565,7 +8721,7 @@
             if test "x$thelibs" != x; then
                BOOT_JDK_LIBS="$thelibs"
             fi
-            BOOT_JDK_FOUND=yes
+            BOOT_JDK_FOUND=maybe
             else BOOT_JDK_FOUND=no
 
         fi
@@ -7573,41 +8729,247 @@
 
     fi
 
-fi
-
-if test "x$BOOT_JDK_FOUND" = xno; then
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+# Test: Is $JAVA_HOME set?
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
     if test "x$JAVA_HOME" != x; then
-        if test ! -d "$JAVA_HOME"; then
+        if test "x$OPENJDK_TARGET_OS" = xwindows; then
+          # On Windows, JAVA_HOME is likely in DOS-style
+          JAVA_HOME_PROCESSED="`$CYGPATH -u "$JAVA_HOME"`"
+        else
+          JAVA_HOME_PROCESSED="$JAVA_HOME"
+        fi
+        if test ! -d "$JAVA_HOME_PROCESSED"; then
             { $as_echo "$as_me:${as_lineno-$LINENO}: Your JAVA_HOME points to a non-existing directory!" >&5
 $as_echo "$as_me: Your JAVA_HOME points to a non-existing directory!" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-        fi
-        # Aha, the user has set a JAVA_HOME
-        # let us use that as the Boot JDK.
-        BOOT_JDK="$JAVA_HOME"
-        BOOT_JDK_FOUND=yes
-        # To be on the safe side, lets check that it is a JDK.
-        if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then
-            JAVAC="$BOOT_JDK/bin/javac"
-            JAVA="$BOOT_JDK/bin/java"
-            BOOT_JDK_FOUND=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: Your JAVA_HOME points to a JRE! The build needs a JDK! Please point JAVA_HOME to a JDK. JAVA_HOME=$JAVA_HOME" >&5
-$as_echo "$as_me: Your JAVA_HOME points to a JRE! The build needs a JDK! Please point JAVA_HOME to a JDK. JAVA_HOME=$JAVA_HOME" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-        fi
-    fi
-fi
-
-if test "x$BOOT_JDK_FOUND" = xno; then
+        else
+          # Aha, the user has set a JAVA_HOME
+          # let us use that as the Boot JDK.
+          BOOT_JDK="$JAVA_HOME_PROCESSED"
+          BOOT_JDK_FOUND=maybe
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using JAVA_HOME" >&5
+$as_echo "$as_me: Found potential Boot JDK using JAVA_HOME" >&6;}
+        fi
+    fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX)
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+    if test -x /usr/libexec/java_home; then
+        BOOT_JDK=`/usr/libexec/java_home`
+        BOOT_JDK_FOUND=maybe
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using /usr/libexec/java_home" >&5
+$as_echo "$as_me: Found potential Boot JDK using /usr/libexec/java_home" >&6;}
+    fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+# Test: Is there a java or javac in the PATH, which is a symlink to the JDK?
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
     # Extract the first word of "javac", so it can be a program name with args.
 set dummy javac; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -7800,116 +9162,742 @@
         fi
     fi
 
-        BOOT_JDK=`dirname $BINARY`
-        BOOT_JDK=`cd $BOOT_JDK/..; pwd`
-        if test -x $BOOT_JDK/bin/javac && test -x $BOOT_JDK/bin/java; then
-            JAVAC=$BOOT_JDK/bin/javac
-            JAVA=$BOOT_JDK/bin/java
-            BOOT_JDK_FOUND=yes
-        fi
-    fi
-fi
-
-if test "x$BOOT_JDK_FOUND" = xno; then
-    # Try the MacOSX way.
-    if test -x /usr/libexec/java_home; then
-        BOOT_JDK=`/usr/libexec/java_home`
-        if test -x $BOOT_JDK/bin/javac && test -x $BOOT_JDK/bin/java; then
-            JAVAC=$BOOT_JDK/bin/javac
-            JAVA=$BOOT_JDK/bin/java
-            BOOT_JDK_FOUND=yes
-        fi
-    fi
-fi
-
+        BOOT_JDK=`dirname "$BINARY"`
+        BOOT_JDK=`cd "$BOOT_JDK/.."; pwd`
+        if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then
+            # Looks like we found ourselves an JDK
+            BOOT_JDK_FOUND=maybe
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using java(c) in PATH" >&5
+$as_echo "$as_me: Found potential Boot JDK using java(c) in PATH" >&6;}
+        fi
+    fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+# Test: Is there a JDK installed in default, well-known locations?
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  if test "x$OPENJDK_TARGET_OS" = xwindows; then
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  if test "x$ProgramW6432" != x; then
+
+  BOOT_JDK_PREFIX="`$CYGPATH -u "$ProgramW6432"`/Java"
+  BOOT_JDK_SUFFIX=""
+  BEST_JDK_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $GREP jdk | $SORT -r | $HEAD -n 1 `
+  if test "x$BEST_JDK_FOUND" != x; then
+    BOOT_JDK="${BOOT_JDK_PREFIX}/${BEST_JDK_FOUND}${BOOT_JDK_SUFFIX}"
+    if test -d "$BOOT_JDK"; then
+      BOOT_JDK_FOUND=maybe
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&5
+$as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&6;}
+    fi
+  fi
+
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  if test "x$PROGRAMW6432" != x; then
+
+  BOOT_JDK_PREFIX="`$CYGPATH -u "$PROGRAMW6432"`/Java"
+  BOOT_JDK_SUFFIX=""
+  BEST_JDK_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $GREP jdk | $SORT -r | $HEAD -n 1 `
+  if test "x$BEST_JDK_FOUND" != x; then
+    BOOT_JDK="${BOOT_JDK_PREFIX}/${BEST_JDK_FOUND}${BOOT_JDK_SUFFIX}"
+    if test -d "$BOOT_JDK"; then
+      BOOT_JDK_FOUND=maybe
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&5
+$as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&6;}
+    fi
+  fi
+
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  if test "x$PROGRAMFILES" != x; then
+
+  BOOT_JDK_PREFIX="`$CYGPATH -u "$PROGRAMFILES"`/Java"
+  BOOT_JDK_SUFFIX=""
+  BEST_JDK_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $GREP jdk | $SORT -r | $HEAD -n 1 `
+  if test "x$BEST_JDK_FOUND" != x; then
+    BOOT_JDK="${BOOT_JDK_PREFIX}/${BEST_JDK_FOUND}${BOOT_JDK_SUFFIX}"
+    if test -d "$BOOT_JDK"; then
+      BOOT_JDK_FOUND=maybe
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&5
+$as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&6;}
+    fi
+  fi
+
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  if test "x$ProgramFiles" != x; then
+
+  BOOT_JDK_PREFIX="`$CYGPATH -u "$ProgramFiles"`/Java"
+  BOOT_JDK_SUFFIX=""
+  BEST_JDK_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $GREP jdk | $SORT -r | $HEAD -n 1 `
+  if test "x$BEST_JDK_FOUND" != x; then
+    BOOT_JDK="${BOOT_JDK_PREFIX}/${BEST_JDK_FOUND}${BOOT_JDK_SUFFIX}"
+    if test -d "$BOOT_JDK"; then
+      BOOT_JDK_FOUND=maybe
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&5
+$as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&6;}
+    fi
+  fi
+
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  BOOT_JDK_PREFIX="/cygdrive/c/Program Files/Java"
+  BOOT_JDK_SUFFIX=""
+  BEST_JDK_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $GREP jdk | $SORT -r | $HEAD -n 1 `
+  if test "x$BEST_JDK_FOUND" != x; then
+    BOOT_JDK="${BOOT_JDK_PREFIX}/${BEST_JDK_FOUND}${BOOT_JDK_SUFFIX}"
+    if test -d "$BOOT_JDK"; then
+      BOOT_JDK_FOUND=maybe
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&5
+$as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&6;}
+    fi
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+  elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  BOOT_JDK_PREFIX="/Library/Java/JavaVirtualMachines"
+  BOOT_JDK_SUFFIX="/Contents/Home"
+  BEST_JDK_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $GREP jdk | $SORT -r | $HEAD -n 1 `
+  if test "x$BEST_JDK_FOUND" != x; then
+    BOOT_JDK="${BOOT_JDK_PREFIX}/${BEST_JDK_FOUND}${BOOT_JDK_SUFFIX}"
+    if test -d "$BOOT_JDK"; then
+      BOOT_JDK_FOUND=maybe
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&5
+$as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&6;}
+    fi
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+  if test "x$BOOT_JDK_FOUND" = xno; then
+    # Now execute the test
+
+  BOOT_JDK_PREFIX="/System/Library/Java/JavaVirtualMachines"
+  BOOT_JDK_SUFFIX="/Contents/Home"
+  BEST_JDK_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $GREP jdk | $SORT -r | $HEAD -n 1 `
+  if test "x$BEST_JDK_FOUND" != x; then
+    BOOT_JDK="${BOOT_JDK_PREFIX}/${BEST_JDK_FOUND}${BOOT_JDK_SUFFIX}"
+    if test -d "$BOOT_JDK"; then
+      BOOT_JDK_FOUND=maybe
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&5
+$as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX)" >&6;}
+    fi
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+  fi
+
+
+    # If previous step claimed to have found a JDK, check it to see if it seems to be valid.
+    if test "x$BOOT_JDK_FOUND" = xmaybe; then
+      # Do we have a bin/java?
+      if test ! -x "$BOOT_JDK/bin/java"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;}
+        BOOT_JDK_FOUND=no
+      else
+        # Do we have a bin/javac?
+        if test ! -x "$BOOT_JDK/bin/javac"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5
+$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;}
+          BOOT_JDK_FOUND=no
+        else
+          # Do we have an rt.jar? (On MacOSX it is called classes.jar)
+          if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;}
+            BOOT_JDK_FOUND=no
+          else
+            # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
+            BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
+
+            # Extra M4 quote needed to protect [] in grep expression.
+            FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
+            if test "x$FOUND_VERSION_78" = x; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
+$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;}
+              BOOT_JDK_FOUND=no
+            else
+              # We're done! :-)
+              BOOT_JDK_FOUND=yes
+
+    # Fail with message the path to the Boot JDK if var BOOT_JDK contains a path with no spaces in it.
+    # Unless on Windows, where we can rewrite the path.
+    HAS_SPACE=`echo "$BOOT_JDK" | grep " "`
+    if test "x$HAS_SPACE" != x; then
+        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
+            BOOT_JDK=`$CYGPATH -s -m -a "$BOOT_JDK"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            BOOT_JDK=`$ECHO "$BOOT_JDK" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
+            BOOT_JDK=`$CYGPATH -u "$BOOT_JDK"`
+        else
+            as_fn_error $? "You cannot have spaces in the path to the Boot JDK! \"$BOOT_JDK\"" "$LINENO" 5
+        fi
+    fi
+
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
+$as_echo_n "checking for Boot JDK... " >&6; }
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK ($BOOT_JDK_VERSION)" >&5
+$as_echo "$BOOT_JDK ($BOOT_JDK_VERSION)" >&6; }
+            fi # end check jdk version
+          fi # end check rt.jar
+        fi # end check javac
+      fi # end check java
+    fi # end check boot jdk found
+  fi
+
+
+# If we haven't found anything yet, we've truly lost. Give up.
 if test "x$BOOT_JDK_FOUND" = xno; then
-    # Extract the first word of "java", so it can be a program name with args.
-set dummy java; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_JAVA_CHECK+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $JAVA_CHECK in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_JAVA_CHECK="$JAVA_CHECK" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_JAVA_CHECK="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-JAVA_CHECK=$ac_cv_path_JAVA_CHECK
-if test -n "$JAVA_CHECK"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVA_CHECK" >&5
-$as_echo "$JAVA_CHECK" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-    if test "x$JAVA_CHECK" != x; then
-        # There is a java in the path. But apparently we have not found a javac
-        # in the path, since that would have been tested earlier.
-        if test "x$OPENJDK_TARGET_OS" = xwindows; then
-            # Now if this is a windows platform. The default installation of a JDK
-            # actually puts the JRE in the path and keeps the JDK out of the path!
-            # Go look in the default installation location.
-            BOOT_JDK=/cygdrive/c/Program\ Files/Java/`ls /cygdrive/c/Program\ Files/Java | grep jdk | sort -r | head --lines 1`
-            if test -d "$BOOT_JDK"; then
-                BOOT_JDK_FOUND=yes
-            fi
-        fi
-        if test "x$BOOT_JDK_FOUND" = xno; then
-
-    # Print a helpful message on how to acquire the necessary build dependency.
-    # openjdk is the help tag: freetyp2, cups, pulse, alsa etc
-    MISSING_DEPENDENCY=openjdk
-    PKGHANDLER_COMMAND=
-
-    case $PKGHANDLER in
-	apt-get)
-                apt_help     $MISSING_DEPENDENCY ;;
-    yum)
-                yum_help     $MISSING_DEPENDENCY ;;
-	port)
-                port_help    $MISSING_DEPENDENCY ;;
-	pkgutil)
-                pkgutil_help $MISSING_DEPENDENCY ;;
-	pkgadd)
-                pkgadd_help  $MISSING_DEPENDENCY ;;
-    * )
-      break ;;
-    esac
-
-    if test "x$PKGHANDLER_COMMAND" != x; then
-        HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
-    fi
-
-            { $as_echo "$as_me:${as_lineno-$LINENO}: Found a JRE, not not a JDK! Please remove the JRE from your path and put a JDK there instead. $HELP_MSG" >&5
-$as_echo "$as_me: Found a JRE, not not a JDK! Please remove the JRE from your path and put a JDK there instead. $HELP_MSG" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-        fi
-    else
 
     # Print a helpful message on how to acquire the necessary build dependency.
     # openjdk is the help tag: freetyp2, cups, pulse, alsa etc
@@ -7935,270 +9923,135 @@
         HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
     fi
 
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find a JDK. $HELP_MSG" >&5
-$as_echo "$as_me: Could not find a JDK. $HELP_MSG" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find a valid Boot JDK. $HELP_MSG" >&5
+$as_echo "$as_me: Could not find a valid Boot JDK. $HELP_MSG" >&6;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
 $as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-    fi
-fi
-
-
-    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
-        # Extract the first word of "cygpath", so it can be a program name with args.
-set dummy cygpath; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CYGPATH+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $CYGPATH in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_CYGPATH="$CYGPATH" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_CYGPATH="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-CYGPATH=$ac_cv_path_CYGPATH
-if test -n "$CYGPATH"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGPATH" >&5
-$as_echo "$CYGPATH" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-        tmp="$BOOT_JDK"
-        # Convert to C:/ mixed style path without spaces.
-        tmp=`$CYGPATH -s -m "$tmp"`
-        BOOT_JDK="$tmp"
-    fi
-
-
-# Now see if we can find the rt.jar, or its nearest equivalent.
+  as_fn_error $? "Cannot continue" "$LINENO" 5
+fi
+
+# Setup proper paths for what we found
 BOOT_RTJAR="$BOOT_JDK/jre/lib/rt.jar"
-
-    # Fail with message the path to the Boot JDK rt.jar (or nearest equivalent) if var BOOT_RTJAR contains a path with no spaces in it.
-    # Unless on Windows, where we can rewrite the path.
-    HAS_SPACE=`echo "$BOOT_RTJAR" | grep " "`
-    if test "x$HAS_SPACE" != x; then
-        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
-            BOOT_RTJAR=`$CYGPATH -s -m -a "$BOOT_RTJAR"`
-            BOOT_RTJAR=`$CYGPATH -u "$BOOT_RTJAR"`
-        else
-            as_fn_error $? "You cannot have spaces in the path to the Boot JDK rt.jar (or nearest equivalent)! \"$BOOT_RTJAR\"" "$LINENO" 5
-        fi
-    fi
-
-
+if test ! -f "$BOOT_RTJAR"; then
+    # On MacOSX it is called classes.jar
+    BOOT_RTJAR="$BOOT_JDK/../Classes/classes.jar"
+    if test -f "$BOOT_RTJAR"; then
+      # Remove the ..
+      BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}"
+    fi
+fi
 BOOT_TOOLSJAR="$BOOT_JDK/lib/tools.jar"
-
-    # Fail with message the path to the Boot JDK tools.jar (or nearest equivalent) if var BOOT_TOOLSJAR contains a path with no spaces in it.
-    # Unless on Windows, where we can rewrite the path.
-    HAS_SPACE=`echo "$BOOT_TOOLSJAR" | grep " "`
-    if test "x$HAS_SPACE" != x; then
-        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
-            BOOT_TOOLSJAR=`$CYGPATH -s -m -a "$BOOT_TOOLSJAR"`
-            BOOT_TOOLSJAR=`$CYGPATH -u "$BOOT_TOOLSJAR"`
-        else
-            as_fn_error $? "You cannot have spaces in the path to the Boot JDK tools.jar (or nearest equivalent)! \"$BOOT_TOOLSJAR\"" "$LINENO" 5
-        fi
-    fi
-
-
-if test ! -f $BOOT_RTJAR; then
-    # On MacOSX it is called classes.jar
-    BOOT_RTJAR=$BOOT_JDK/../Classes/classes.jar
-    if test ! -f $BOOT_RTJAR; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Cannot find the rt.jar or its equivalent!" >&5
-$as_echo "$as_me: Cannot find the rt.jar or its equivalent!" >&6;}
-        { $as_echo "$as_me:${as_lineno-$LINENO}: This typically means that configure failed to automatically find a suitable Boot JDK" >&5
-$as_echo "$as_me: This typically means that configure failed to automatically find a suitable Boot JDK" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-    fi
-    # Remove the ..
-    BOOT_RTJAR="`cd ${BOOT_RTJAR%/*} && pwd`/${BOOT_RTJAR##*/}"
-    # The tools.jar is part of classes.jar
-    BOOT_TOOLSJAR="$BOOT_RTJAR"
-fi
-
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
-$as_echo_n "checking for Boot JDK... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5
-$as_echo "$BOOT_JDK" >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot rt.jar" >&5
-$as_echo_n "checking for Boot rt.jar... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_RTJAR" >&5
-$as_echo "$BOOT_RTJAR" >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot tools.jar" >&5
-$as_echo_n "checking for Boot tools.jar... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_TOOLSJAR" >&5
-$as_echo "$BOOT_TOOLSJAR" >&6; }
-
-# Use the java tool from the Boot JDK.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for java in Boot JDK" >&5
+BOOT_JDK="$BOOT_JDK"
+
+
+
+
+# Setup tools from the Boot JDK.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for java in Boot JDK" >&5
 $as_echo_n "checking for java in Boot JDK... " >&6; }
-JAVA=$BOOT_JDK/bin/java
-if test ! -x $JAVA; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find a working java" >&5
-$as_echo "$as_me: Could not find a working java" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-fi
-BOOT_JDK_VERSION=`$JAVA -version 2>&1 | head -n 1`
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes $BOOT_JDK_VERSION" >&5
-$as_echo "yes $BOOT_JDK_VERSION" >&6; }
-
-
-# Extra M4 quote needed to protect [] in grep expression.
-FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep  '\"1\.[78]\.'`
-if test "x$FOUND_VERSION_78" = x; then
-
-    # Print a helpful message on how to acquire the necessary build dependency.
-    # openjdk is the help tag: freetyp2, cups, pulse, alsa etc
-    MISSING_DEPENDENCY=openjdk
-    PKGHANDLER_COMMAND=
-
-    case $PKGHANDLER in
-	apt-get)
-                apt_help     $MISSING_DEPENDENCY ;;
-    yum)
-                yum_help     $MISSING_DEPENDENCY ;;
-	port)
-                port_help    $MISSING_DEPENDENCY ;;
-	pkgutil)
-                pkgutil_help $MISSING_DEPENDENCY ;;
-	pkgadd)
-                pkgadd_help  $MISSING_DEPENDENCY ;;
-    * )
-      break ;;
-    esac
-
-    if test "x$PKGHANDLER_COMMAND" != x; then
-        HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
-    fi
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Your boot-jdk must be version 7 or 8. $HELP_MSG" >&5
-$as_echo "$as_me: Your boot-jdk must be version 7 or 8. $HELP_MSG" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-fi
+  JAVA=$BOOT_JDK/bin/java
+  if test ! -x $JAVA; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5
+$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;}
+      as_fn_error $? "Could not find java in the Boot JDK" "$LINENO" 5
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javac in Boot JDK" >&5
+$as_echo_n "checking for javac in Boot JDK... " >&6; }
+  JAVAC=$BOOT_JDK/bin/javac
+  if test ! -x $JAVAC; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5
+$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;}
+      as_fn_error $? "Could not find javac in the Boot JDK" "$LINENO" 5
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javah in Boot JDK" >&5
+$as_echo_n "checking for javah in Boot JDK... " >&6; }
+  JAVAH=$BOOT_JDK/bin/javah
+  if test ! -x $JAVAH; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5
+$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;}
+      as_fn_error $? "Could not find javah in the Boot JDK" "$LINENO" 5
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javap in Boot JDK" >&5
+$as_echo_n "checking for javap in Boot JDK... " >&6; }
+  JAVAP=$BOOT_JDK/bin/javap
+  if test ! -x $JAVAP; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5
+$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;}
+      as_fn_error $? "Could not find javap in the Boot JDK" "$LINENO" 5
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jar in Boot JDK" >&5
+$as_echo_n "checking for jar in Boot JDK... " >&6; }
+  JAR=$BOOT_JDK/bin/jar
+  if test ! -x $JAR; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5
+$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;}
+      as_fn_error $? "Could not find jar in the Boot JDK" "$LINENO" 5
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rmic in Boot JDK" >&5
+$as_echo_n "checking for rmic in Boot JDK... " >&6; }
+  RMIC=$BOOT_JDK/bin/rmic
+  if test ! -x $RMIC; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5
+$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;}
+      as_fn_error $? "Could not find rmic in the Boot JDK" "$LINENO" 5
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for native2ascii in Boot JDK" >&5
+$as_echo_n "checking for native2ascii in Boot JDK... " >&6; }
+  NATIVE2ASCII=$BOOT_JDK/bin/native2ascii
+  if test ! -x $NATIVE2ASCII; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5
+$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;}
+      as_fn_error $? "Could not find native2ascii in the Boot JDK" "$LINENO" 5
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+
+
+# Finally, set some other options...
 
 # When compiling code to be executed by the Boot JDK, force jdk7 compatibility.
 BOOT_JDK_SOURCETARGET="-source 7 -target 7"
 
 
-# Use the javac tool from the Boot JDK.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for javac in Boot JDK" >&5
-$as_echo_n "checking for javac in Boot JDK... " >&6; }
-JAVAC=$BOOT_JDK/bin/javac
-if test ! -x $JAVAC; then
-    as_fn_error $? "Could not find a working javac" "$LINENO" 5
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-
-
-# Use the javah tool from the Boot JDK.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for javah in Boot JDK" >&5
-$as_echo_n "checking for javah in Boot JDK... " >&6; }
-JAVAH=$BOOT_JDK/bin/javah
-if test ! -x $JAVAH; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find a working javah" >&5
-$as_echo "$as_me: Could not find a working javah" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-
-# Use the jar tool from the Boot JDK.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for jar in Boot JDK" >&5
-$as_echo_n "checking for jar in Boot JDK... " >&6; }
-JAR=$BOOT_JDK/bin/jar
-if test ! -x $JAR; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find a working jar" >&5
-$as_echo "$as_me: Could not find a working jar" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-# Use the rmic tool from the Boot JDK.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rmic in Boot JDK" >&5
-$as_echo_n "checking for rmic in Boot JDK... " >&6; }
-RMIC=$BOOT_JDK/bin/rmic
-if test ! -x $RMIC; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find a working rmic" >&5
-$as_echo "$as_me: Could not find a working rmic" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-# Use the native2ascii tool from the Boot JDK.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for native2ascii in Boot JDK" >&5
-$as_echo_n "checking for native2ascii in Boot JDK... " >&6; }
-NATIVE2ASCII=$BOOT_JDK/bin/native2ascii
-if test ! -x $NATIVE2ASCII; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find a working native2ascii" >&5
-$as_echo "$as_me: Could not find a working native2ascii" >&6;}
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5
-$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;}
-    as_fn_error $? "Cannot continue" "$LINENO" 5
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
 
 
 ##############################################################################
@@ -8573,33 +10426,10 @@
 
 
 
-LANGTOOLS_OUTPUTDIR="$OUTPUT_ROOT/langtools"
-CORBA_OUTPUTDIR="$OUTPUT_ROOT/corba"
-JAXP_OUTPUTDIR="$OUTPUT_ROOT/jaxp"
-JAXWS_OUTPUTDIR="$OUTPUT_ROOT/jaxws"
-HOTSPOT_OUTPUTDIR="$OUTPUT_ROOT/hotspot"
+BUILD_OUTPUT="$OUTPUT_ROOT"
+
+
 JDK_OUTPUTDIR="$OUTPUT_ROOT/jdk"
-IMAGES_OUTPUTDIR="$OUTPUT_ROOT/images"
-
-
-
-
-
-
-
-
-
-LANGTOOLS_DIST="$OUTPUT_ROOT/langtools/dist"
-CORBA_DIST="$OUTPUT_ROOT/corba/dist"
-JAXP_DIST="$OUTPUT_ROOT/jaxp/dist"
-JAXWS_DIST="$OUTPUT_ROOT/jaxws/dist"
-HOTSPOT_DIST="$OUTPUT_ROOT/hotspot/dist"
-
-
-
-
-
-
 
 
 ###############################################################################
@@ -8620,9 +10450,6 @@
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
-DEVKIT=
-SYS_ROOT=/
-
 
 # The option used to specify the target .o,.a or .so file.
 # When compiling, how to specify the to be created object file.
@@ -8645,6 +10472,61 @@
 # the set env variables into the spec file.
 SETUPDEVENV="# No special vars"
 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+    # Store path to cygwin link.exe to help excluding it when searching for
+    # VS linker.
+    # Extract the first word of "link", so it can be a program name with args.
+set dummy link; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_CYGWIN_LINK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CYGWIN_LINK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CYGWIN_LINK="$CYGWIN_LINK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CYGWIN_LINK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CYGWIN_LINK=$ac_cv_path_CYGWIN_LINK
+if test -n "$CYGWIN_LINK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGWIN_LINK" >&5
+$as_echo "$CYGWIN_LINK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the first found link.exe is actually the Cygwin link tool" >&5
+$as_echo_n "checking if the first found link.exe is actually the Cygwin link tool... " >&6; }
+    "$CYGWIN_LINK" --version > /dev/null
+    if test $? -eq 0 ; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      # This might be the VS linker. Don't exclude it later on.
+      CYGWIN_LINK=""
+    fi
+
     # If vcvarsall.bat has been run, then VCINSTALLDIR is set.
     if test "x$VCINSTALLDIR" != x; then
         # No further setup is needed. The build will happen from this kind
@@ -8675,12 +10557,12 @@
 $as_echo "no" >&6; }
             as_fn_error $? "Tried to find a VS installation using both $SEARCH_ROOT but failed. Please run \"c:\\cygwin\\bin\\bash.exe -l\" from a VS command prompt and then run configure/make from there." "$LINENO" 5
         fi
-        case "$LEGACY_OPENJDK_TARGET_CPU1" in
-          i?86)
+        case "$OPENJDK_TARGET_CPU" in
+          x86)
             VARSBAT_ARCH=x86
             ;;
-          *)
-            VARSBAT_ARCH=$LEGACY_OPENJDK_TARGET_CPU1
+          x86_64)
+            VARSBAT_ARCH=amd64
             ;;
         esac
         # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
@@ -8743,7 +10625,11 @@
     HAS_SPACE=`echo "$MSVCR100DLL" | grep " "`
     if test "x$HAS_SPACE" != x; then
         if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
             MSVCR100DLL=`$CYGPATH -s -m -a "$MSVCR100DLL"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            MSVCR100DLL=`$ECHO "$MSVCR100DLL" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
             MSVCR100DLL=`$CYGPATH -u "$MSVCR100DLL"`
         else
             as_fn_error $? "You cannot have spaces in the path to msvcr100.dll! \"$MSVCR100DLL\"" "$LINENO" 5
@@ -8768,64 +10654,56 @@
 # Setting only --host, does not seem to be really supported.
 # Please set both --build and --host if you want to cross compile.
 
-DEFINE_CROSS_COMPILE_ARCH=""
-HOSTCC=""
-HOSTCXX=""
-HOSTLD=""
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if this is a cross compile" >&5
-$as_echo_n "checking if this is a cross compile... " >&6; }
-if test "x$OPENJDK_BUILD_SYSTEM" != "x$OPENJDK_TARGET_SYSTEM"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, from $OPENJDK_BUILD_SYSTEM to $OPENJDK_TARGET_SYSTEM" >&5
-$as_echo "yes, from $OPENJDK_BUILD_SYSTEM to $OPENJDK_TARGET_SYSTEM" >&6; }
-    # We have detected a cross compile!
-    DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$LEGACY_OPENJDK_TARGET_CPU1"
+if test "x$COMPILE_TYPE" = "xcross"; then
     # Now we to find a C/C++ compiler that can build executables for the build
     # platform. We can't use the AC_PROG_CC macro, since it can only be used
-    # once.
+    # once. Also, we need to do this before adding a tools dir to the path,
+    # otherwise we might pick up cross-compilers which don't use standard naming.
+    # Otherwise, we'll set the BUILD_tools to the native tools, but that'll have
+    # to wait until they are properly discovered.
     for ac_prog in cl cc gcc
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_HOSTCC+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $HOSTCC in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_HOSTCC="$HOSTCC" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_HOSTCC="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-HOSTCC=$ac_cv_path_HOSTCC
-if test -n "$HOSTCC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOSTCC" >&5
-$as_echo "$HOSTCC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$HOSTCC" && break
+if test "${ac_cv_path_BUILD_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $BUILD_CC in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BUILD_CC="$BUILD_CC" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_BUILD_CC="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+BUILD_CC=$ac_cv_path_BUILD_CC
+if test -n "$BUILD_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_CC" >&5
+$as_echo "$BUILD_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$BUILD_CC" && break
 done
 
 
@@ -8833,9 +10711,9 @@
     # extract the full path to the binary and at the
     # same time maintain any arguments passed to it.
     # The command MUST exist in the path, or else!
-    tmp="$HOSTCC"
+    tmp="$BUILD_CC"
     car="${tmp%% *}"
-    tmp="$HOSTCC EOL"
+    tmp="$BUILD_CC EOL"
     cdr="${tmp#* }"
     # On windows we want paths without spaces.
     if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
@@ -8866,9 +10744,9 @@
         car=`which $car`
     fi
     if test "x$cdr" != xEOL; then
-        HOSTCC="$car ${cdr% *}"
-    else
-        HOSTCC="$car"
+        BUILD_CC="$car ${cdr% *}"
+    else
+        BUILD_CC="$car"
     fi
 
     for ac_prog in cl CC g++
@@ -8877,43 +10755,43 @@
 set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_HOSTCXX+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $HOSTCXX in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_HOSTCXX="$HOSTCXX" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_HOSTCXX="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-HOSTCXX=$ac_cv_path_HOSTCXX
-if test -n "$HOSTCXX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOSTCXX" >&5
-$as_echo "$HOSTCXX" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$HOSTCXX" && break
+if test "${ac_cv_path_BUILD_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $BUILD_CXX in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BUILD_CXX="$BUILD_CXX" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_BUILD_CXX="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+BUILD_CXX=$ac_cv_path_BUILD_CXX
+if test -n "$BUILD_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_CXX" >&5
+$as_echo "$BUILD_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$BUILD_CXX" && break
 done
 
 
@@ -8921,9 +10799,9 @@
     # extract the full path to the binary and at the
     # same time maintain any arguments passed to it.
     # The command MUST exist in the path, or else!
-    tmp="$HOSTCXX"
+    tmp="$BUILD_CXX"
     car="${tmp%% *}"
-    tmp="$HOSTCXX EOL"
+    tmp="$BUILD_CXX EOL"
     cdr="${tmp#* }"
     # On windows we want paths without spaces.
     if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
@@ -8954,45 +10832,45 @@
         car=`which $car`
     fi
     if test "x$cdr" != xEOL; then
-        HOSTCXX="$car ${cdr% *}"
-    else
-        HOSTCXX="$car"
+        BUILD_CXX="$car ${cdr% *}"
+    else
+        BUILD_CXX="$car"
     fi
 
     # Extract the first word of "ld", so it can be a program name with args.
 set dummy ld; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_HOSTLD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $HOSTLD in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_HOSTLD="$HOSTLD" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_HOSTLD="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-HOSTLD=$ac_cv_path_HOSTLD
-if test -n "$HOSTLD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOSTLD" >&5
-$as_echo "$HOSTLD" >&6; }
+if test "${ac_cv_path_BUILD_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $BUILD_LD in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BUILD_LD="$BUILD_LD" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_BUILD_LD="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+BUILD_LD=$ac_cv_path_BUILD_LD
+if test -n "$BUILD_LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_LD" >&5
+$as_echo "$BUILD_LD" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -9004,9 +10882,9 @@
     # extract the full path to the binary and at the
     # same time maintain any arguments passed to it.
     # The command MUST exist in the path, or else!
-    tmp="$HOSTLD"
+    tmp="$BUILD_LD"
     car="${tmp%% *}"
-    tmp="$HOSTLD EOL"
+    tmp="$BUILD_LD EOL"
     cdr="${tmp#* }"
     # On windows we want paths without spaces.
     if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
@@ -9037,34 +10915,20 @@
         car=`which $car`
     fi
     if test "x$cdr" != xEOL; then
-        HOSTLD="$car ${cdr% *}"
-    else
-        HOSTLD="$car"
-    fi
-
-    # Building for the build platform should be easy. Therefore
-    # we do not need any linkers or assemblers etc.
-else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-# You can force the sys-root if the sys-root encoded into the cross compiler tools
-# is not correct.
-
-# Check whether --with-sys-root was given.
-if test "${with_sys_root+set}" = set; then :
-  withval=$with_sys_root;
-fi
-
-
-if test "x$with_sys_root" != x; then
-    SYS_ROOT=$with_sys_root
-fi
+        BUILD_LD="$car ${cdr% *}"
+    else
+        BUILD_LD="$car"
+    fi
+
+fi
+
+
+
 
 # If a devkit is found on the builddeps server, then prepend its path to the
 # PATH variable. If there are cross compilers available in the devkit, these
 # will be found by AC_PROG_CC et al.
+DEVKIT=
 
 
     if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then
@@ -9232,29 +11096,6 @@
 ORG_CXXFLAGS="$CXXFLAGS"
 ORG_OBJCFLAGS="$OBJCFLAGS"
 
-
-# Check whether --with-tools-dir was given.
-if test "${with_tools_dir+set}" = set; then :
-  withval=$with_tools_dir; TOOLS_DIR=$with_tools_dir
-fi
-
-
-
-# Check whether --with-devkit was given.
-if test "${with_devkit+set}" = set; then :
-  withval=$with_devkit;
-    if test "x$with_sys_root" != x; then
-      as_fn_error $? "Cannot specify both --with-devkit and --with-sys-root at the same time" "$LINENO" 5
-    fi
-    if test "x$with_tools_dir" != x; then
-      as_fn_error $? "Cannot specify both --with-devkit and --with-tools-dir at the same time" "$LINENO" 5
-    fi
-    TOOLS_DIR=$with_devkit/bin
-    SYS_ROOT=$with_devkit/$host_alias/libc
-
-fi
-
-
 # autoconf magic only relies on PATH, so update it if tools dir is specified
 OLD_PATH="$PATH"
 if test "x$TOOLS_DIR" != x; then
@@ -10578,152 +12419,11 @@
 CXXFLAGS="$ORG_CXXFLAGS"
 OBJCFLAGS="$ORG_OBJCFLAGS"
 
-# If we are not cross compiling, use the same compilers for
-# building the build platform executables.
-if test "x$DEFINE_CROSS_COMPILE_ARCH" = x; then
-    HOSTCC="$CC"
-    HOSTCXX="$CXX"
-fi
-
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ld; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_LD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$LD"; then
-  ac_cv_prog_LD="$LD" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_LD="${ac_tool_prefix}ld"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-LD=$ac_cv_prog_LD
-if test -n "$LD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
-$as_echo "$LD" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_LD"; then
-  ac_ct_LD=$LD
-  # Extract the first word of "ld", so it can be a program name with args.
-set dummy ld; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_LD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_LD"; then
-  ac_cv_prog_ac_ct_LD="$ac_ct_LD" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_LD="ld"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_LD=$ac_cv_prog_ac_ct_LD
-if test -n "$ac_ct_LD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LD" >&5
-$as_echo "$ac_ct_LD" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_LD" = x; then
-    LD=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    LD=$ac_ct_LD
-  fi
-else
-  LD="$ac_cv_prog_LD"
-fi
-
-
-    # Translate "gcc -E" into "`which gcc` -E" ie
-    # extract the full path to the binary and at the
-    # same time maintain any arguments passed to it.
-    # The command MUST exist in the path, or else!
-    tmp="$LD"
-    car="${tmp%% *}"
-    tmp="$LD EOL"
-    cdr="${tmp#* }"
-    # On windows we want paths without spaces.
-    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
-
-    # Translate long cygdrive or C:\sdfsf path
-    # into a short mixed mode path that has no
-    # spaces in it.
-    tmp="$car"
-
-    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
-        tmp=`$CYGPATH -u "$car"`
-        tmp=`which "$tmp"`
-        # If file exists with .exe appended, that's the real filename
-        # and cygpath needs that to convert to short style path.
-        if test -f "${tmp}.exe"; then
-           tmp="${tmp}.exe"
-        elif test -f "${tmp}.cmd"; then
-           tmp="${tmp}.cmd"
-        fi
-        # Convert to C:/ mixed style path without spaces.
-         tmp=`$CYGPATH -s -m "$tmp"`
-    fi
-    car="$tmp"
-
-    else
-        # "which" is not portable, but is used here
-        # because we know that the command exists!
-        car=`which $car`
-    fi
-    if test "x$cdr" != xEOL; then
-        LD="$car ${cdr% *}"
-    else
-        LD="$car"
-    fi
-
 LD="$CC"
 LDEXE="$CC"
 LDCXX="$CXX"
 LDEXECXX="$CXX"
+
 # LDEXE is the linker to use, when creating executables.
 
 # Linking C++ libraries.
@@ -10731,7 +12431,8 @@
 # Linking C++ executables.
 
 
-if test -n "$ac_tool_prefix"; then
+if test "x$OPENJDK_BUILD_OS" != xwindows; then
+    if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -10866,6 +12567,7 @@
         AR="$car"
     fi
 
+fi
 if test "x$OPENJDK_BUILD_OS" = xmacosx; then
     ARFLAGS="-r"
 else
@@ -10882,7 +12584,7 @@
     EXE_OUT_OPTION=-out:
     LD_OUT_OPTION=-out:
     AR_OUT_OPTION=-out:
-    # On Windows, reject /usr/bin/link, which is a cygwin
+    # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
     # program for something completely different.
     # Extract the first word of "link", so it can be a program name with args.
 set dummy link; ac_word=$2
@@ -10902,7 +12604,7 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/bin/link"; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "$CYGWIN_LINK"; then
        ac_prog_rejected=yes
        continue
      fi
@@ -10961,13 +12663,22 @@
     fi
     WINLD="$tmp"
 
+    printf "Windows linker was found at $WINLD\n"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the found link.exe is actually the Visual Studio linker" >&5
+$as_echo_n "checking if the found link.exe is actually the Visual Studio linker... " >&6; }
+    "$WINLD" --version > /dev/null
+    if test $? -eq 0 ; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      as_fn_error $? "This is the Cygwin link tool. Please check your PATH and rerun configure." "$LINENO" 5
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    fi
     LD="$WINLD"
     LDEXE="$WINLD"
     LDCXX="$WINLD"
     LDEXECXX="$WINLD"
-    # Set HOSTLD to same as LD until we fully support cross compilation
-    # on windows.
-    HOSTLD="$WINLD"
 
     # Extract the first word of "mt", so it can be a program name with args.
 set dummy mt; ac_word=$2
@@ -11627,6 +13338,16 @@
     fi
 
 
+if test "x$COMPILE_TYPE" != "xcross"; then
+    # If we are not cross compiling, use the same compilers for
+    # building the build platform executables. The cross-compilation
+    # case needed to be done earlier, but this can only be done after
+    # the native tools have been localized.
+    BUILD_CC="$CC"
+    BUILD_CXX="$CXX"
+    BUILD_LD="$LD"
+fi
+
 # for solaris we really need solaris tools, and not gnu equivalent
 #   these seems to normally reside in /usr/ccs/bin so add that to path before
 #   starting to probe
@@ -11722,17 +13443,16 @@
         AS="$car"
     fi
 
-    ASFLAGS=" "
 else
     AS="$CC -c"
-    ASFLAGS=" "
-fi
-
+fi
 
 
 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
-    # Extract the first word of "nm", so it can be a program name with args.
-set dummy nm; ac_word=$2
+    for ac_prog in gnm nm
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_path_NM+set}" = set; then :
@@ -11771,6 +13491,9 @@
 fi
 
 
+  test -n "$NM" && break
+done
+
 
     # Translate "gcc -E" into "`which gcc` -E" ie
     # extract the full path to the binary and at the
@@ -11980,7 +13703,7 @@
         MCS="$car"
     fi
 
-else
+elif test "x$OPENJDK_BUILD_OS" != xwindows; then
     if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args.
 set dummy ${ac_tool_prefix}nm; ac_word=$2
@@ -12459,6 +14182,92 @@
 
 fi
 
+if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
+   # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_LIPO+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $LIPO in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_LIPO="$LIPO" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_LIPO="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+LIPO=$ac_cv_path_LIPO
+if test -n "$LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+    # Translate "gcc -E" into "`which gcc` -E" ie
+    # extract the full path to the binary and at the
+    # same time maintain any arguments passed to it.
+    # The command MUST exist in the path, or else!
+    tmp="$LIPO"
+    car="${tmp%% *}"
+    tmp="$LIPO EOL"
+    cdr="${tmp#* }"
+    # On windows we want paths without spaces.
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+
+    # Translate long cygdrive or C:\sdfsf path
+    # into a short mixed mode path that has no
+    # spaces in it.
+    tmp="$car"
+
+    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+        tmp=`$CYGPATH -u "$car"`
+        tmp=`which "$tmp"`
+        # If file exists with .exe appended, that's the real filename
+        # and cygpath needs that to convert to short style path.
+        if test -f "${tmp}.exe"; then
+           tmp="${tmp}.exe"
+        elif test -f "${tmp}.cmd"; then
+           tmp="${tmp}.cmd"
+        fi
+        # Convert to C:/ mixed style path without spaces.
+         tmp=`$CYGPATH -s -m "$tmp"`
+    fi
+    car="$tmp"
+
+    else
+        # "which" is not portable, but is used here
+        # because we know that the command exists!
+        car=`which $car`
+    fi
+    if test "x$cdr" != xEOL; then
+        LIPO="$car ${cdr% *}"
+    else
+        LIPO="$car"
+    fi
+
+fi
+
 # Restore old path without tools dir
 PATH="$OLD_PATH"
 
@@ -12604,16 +14413,71 @@
 # (The JVM can use 32 or 64 bit Java pointers but that decision
 # is made at runtime.)
 #
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-OLD_CXXFLAGS="$CXXFLAGS"
-if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
-	CXXFLAGS="-m${with_target_bits} $CXXFLAGS"
-fi
+if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+  # Always specify -m flags on Solaris
+
+  # keep track of c/cxx flags that we added outselves...
+  #   to prevent emitting warning...
+  ADDED_CFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+  ADDED_CXXFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+  ADDED_LDFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+
+  CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
+  CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
+  LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
+
+  CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
+  CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
+  LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
+
+elif test "x$COMPILE_TYPE" = xreduced; then
+  if test "x$OPENJDK_TARGET_OS" != xwindows; then
+    # Specify -m if running reduced on other Posix platforms
+
+  # keep track of c/cxx flags that we added outselves...
+  #   to prevent emitting warning...
+  ADDED_CFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+  ADDED_CXXFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+  ADDED_LDFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+
+  CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
+  CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
+  LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
+
+  CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
+  CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
+  LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
+
+  fi
+fi
+
+# Make compilation sanity check
+for ac_header in stdio.h
+do :
+  ac_fn_cxx_check_header_mongrel "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdio_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STDIO_H 1
+_ACEOF
+
+else
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Failed to compile stdio.h. This likely implies missing compile dependencies." >&5
+$as_echo "$as_me: Failed to compile stdio.h. This likely implies missing compile dependencies." >&6;}
+  if test "x$COMPILE_TYPE" = xreduced; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: You are doing a reduced build. Check that you have 32-bit libraries installed." >&5
+$as_echo "$as_me: You are doing a reduced build. Check that you have 32-bit libraries installed." >&6;}
+  elif test "x$COMPILE_TYPE" = xcross; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: You are doing a cross-compilation. Check that you have all target platform libraries installed." >&5
+$as_echo "$as_me: You are doing a cross-compilation. Check that you have all target platform libraries installed." >&6;}
+  fi
+  as_fn_error $? "Cannot continue." "$LINENO" 5
+
+fi
+
+done
+
+
 # The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
@@ -12647,85 +14511,28 @@
 _ACEOF
 
 
-CXXFLAGS="$OLD_CXXFLAGS"
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-# keep track of c/cxx flags that we added outselves...
-#   to prevent emitting warning...
-ADDED_CFLAGS=
-ADDED_CXXFLAGS=
-ADDED_LDFLAGS=
-
-if test "x$ac_cv_sizeof_int_p" = x0; then
-    # The test failed, lets pick the assumed value.
-    ARCH_DATA_MODEL=$OPENJDK_TARGET_CPU_BITS
-else
-    ARCH_DATA_MODEL=`expr 8 \* $ac_cv_sizeof_int_p`
-
-    if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
-       ADDED_CFLAGS=" -m${with_target_bits}"
-       ADDED_CXXFLAGS=" -m${with_target_bits}"
-       ADDED_LDFLAGS=" -m${with_target_bits}"
-
-       CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
-       CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
-       LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
-
-       CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
-       CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
-       LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
-    fi
-fi
-
-if test "x$ARCH_DATA_MODEL" = x64; then
-    A_LP64="LP64:="
-    ADD_LP64="-D_LP64=1"
-fi
+
+if test "x$SIZEOF_INT_P" != "x$ac_cv_sizeof_int_p"; then
+  # Workaround autoconf bug, see http://lists.gnu.org/archive/html/autoconf/2010-07/msg00004.html
+  SIZEOF_INT_P="$ac_cv_sizeof_int_p"
+fi
+
+if test "x$SIZEOF_INT_P" = x; then
+    # The test failed, lets stick to the assumed value.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS." >&5
+$as_echo "$as_me: WARNING: The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS." >&2;}
+else
+    TESTED_TARGET_CPU_BITS=`expr 8 \* $SIZEOF_INT_P`
+
+    if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
+        as_fn_error $? "The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)" "$LINENO" 5
+    fi
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for target address size" >&5
 $as_echo_n "checking for target address size... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ARCH_DATA_MODEL bits" >&5
-$as_echo "$ARCH_DATA_MODEL bits" >&6; }
-LP64=$A_LP64
-
-
-
-if test "x$ARCH_DATA_MODEL" != "x$OPENJDK_TARGET_CPU_BITS"; then
-    as_fn_error $? "The tested number of bits in the target ($ARCH_DATA_MODEL) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)" "$LINENO" 5
-fi
-
-#
-# NOTE: check for -mstackrealign needs to be below potential addition of -m32
-#
-if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
-    # While waiting for a better solution, the current workaround is to use -mstackrealign.
-    CFLAGS="$CFLAGS -mstackrealign"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 32-bit compiler supports -mstackrealign" >&5
-$as_echo_n "checking if 32-bit compiler supports -mstackrealign... " >&6; }
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-int main() { return 0; }
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-
-		        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-else
-
-		        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-	                as_fn_error $? "The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path." "$LINENO" 5
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENJDK_TARGET_CPU_BITS bits" >&5
+$as_echo "$OPENJDK_TARGET_CPU_BITS bits" >&6; }
 
 
 ###############################################################################
@@ -12956,15 +14763,9 @@
 if test "x$ENDIAN" = xuniversal_endianness; then
     as_fn_error $? "Building with both big and little endianness is not supported" "$LINENO" 5
 fi
-if test "x$ENDIAN" = xunknown; then
-    ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
-fi
 if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)" >&5
-$as_echo "$as_me: WARNING: The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)" >&2;}
-    ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
-fi
-
+    as_fn_error $? "The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)" "$LINENO" 5
+fi
 
 
 # Configure flags for the tools
@@ -12990,15 +14791,13 @@
     SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=$1'
     C_FLAG_REORDER=''
     CXX_FLAG_REORDER=''
-    SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN/$1'
+    SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN$1'
+    SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN$1'
     LD="$CC"
     LDEXE="$CC"
     LDCXX="$CXX"
     LDEXECXX="$CXX"
     POST_STRIP_CMD="$STRIP -g"
-    if test "x$JDK_VARIANT" = xembedded; then
-        POST_STRIP_CMD="$STRIP --strip-unneeded"
-    fi
 
     # Linking is different on MacOSX
     if test "x$OPENJDK_BUILD_OS" = xmacosx; then
@@ -13011,6 +14810,7 @@
         SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/$1'
         SET_SHARED_LIBRARY_MAPFILE=''
         SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
+        SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
         POST_STRIP_CMD="$STRIP -S"
     fi
 else
@@ -13021,7 +14821,7 @@
         LIBRARY_PREFIX=lib
         SHARED_LIBRARY='lib$1.so'
         STATIC_LIBRARY='lib$1.a'
-        SHARED_LIBRARY_FLAGS="-z defs -xildoff -ztext -G"
+        SHARED_LIBRARY_FLAGS="-G"
         SHARED_LIBRARY_SUFFIX='.so'
         STATIC_LIBRARY_SUFFIX='.a'
         OBJ_SUFFIX='.o'
@@ -13030,7 +14830,8 @@
         SET_SHARED_LIBRARY_MAPFILE='-M$1'
 	C_FLAG_REORDER='-xF'
 	CXX_FLAG_REORDER='-xF'
-        SET_SHARED_LIBRARY_ORIGIN='-R \$$$$ORIGIN/$1'
+        SET_SHARED_LIBRARY_ORIGIN='-R\$$$$ORIGIN$1'
+        SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
         CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
         CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
         CFLAGS_JDKLIB_EXTRA='-xstrconst'
@@ -13052,8 +14853,10 @@
         SET_SHARED_LIBRARY_NAME=''
         SET_SHARED_LIBRARY_MAPFILE=''
         SET_SHARED_LIBRARY_ORIGIN=''
-    fi
-fi
+        SET_EXECUTABLE_ORIGIN=''
+    fi
+fi
+
 
 
 
@@ -13081,6 +14884,36 @@
 # Setup the opt flags for different compilers
 # and different operating systems.
 #
+
+#
+# NOTE: check for -mstackrealign needs to be below potential addition of -m32
+#
+if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
+    # While waiting for a better solution, the current workaround is to use -mstackrealign.
+    CFLAGS="$CFLAGS -mstackrealign"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 32-bit compiler supports -mstackrealign" >&5
+$as_echo_n "checking if 32-bit compiler supports -mstackrealign... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int main() { return 0; }
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+		        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+else
+
+		        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	                as_fn_error $? "The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path." "$LINENO" 5
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+
 C_FLAG_DEPS="-MMD -MF"
 CXX_FLAG_DEPS="-MMD -MF"
 
@@ -13105,7 +14938,7 @@
 	    CXXFLAGS_DEBUG_SYMBOLS="-g"
 	    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
 	       CFLAGS_DEBUG_SYMBOLS="-g1"
-	       CXXFLAGS_DEBUG_SYMBOLSG="-g1"
+	       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 	    fi
 	    ;;
 	esac
@@ -13117,52 +14950,56 @@
         #
         # Forte has different names for this with their C++ compiler...
         #
-	C_FLAG_DEPS="-xMMD -xMF"
-	CXX_FLAG_DEPS="-xMMD -xMF"
-
-# Extra options used with HIGHEST
-#
-# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
-#          done with care, there are some assumptions below that need to
-#          be understood about the use of pointers, and IEEE behavior.
-#
-# Use non-standard floating point mode (not IEEE 754)
-CC_HIGHEST="$CC_HIGHEST -fns"
-# Do some simplification of floating point arithmetic (not IEEE 754)
-CC_HIGHEST="$CC_HIGHEST -fsimple"
-# Use single precision floating point with 'float'
-CC_HIGHEST="$CC_HIGHEST -fsingle"
-# Assume memory references via basic pointer types do not alias
-#   (Source with excessing pointer casting and data access with mixed
-#    pointer types are not recommended)
-CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
-# Use intrinsic or inline versions for math/std functions
-#   (If you expect perfect errno behavior, do not use this)
-CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
-# Loop data dependency optimizations (need -xO3 or higher)
-CC_HIGHEST="$CC_HIGHEST -xdepend"
-# Pointer parameters to functions do not overlap
-#   (Similar to -xalias_level=basic usage, but less obvious sometimes.
-#    If you pass in multiple pointers to the same data, do not use this)
-CC_HIGHEST="$CC_HIGHEST -xrestrict"
-# Inline some library routines
-#   (If you expect perfect errno behavior, do not use this)
-CC_HIGHEST="$CC_HIGHEST -xlibmil"
-# Use optimized math routines
-#   (If you expect perfect errno behavior, do not use this)
-#  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
-#CC_HIGHEST="$CC_HIGHEST -xlibmopt"
-
-        case $LEGACY_OPENJDK_TARGET_CPU1 in
-          i586)
-            C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xchip=pentium"
-            C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
-            C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
-            C_O_FLAG_NONE=""
-            CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xchip=pentium"
-            CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz"
-            CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz"
-            CXX_O_FLAG_NONE=""
+        C_FLAG_DEPS="-xMMD -xMF"
+        CXX_FLAG_DEPS="-xMMD -xMF"
+
+        # Extra options used with HIGHEST
+        #
+        # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
+        #          done with care, there are some assumptions below that need to
+        #          be understood about the use of pointers, and IEEE behavior.
+        #
+        # Use non-standard floating point mode (not IEEE 754)
+        CC_HIGHEST="$CC_HIGHEST -fns"
+        # Do some simplification of floating point arithmetic (not IEEE 754)
+        CC_HIGHEST="$CC_HIGHEST -fsimple"
+        # Use single precision floating point with 'float'
+        CC_HIGHEST="$CC_HIGHEST -fsingle"
+        # Assume memory references via basic pointer types do not alias
+        #   (Source with excessing pointer casting and data access with mixed
+        #    pointer types are not recommended)
+        CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
+        # Use intrinsic or inline versions for math/std functions
+        #   (If you expect perfect errno behavior, do not use this)
+        CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
+        # Loop data dependency optimizations (need -xO3 or higher)
+        CC_HIGHEST="$CC_HIGHEST -xdepend"
+        # Pointer parameters to functions do not overlap
+        #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
+        #    If you pass in multiple pointers to the same data, do not use this)
+        CC_HIGHEST="$CC_HIGHEST -xrestrict"
+        # Inline some library routines
+        #   (If you expect perfect errno behavior, do not use this)
+        CC_HIGHEST="$CC_HIGHEST -xlibmil"
+        # Use optimized math routines
+        #   (If you expect perfect errno behavior, do not use this)
+        #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
+        #CC_HIGHEST="$CC_HIGHEST -xlibmopt"
+
+        case $OPENJDK_TARGET_CPU_ARCH in
+          x86)
+            C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
+            C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
+            C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
+            C_O_FLAG_NONE="-xregs=no%frameptr"
+            CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
+            CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
+            CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
+            CXX_O_FLAG_NONE="-xregs=no%frameptr"
+            if test "x$OPENJDK_TARGET_CPU" = xx86; then
+               C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
+               CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
+            fi
             ;;
           sparc)
             CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
@@ -13186,9 +15023,11 @@
     ;;
   CL )
     D_FLAG=
-    C_O_FLAG_HI="-O2"
+    C_O_FLAG_HIGHEST="-O2"
+    C_O_FLAG_HI="-O1"
     C_O_FLAG_NORM="-O1"
     C_O_FLAG_NONE="-Od"
+    CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
     CXX_O_FLAG_HI="$C_O_FLAG_HI"
     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
@@ -13217,18 +15056,18 @@
 
 
 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags\"" >&5
-$as_echo "$as_me: WARNING: Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags\"" >&2;}
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags" >&5
+$as_echo "$as_me: WARNING: Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags" >&2;}
 fi
 
 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags\"" >&5
-$as_echo "$as_me: WARNING: Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags\"" >&2;}
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags" >&5
+$as_echo "$as_me: WARNING: Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags" >&2;}
 fi
 
 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags\"" >&5
-$as_echo "$as_me: WARNING: Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags\"" >&2;}
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags" >&5
+$as_echo "$as_me: WARNING: Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags" >&2;}
 fi
 
 
@@ -13256,6 +15095,15 @@
 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
 
+# Hotspot needs these set in their legacy form
+LEGACY_EXTRA_CFLAGS=$with_extra_cflags
+LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
+LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
+
+
+
+
+
 ###############################################################################
 #
 # Now setup the CFLAGS and LDFLAGS for the JDK build.
@@ -13281,19 +15129,30 @@
 	  esac
           ;;
       ossc )
-      	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -norunpath -xnolib"
-      	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX"
+          CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
+          case $OPENJDK_TARGET_CPU_ARCH in
+          x86 )
+            CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -Di386"
+       	    CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
+          ;;
+          esac
+
+      	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
+      	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
+
+          LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
+          LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
           ;;
       cl )
           CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
                -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
 	       -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 	       -DWIN32 -DIAL"
-          case $LEGACY_OPENJDK_TARGET_CPU1 in
-              i?86 )
+          case $OPENJDK_TARGET_CPU in
+              x86 )
                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
                   ;;
-              amd64 )
+              x86_64 )
                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
                   ;;
           esac
@@ -13301,24 +15160,6 @@
 esac
 
 ###############################################################################
-#
-# Cross-compile arch specific flags
-
-#
-if test "x$JDK_VARIANT" = "xembedded"; then
-   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DJAVASE_EMBEDDED"
-fi
-
-case $OPENJDK_TARGET_CPU_ARCH in
-arm )
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
-    ;;
-ppc )
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
-    ;;
-esac
-
-###############################################################################
 
 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
 
@@ -13326,11 +15167,17 @@
 PACKAGE_PATH=/opt/local
 
 
-# Sometimes we use a cpu dir (.../lib/amd64/server)
-# Sometimes not (.../lib/server)
-LIBARCHDIR="$LEGACY_OPENJDK_TARGET_CPU2/"
-if test "x$ENDIAN" = xlittle; then
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
+if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
+    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
+    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
+    #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
+    #   Note: -Dmacro         is the same as    #define macro 1
+    #         -Dmacro=	    is the same as    #define macro
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
+    else
+        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
+    fi
 else
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
 fi
@@ -13345,27 +15192,29 @@
 fi
 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
-    LIBARCHDIR=""
 fi
 if test "x$OPENJDK_TARGET_OS" = xbsd; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
 fi
 if test "x$DEBUG_LEVEL" = xrelease; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
+    fi
 else
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
 fi
 
-CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$LEGACY_OPENJDK_TARGET_CPU1\"' -D$LEGACY_OPENJDK_TARGET_CPU1"
+CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'"
 
 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
         -I${JDK_OUTPUTDIR}/include \
         -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
         -I${JDK_TOPDIR}/src/share/javavm/export \
-        -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/javavm/export \
+        -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/javavm/export \
         -I${JDK_TOPDIR}/src/share/native/common \
-        -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/native/common"
+        -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
 
 # The shared libraries are compiled using the picflag.
 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
@@ -13385,7 +15234,7 @@
 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
 if test "x$COMPILER_TYPE" = xCL; then
     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
-    if test "x$LEGACY_OPENJDK_TARGET_CPU1" = xi586; then
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then
         LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
     fi
     # TODO: make -debug optional "--disable-full-debug-symbols"
@@ -13413,20 +15262,18 @@
     fi
 
     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
-                    -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}server \
-                    -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}client \
-  	            -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}"
-    LDFLAGS_JDKLIB_SUFFIX="-ljvm -ljava"
+                    -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server \
+                    -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client \
+                    -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
+
+    LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
     if test "x$COMPILER_NAME" = xossc; then
         LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
     fi
 
-    # Only the jli library is explicitly linked when the launchers are built.
-    # The libjvm is then dynamically loaded/linked by the launcher.
     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
-    if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then
-       LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}jli"
-       LDFLAGS_JDKEXE_SUFFIX="-ljli"
+    if test "x$OPENJDK_TARGET_OS" = xlinux; then
+        LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
     fi
 fi
 
@@ -13459,6 +15306,7 @@
 
 
 
+
 # After we have toolchain, we can compile the uncygdrive helper
 
 # When using cygwin, we need a wrapper binary that renames
@@ -13498,6 +15346,8 @@
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
     rm -f $OUTPUT_ROOT/uncygdrive?.??? $OUTPUT_ROOT/uncygdrive.obj
+    # The path to uncygdrive to use should be Unix-style
+    UNCYGDRIVE="$OUTPUT_ROOT/uncygdrive.exe"
 fi
 
 
@@ -13517,11 +15367,6 @@
    ENABLE_DEBUG_SYMBOLS=no
 fi
 
-# default for embedded is no...
-if test "x$JDK_VARIANT" = "xembedded"; then
-   ENABLE_DEBUG_SYMBOLS=no
-fi
-
 # Check whether --enable-debug-symbols was given.
 if test "${enable_debug_symbols+set}" = set; then :
   enableval=$enable_debug_symbols; ENABLE_DEBUG_SYMBOLS=${enable_debug_symbols}
@@ -13644,6 +15489,10 @@
     FREETYPE2_NOT_NEEDED=yes
 fi
 
+if test "x$SUPPORT_HEADFUL" = xno; then
+    X11_NOT_NEEDED=yes
+fi
+
 ###############################################################################
 #
 # Check for MacOSX support for OpenJDK. If this exists, try to build a JVM
@@ -14817,7 +16666,11 @@
     HAS_SPACE=`echo "$with_freetype" | grep " "`
     if test "x$HAS_SPACE" != x; then
         if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+            # First convert it to DOS-style, short mode (no spaces)
             with_freetype=`$CYGPATH -s -m -a "$with_freetype"`
+            # Now it's case insensitive; let's make it lowercase to improve readability
+            with_freetype=`$ECHO "$with_freetype" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
+            # Now convert it back to Unix-stile (cygpath)
             with_freetype=`$CYGPATH -u "$with_freetype"`
         else
             as_fn_error $? "You cannot have spaces in the path to freetype! \"$with_freetype\"" "$LINENO" 5
@@ -15677,9 +17530,7 @@
 
 ###############################################################################
 LIBZIP_CAN_USE_MMAP=true
-if test "x$JDK_VARIANT" = "xembedded"; then
-   LIBZIP_CAN_USE_MMAP=false
-fi
+
 
 
 ###############################################################################
@@ -15956,7 +17807,7 @@
 
 # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
 if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then
-    LIBCXX="/usr/lib${LEGACY_OPENJDK_TARGET_CPU3}/libCrun.so.1"
+    LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
 fi
 
 # TODO better (platform agnostic) test
@@ -15975,7 +17826,7 @@
 ###############################################################################
 
 
-HOTSPOT_MAKE_ARGS="ALT_OUTPUTDIR=$HOTSPOT_OUTPUTDIR ALT_EXPORT_PATH=$HOTSPOT_DIST $HOTSPOT_TARGET"
+HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET"
 
 
 # The name of the Service Agent jar.
@@ -16011,27 +17862,19 @@
     FOUND_CORES=no
 
     if test -f /proc/cpuinfo; then
-        # Looks like a Linux system
+        # Looks like a Linux (or cygwin) system
         NUM_CORES=`cat /proc/cpuinfo  | grep -c processor`
         FOUND_CORES=yes
-    fi
-
-    if test -x /usr/sbin/psrinfo; then
+    elif test -x /usr/sbin/psrinfo; then
         # Looks like a Solaris system
         NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line`
         FOUND_CORES=yes
-    fi
-
-    if test -x /usr/sbin/system_profiler; then
+    elif test -x /usr/sbin/system_profiler; then
         # Looks like a MacOSX system
         NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk  '{print $5}'`
         FOUND_CORES=yes
     fi
 
-    if test "x$build_os" = xwindows; then
-        NUM_CORES=4
-    fi
-
     # For c/c++ code we run twice as many concurrent build
     # jobs than we have cores, otherwise we will stall on io.
     CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2`
@@ -16065,31 +17908,26 @@
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for memory size" >&5
 $as_echo_n "checking for memory size... " >&6; }
-    # Default to 1024MB
+    # Default to 1024 MB
     MEMORY_SIZE=1024
     FOUND_MEM=no
 
-    if test -f /proc/cpuinfo; then
-        # Looks like a Linux system
+    if test -f /proc/meminfo; then
+        # Looks like a Linux (or cygwin) system
         MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`
         MEMORY_SIZE=`expr $MEMORY_SIZE / 1024`
         FOUND_MEM=yes
-    fi
-
-    if test -x /usr/sbin/prtconf; then
+    elif test -x /usr/sbin/prtconf; then
         # Looks like a Solaris system
         MEMORY_SIZE=`/usr/sbin/prtconf | grep "Memory size" | awk '{ print $3 }'`
         FOUND_MEM=yes
-    fi
-
-    if test -x /usr/sbin/system_profiler; then
+    elif test -x /usr/sbin/system_profiler; then
         # Looks like a MacOSX system
         MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk  '{print $2}'`
         MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024`
         FOUND_MEM=yes
-    fi
-
-    if test "x$build_os" = xwindows; then
+    elif test "x$build_os" = xwindows; then
+        # Windows, but without cygwin
         MEMORY_SIZE=`systeminfo | grep 'Total Physical Memory:' | awk '{ print $4 }' | sed 's/,//'`
         FOUND_MEM=yes
     fi
@@ -16098,8 +17936,8 @@
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMORY_SIZE MB" >&5
 $as_echo "$MEMORY_SIZE MB" >&6; }
     else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not detect memory size defaulting to 1024MB!" >&5
-$as_echo "could not detect memory size defaulting to 1024MB!" >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not detect memory size defaulting to 1024 MB!" >&5
+$as_echo "could not detect memory size defaulting to 1024 MB!" >&6; }
     fi
 
 else
@@ -16111,82 +17949,52 @@
 # Setup smart javac (after cores and memory have been setup)
 
 
-# Check whether --with-server-java was given.
-if test "${with_server_java+set}" = set; then :
-  withval=$with_server_java;
-fi
-
-
-if test "x$with_server_java" != x; then
-    SERVER_JAVA="$with_server_java"
-    FOUND_VERSION=`$SERVER_JAVA -version 2>&1 | grep " version \""`
+# Check whether --with-sjavac-server-java was given.
+if test "${with_sjavac_server_java+set}" = set; then :
+  withval=$with_sjavac_server_java;
+fi
+
+
+if test "x$with_sjavac_server_java" != x; then
+    SJAVAC_SERVER_JAVA="$with_sjavac_server_java"
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" = x; then
-        as_fn_error $? "Could not execute server java: $SERVER_JAVA" "$LINENO" 5
-    fi
-else
-    SERVER_JAVA=""
+        as_fn_error $? "Could not execute server java: $SJAVAC_SERVER_JAVA" "$LINENO" 5
+    fi
+else
+    SJAVAC_SERVER_JAVA=""
     # Hotspot specific options.
 
-    # Test if -XX:+UseParallelOldGC is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -XX:+UseParallelOldGC to SERVER_JAVA
-    FOUND_WARN=`$JAVA -XX:+UseParallelOldGC -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -XX:+UseParallelOldGC -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -XX:+UseParallelOldGC"
-    fi
-
-
     # Test if -verbosegc is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -verbosegc to SERVER_JAVA
+    # If so, then append -verbosegc to SJAVAC_SERVER_JAVA
     FOUND_WARN=`$JAVA -verbosegc -version 2>&1 | grep -i warn`
     FOUND_VERSION=`$JAVA -verbosegc -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -verbosegc"
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -verbosegc"
     fi
 
     # JRockit specific options.
 
     # Test if -Xverbose:gc is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -Xverbose:gc to SERVER_JAVA
+    # If so, then append -Xverbose:gc to SJAVAC_SERVER_JAVA
     FOUND_WARN=`$JAVA -Xverbose:gc -version 2>&1 | grep -i warn`
     FOUND_VERSION=`$JAVA -Xverbose:gc -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xverbose:gc"
-    fi
-
-    SERVER_JAVA="$JAVA $SERVER_JAVA"
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use shared server for javac" >&5
-$as_echo_n "checking whether to use shared server for javac... " >&6; }
-# Check whether --enable-javac-server was given.
-if test "${enable_javac_server+set}" = set; then :
-  enableval=$enable_javac_server; ENABLE_JAVAC_SERVER="${enableval}"
-else
-  ENABLE_JAVAC_SERVER='no'
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ENABLE_JAVAC_SERVER" >&5
-$as_echo "$ENABLE_JAVAC_SERVER" >&6; }
-if test "x$ENABLE_JAVAC_SERVER" = xyes; then
-    JAVAC_USE_REMOTE=true
-    JAVAC_SERVERS="$OUTPUT_ROOT/javacservers"
-else
-    JAVAC_USE_REMOTE=false
-    JAVAC_SERVERS=
-fi
-
-
-
-
-# Check whether --with-javac-server-cores was given.
-if test "${with_javac_server_cores+set}" = set; then :
-  withval=$with_javac_server_cores;
-fi
-
-if test "x$with_javac_server_cores" != x; then
-    JAVAC_SERVER_CORES="$with_javac_server_cores"
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xverbose:gc"
+    fi
+
+    SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA"
+fi
+
+
+
+# Check whether --with-sjavac-server-cores was given.
+if test "${with_sjavac_server_cores+set}" = set; then :
+  withval=$with_sjavac_server_cores;
+fi
+
+if test "x$with_sjavac_server_cores" != x; then
+    SJAVAC_SERVER_CORES="$with_sjavac_server_cores"
 else
     if test "$NUM_CORES" -gt 16; then
         # We set this arbitrary limit because we want to limit the heap
@@ -16194,237 +18002,152 @@
         # In the future we will make the javac compilers in the server
         # share more and more state, thus enabling us to use more and
         # more concurrent threads in the server.
-        JAVAC_SERVER_CORES="16"
-    else
-        JAVAC_SERVER_CORES="$NUM_CORES"
+        SJAVAC_SERVER_CORES="16"
+    else
+        SJAVAC_SERVER_CORES="$NUM_CORES"
     fi
 
     if test "$MEMORY_SIZE" -gt "17000"; then
         MAX_HEAP_MEM=10000
 
-    # Test if -d64 is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -d64 to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -d64 -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -d64 -version 2>&1 | grep " version \""`
+    # Test if -d64 is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -d64 to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -d64"
-    fi
-
-
-    # Test if -Xms10G -Xmx10G is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xms10G -Xmx10G to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xms10G -Xmx10G -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xms10G -Xmx10G -version 2>&1 | grep " version \""`
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -d64"
+    fi
+
+
+    # Test if -Xms10G -Xmx10G is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -Xms10G -Xmx10G to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms10G -Xmx10G -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms10G -Xmx10G -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xms10G -Xmx10G"
-    fi
-
-
-    # Test if -Xmn2G is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xmn2G to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xmn2G -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xmn2G -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xmn2G"
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms10G -Xmx10G"
     fi
 
     elif test "$MEMORY_SIZE" -gt "10000"; then
         MAX_HEAP_MEM=6000
 
-    # Test if -d64 is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -d64 to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -d64 -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -d64 -version 2>&1 | grep " version \""`
+    # Test if -d64 is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -d64 to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -d64"
-    fi
-
-
-    # Test if -Xms6G -Xmx6G is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xms6G -Xmx6G to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xms6G -Xmx6G -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xms6G -Xmx6G -version 2>&1 | grep " version \""`
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -d64"
+    fi
+
+
+    # Test if -Xms6G -Xmx6G is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -Xms6G -Xmx6G to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms6G -Xmx6G -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms6G -Xmx6G -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xms6G -Xmx6G"
-    fi
-
-
-    # Test if -Xmn1G is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xmn1G to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xmn1G -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xmn1G -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xmn1G"
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms6G -Xmx6G"
     fi
 
     elif test "$MEMORY_SIZE" -gt "5000"; then
         MAX_HEAP_MEM=3000
 
-    # Test if -d64 is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -d64 to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -d64 -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -d64 -version 2>&1 | grep " version \""`
+    # Test if -d64 is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -d64 to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -d64"
-    fi
-
-
-    # Test if -Xms1G -Xmx3G is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xms1G -Xmx3G to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xms1G -Xmx3G -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xms1G -Xmx3G -version 2>&1 | grep " version \""`
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -d64"
+    fi
+
+
+    # Test if -Xms1G -Xmx3G is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -Xms1G -Xmx3G to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx3G -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx3G -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xms1G -Xmx3G"
-    fi
-
-
-    # Test if -Xmn256M is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xmn256M to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xmn256M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xmn256M -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xmn256M"
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms1G -Xmx3G"
     fi
 
     elif test "$MEMORY_SIZE" -gt "3800"; then
         MAX_HEAP_MEM=2500
 
-    # Test if -Xms1G -Xmx2500M is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xms1G -Xmx2500M to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xms1G -Xmx2500M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xms1G -Xmx2500M -version 2>&1 | grep " version \""`
+    # Test if -Xms1G -Xmx2500M is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -Xms1G -Xmx2500M to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xms1G -Xmx2500M"
-    fi
-
-
-    # Test if -Xmn256M is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xmn256M to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xmn256M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xmn256M -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xmn256M"
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M"
     fi
 
     elif test "$MEMORY_SIZE" -gt "1900"; then
         MAX_HEAP_MEM=1200
 
-    # Test if -Xms700M -Xmx1200M is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xms700M -Xmx1200M to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xms700M -Xmx1200M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xms700M -Xmx1200M -version 2>&1 | grep " version \""`
+    # Test if -Xms700M -Xmx1400M is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -Xms700M -Xmx1400M to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms700M -Xmx1400M -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms700M -Xmx1400M -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xms700M -Xmx1200M"
-    fi
-
-
-    # Test if -Xmn256M is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xmn256M to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xmn256M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xmn256M -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xmn256M"
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms700M -Xmx1400M"
     fi
 
     elif test "$MEMORY_SIZE" -gt "1000"; then
         MAX_HEAP_MEM=900
 
-    # Test if -Xms400M -Xmx900M is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xms400M -Xmx900M to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xms400M -Xmx900M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xms400M -Xmx900M -version 2>&1 | grep " version \""`
+    # Test if -Xms400M -Xmx1100M is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -Xms400M -Xmx1100M to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xms400M -Xmx900M"
-    fi
-
-
-    # Test if -Xmn128M is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xmn128M to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xmn128M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xmn128M -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xmn128M"
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M"
     fi
 
     else
         MAX_HEAP_MEM=512
 
-    # Test if -Xms256M -Xmx512M is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xms256M -Xmx512M to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xms256M -Xmx512M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xms256M -Xmx512M -version 2>&1 | grep " version \""`
+    # Test if -Xms256M -Xmx512M is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -Xms256M -Xmx512M to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms256M -Xmx512M -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms256M -Xmx512M -version 2>&1 | grep " version \""`
+    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms256M -Xmx512M"
+    fi
+
+    fi
+
+
+    # Test if -XX:PermSize=32m is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -XX:PermSize=32m to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -XX:PermSize=32m -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -XX:PermSize=32m -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xms256M -Xmx512M"
-    fi
-
-
-    # Test if -Xmn128M is a valid argument to $SERVER_JAVA (often is $JAVA passed as $SERVER_JAVA)
-    # If so, then append -Xmn128M to SERVER_JAVA
-    FOUND_WARN=`$SERVER_JAVA -Xmn128M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SERVER_JAVA -Xmn128M -version 2>&1 | grep " version \""`
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -XX:PermSize=32m"
+    fi
+
+
+    # Test if -XX:MaxPermSize=160m is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -XX:MaxPermSize=160m to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -XX:MaxPermSize=160m -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -XX:MaxPermSize=160m -version 2>&1 | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SERVER_JAVA="$SERVER_JAVA -Xmn128M"
-    fi
-
-    fi
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -XX:MaxPermSize=160m"
+    fi
+
+
+    # Test if -XX:ThreadStackSize=$STACK_SIZE is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
+    # If so, then append -XX:ThreadStackSize=$STACK_SIZE to SJAVAC_SERVER_JAVA
+    FOUND_WARN=`$SJAVAC_SERVER_JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1 | grep -i warn`
+    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1 | grep " version \""`
+    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -XX:ThreadStackSize=$STACK_SIZE"
+    fi
+
 
     MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501`
-    if test "$JAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then
+    if test "$SJAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: checking if number of server cores must be reduced" >&5
 $as_echo_n "checking if number of server cores must be reduced... " >&6; }
-        JAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP"
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, to $JAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB" >&5
-$as_echo "yes, to $JAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB" >&6; }
-    fi
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to track dependencies between Java packages" >&5
-$as_echo_n "checking whether to track dependencies between Java packages... " >&6; }
-# Check whether --enable-javac-deps was given.
-if test "${enable_javac_deps+set}" = set; then :
-  enableval=$enable_javac_deps; ENABLE_JAVAC_DEPS="${enableval}"
-else
-  ENABLE_JAVAC_DEPS='no'
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ENABLE_JAVAC_DEPS" >&5
-$as_echo "$ENABLE_JAVAC_DEPS" >&6; }
-if test "x$ENABLE_JAVAC_DEPS" = xyes; then
-    JAVAC_USE_DEPS=true
-else
-    JAVAC_USE_DEPS=false
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use multiple cores for javac compilation" >&5
-$as_echo_n "checking whether to use multiple cores for javac compilation... " >&6; }
-# Check whether --enable-javac-multi-core was given.
-if test "${enable_javac_multi_core+set}" = set; then :
-  enableval=$enable_javac_multi_core; ENABLE_JAVAC_MULTICORE="${enableval}"
-else
-  ENABLE_JAVAC_MULTICORE='no'
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ENABLE_JAVAC_MULTICORE" >&5
-$as_echo "$ENABLE_JAVAC_MULTICORE" >&6; }
-if test "x$ENABLE_JAVAC_MULTICORE" = xyes; then
-    JAVAC_USE_MODE=MULTI_CORE_CONCURRENT
-else
-    JAVAC_USE_MODE=SINGLE_THREADED_BATCH
-    if test "x$ENABLE_JAVAC_DEPS" = xyes; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Dependency tracking is not supported with single threaded batch compiles of Java source roots. Please add --disable-javac-deps to your configure options." >&5
-$as_echo "$as_me: WARNING: Dependency tracking is not supported with single threaded batch compiles of Java source roots. Please add --disable-javac-deps to your configure options." >&2;}
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Disabling dependency tracking for you now." >&5
-$as_echo "$as_me: WARNING: Disabling dependency tracking for you now." >&2;}
-        JAVAC_USE_DEPS=false
-    fi
-    if test "x$ENABLE_JAVAC_SERVER" = xyes; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The javac server will not be used since single threaded batch compiles are run within their own JVM. Please add --disable-javac-server to your configure options." >&5
-$as_echo "$as_me: WARNING: The javac server will not be used since single threaded batch compiles are run within their own JVM. Please add --disable-javac-server to your configure options." >&2;}
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Disabling javac server for you now." >&5
-$as_echo "$as_me: WARNING: Disabling javac server for you now." >&2;}
-        JAVAC_USE_REMOTE=false
+        SJAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP"
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB" >&5
+$as_echo "yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB" >&6; }
     fi
 fi
 
@@ -16442,6 +18165,13 @@
 $as_echo "$ENABLE_SJAVAC" >&6; }
 
 
+if test "x$ENABLE_SJAVAC" = xyes; then
+    SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers"
+else
+    SJAVAC_SERVER_DIR=
+fi
+
+
 
 
 # Can the C/C++ compiler use precompiled headers?
@@ -16666,7 +18396,7 @@
 
 
 
-# At the end, call the closed hook. (Dummy macro if no closed sources available)
+# At the end, call the custom hook. (Dummy macro if no custom sources available)
 
 
 # We're messing a bit with internal autoconf variables to put the config.status
@@ -17365,6 +19095,9 @@
   case $ac_config_target in
     "$OUTPUT_ROOT/config.h") CONFIG_HEADERS="$CONFIG_HEADERS $OUTPUT_ROOT/config.h:$AUTOCONF_DIR/config.h.in" ;;
     "$OUTPUT_ROOT/spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in" ;;
+    "$OUTPUT_ROOT/hotspot-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in" ;;
+    "$OUTPUT_ROOT/bootcycle-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in" ;;
+    "$OUTPUT_ROOT/compare.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in" ;;
     "$OUTPUT_ROOT/spec.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in" ;;
     "$OUTPUT_ROOT/Makefile") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in" ;;
 
@@ -17946,6 +19679,9 @@
 fi
 
 
+# Make the compare script executable
+$CHMOD +x $OUTPUT_ROOT/compare.sh
+
 # Finally output some useful information to the user
 
 # Finally output some useful information to the user
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/autoconf/hotspot-spec.gmk.in	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,90 @@
+#
+# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  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.
+#
+
+
+# Chaining of spec files
+HOTSPOT_SPEC:=$(dir $(SPEC))hotspot-spec.gmk
+override SPEC=$(HOTSPOT_SPEC)
+# Now include the base spec.gmk file
+include $(BASE_SPEC)
+
+# Additional legacy variables defined for Hotspot
+
+@SET_OPENJDK@
+
+# Legacy defines controlled by the SUPPORT_HEADLESS and SUPPORT_HEADFUL options.
+@BUILD_HEADLESS@
+
+# Legacy setting: OPT or DBG
+VARIANT:=@VARIANT@
+# Legacy setting: true or false
+FASTDEBUG:=@FASTDEBUG@
+# Legacy setting: debugging the class files?
+DEBUG_CLASSFILES:=@DEBUG_CLASSFILES@
+
+ALT_CUPS_HEADERS_PATH:=$(patsubst -I%,%,$(filter -I%,@CUPS_CFLAGS@))
+
+# The HOSTCC/HOSTCXX is Hotspot terminology for the BUILD_CC/BUILD_CXX, i.e. the
+# compiler that produces code that can be run on the build platform.
+HOSTCC:=@UNCYGDRIVE@ @BUILD_CC@
+HOSTCXX:=@UNCYGDRIVE@ @BUILD_CXX@
+
+####################################################
+#
+# Legacy Hotspot support
+
+# If cross compiling, then define CROSS_COMPILE_ARCH:=cpu_name here.
+@DEFINE_CROSS_COMPILE_ARCH@
+
+# Old name for OPENJDK_TARGET_OS (aix,bsd,hpux,linux,macosx,solaris,windows etc)
+PLATFORM=$(OPENJDK_TARGET_OS)
+# 32 or 64 bit
+ARCH_DATA_MODEL=$(OPENJDK_TARGET_CPU_BITS)
+
+ALT_BOOTDIR=$(BOOT_JDK)
+# Can be /sparcv9 or /amd64 on Solaris
+ISA_DIR=$(OPENJDK_TARGET_CPU_ISADIR)
+# Yet another name for arch used for an extra subdir below the jvm lib.
+# Uses i386 and amd64, instead of x86 and x86_64.
+LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB)
+# Old name for OPENJDK_TARGET_CPU, uses i586 and amd64, instead of x86 and x86_64.
+ARCH=$(OPENJDK_TARGET_CPU_LEGACY)
+# Legacy setting for building for a 64 bit machine.
+# If yes then this expands to _LP64:=1
+@LP64@
+
+ALT_OUTPUTDIR=$(HOTSPOT_OUTPUTDIR)
+ALT_EXPORT_PATH=$(HOTSPOT_DIST)
+
+HOTSPOT_MAKE_ARGS:=@HOTSPOT_MAKE_ARGS@
+# This is used from the libjvm build for C/C++ code.
+HOTSPOT_BUILD_JOBS:=@CONCURRENT_BUILD_JOBS@
+# Control wether Hotspot runs Queens test after building
+TEST_IN_BUILD=@TEST_IN_BUILD@
+
+
+EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@
+EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@
+EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@
--- a/common/autoconf/jdk-options.m4	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/jdk-options.m4	Tue Sep 25 11:48:00 2012 -0700
@@ -30,7 +30,7 @@
 # Check which variant of the JDK that we want to build.
 # Currently we have:
 #    normal:   standard edition   
-#    embedded: cut down to a smaller footprint
+# but the custom make system may add other variants
 #
 # Effectively the JDK variant gives a name to a specific set of
 # modules to compile into the JDK. In the future, these modules
@@ -38,22 +38,14 @@
 #
 AC_MSG_CHECKING([which variant of the JDK to build])
 AC_ARG_WITH([jdk-variant], [AS_HELP_STRING([--with-jdk-variant],
-	[JDK variant to build (normal, embedded) @<:@normal@:>@])])
+	[JDK variant to build (normal) @<:@normal@:>@])])
 
 if test "x$with_jdk_variant" = xnormal || test "x$with_jdk_variant" = x; then
-    JAVASE_EMBEDDED=""
-    MINIMIZE_RAM_USAGE=""
     JDK_VARIANT="normal"
-elif test "x$with_jdk_variant" = xembedded; then
-    JAVASE_EMBEDDED="JAVASE_EMBEDDED:=true"
-    MINIMIZE_RAM_USAGE="MINIMIZE_RAM_USAGE:=true"
-    JDK_VARIANT="embedded"
 else
-    AC_MSG_ERROR([The available JDK variants are: normal, embedded])
+    AC_MSG_ERROR([The available JDK variants are: normal])
 fi
-                              
-AC_SUBST(JAVASE_EMBEDDED)
-AC_SUBST(MINIMIZE_RAM_USAGE)
+
 AC_SUBST(JDK_VARIANT)
 
 AC_MSG_RESULT([$JDK_VARIANT])
@@ -77,11 +69,7 @@
 	[JVM variants (separated by commas) to build (server, client, kernel, zero, zeroshark) @<:@server@:>@])])
 
 if test "x$with_jvm_variants" = x; then
-    if test "x$JDK_VARIANT" = xembedded; then
-        with_jvm_variants="client"
-    else
-        with_jvm_variants="server"
-    fi
+     with_jvm_variants="server"
 fi
 
 JVM_VARIANTS=",$with_jvm_variants,"
@@ -125,6 +113,11 @@
 AC_SUBST(JVM_VARIANT_ZERO)
 AC_SUBST(JVM_VARIANT_ZEROSHARK)
 
+if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
+   MACOSX_UNIVERSAL="true"
+fi
+
+AC_SUBST(MACOSX_UNIVERSAL)
 
 ])
 
@@ -223,6 +216,14 @@
 
 HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_EXPORT"
 
+# On Macosx universal binaries are produced, but they only contain
+# 64 bit intel. This invalidates control of which jvms are built
+# from configure, but only server is valid anyway. Fix this
+# when hotspot makefiles are rewritten.
+if test "x$MACOSX_UNIVERSAL" = xtrue; then
+    HOTSPOT_TARGET=universal_product
+fi
+
 #####
 
 AC_SUBST(DEBUG_LEVEL)
@@ -289,14 +290,12 @@
 
 if test "x$SUPPORT_HEADFUL" = xyes; then
     # We are building both headful and headless.
-    BUILD_HEADLESS_ONLY=""
     headful_msg="inlude support for both headful and headless"
 fi
 
 if test "x$SUPPORT_HEADFUL" = xno; then
     # Thus we are building headless only.
     BUILD_HEADLESS="BUILD_HEADLESS:=true"
-    BUILD_HEADLESS_ONLY="BUILD_HEADLESS_ONLY:=true"
     headful_msg="headless only"
 fi
 
@@ -305,23 +304,6 @@
 AC_SUBST(SUPPORT_HEADLESS)
 AC_SUBST(SUPPORT_HEADFUL)
 AC_SUBST(BUILD_HEADLESS)
-AC_SUBST(BUILD_HEADLESS_ONLY)
-
-###############################################################################
-#
-# Should we run the painfully slow javadoc tool?
-#
-AC_MSG_CHECKING([whether to build documentation])
-AC_ARG_ENABLE([docs], [AS_HELP_STRING([--enable-docs],
-	[enable generation of Javadoc documentation @<:@disabled@:>@])],
-	[ENABLE_DOCS="${enableval}"], [ENABLE_DOCS='no'])
-AC_MSG_RESULT([$ENABLE_DOCS])
-AC_SUBST(ENABLE_DOCS)
-GENERATE_DOCS=false
-if test "x$ENABLE_DOCS" = xyes; then
-    GENERATE_DOCS=true
-fi
-AC_SUBST(GENERATE_DOCS)
 
 ###############################################################################
 #
@@ -373,25 +355,21 @@
 #
 COMPRESS_JARS=false
 
-# default for embedded is yes...
-if test "x$JDK_VARIANT" = "xembedded"; then
-   COMPRESS_JARS=true
-fi
 AC_SUBST(COMPRESS_JARS)
 
 ###############################################################################
 #
 # Should we compile JFR
-#   default no, except for on closed-jdk and !embedded
+#   default no, except for on closed-jdk
 #
 ENABLE_JFR=no
 
 # Is the JFR source present
 
 #
-# For closed && !embedded default is yes if the source is present
+# For closed default is yes
 #
-if test "x${OPENJDK}" != "xtrue" && test "x$JDK_VARIANT" != "xembedded" && test -d "$SRC_ROOT/jdk/src/closed/share/native/oracle/jfr"; then
+if test "x${OPENJDK}" != "xtrue"; then
    ENABLE_JFR=yes
 fi
 
@@ -469,7 +447,7 @@
 
 AC_DEFUN_ONCE([JDKOPT_SETUP_BUILD_TWEAKS],
 [
-HOTSPOT_MAKE_ARGS="ALT_OUTPUTDIR=$HOTSPOT_OUTPUTDIR ALT_EXPORT_PATH=$HOTSPOT_DIST $HOTSPOT_TARGET"
+HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET"
 AC_SUBST(HOTSPOT_MAKE_ARGS)
 
 # The name of the Service Agent jar.
@@ -494,11 +472,6 @@
    ENABLE_DEBUG_SYMBOLS=no
 fi
 
-# default for embedded is no...
-if test "x$JDK_VARIANT" = "xembedded"; then
-   ENABLE_DEBUG_SYMBOLS=no
-fi
-
 AC_ARG_ENABLE([debug-symbols],
               [AS_HELP_STRING([--disable-debug-symbols],[disable generation of debug symbols (@<:@enabled@:>@)])],
               [ENABLE_DEBUG_SYMBOLS=${enable_debug_symbols}],
@@ -549,3 +522,11 @@
 AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
 ])
+
+# Support for customization of the build process. Some build files
+# will include counterparts from this location, if they exist. This allows
+# for a degree of customization of the build targets and the rules/recipes
+# to create them
+AC_ARG_WITH([custom-make-dir], [AS_HELP_STRING([--with-custom-make-dir],
+    [directory containing custom build/make files])], [CUSTOM_MAKE_DIR=$with_custom_make_dir])
+AC_SUBST(CUSTOM_MAKE_DIR)
--- a/common/autoconf/libraries.m4	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/libraries.m4	Tue Sep 25 11:48:00 2012 -0700
@@ -73,6 +73,10 @@
     FREETYPE2_NOT_NEEDED=yes
 fi
 
+if test "x$SUPPORT_HEADFUL" = xno; then
+    X11_NOT_NEEDED=yes
+fi
+
 ###############################################################################
 #
 # Check for MacOSX support for OpenJDK. If this exists, try to build a JVM
@@ -518,9 +522,7 @@
 
 ###############################################################################
 LIBZIP_CAN_USE_MMAP=true
-if test "x$JDK_VARIANT" = "xembedded"; then
-   LIBZIP_CAN_USE_MMAP=false
-fi
+
 AC_SUBST(LIBZIP_CAN_USE_MMAP)
 
 ###############################################################################
@@ -629,7 +631,7 @@
 
 # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
 if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then
-    LIBCXX="/usr/lib${LEGACY_OPENJDK_TARGET_CPU3}/libCrun.so.1"
+    LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
 fi
 
 # TODO better (platform agnostic) test
--- a/common/autoconf/platform.m4	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/platform.m4	Tue Sep 25 11:48:00 2012 -0700
@@ -23,279 +23,86 @@
 # questions.
 #
 
-AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD_AND_LEGACY_VARS],
-[
-    # Expects $host_os $host_cpu $build_os and $build_cpu
-    # and $with_target_bits to have been setup!
-    #
-    # Translate the standard triplet(quadruplet) definition
-    # of the target/build system into
-    # OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
-    # OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
-    # OPENJDK_TARGET_OS_API=posix,winapi
-    # 
-    # OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
-    # OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
-    # OPENJDK_TARGET_CPU_BITS=32,64
-    # OPENJDK_TARGET_CPU_ENDIAN=big,little
-    #
-    # The same values are setup for BUILD_...
-    # 
-    # And the legacy variables, for controlling the old makefiles.
-    # LEGACY_OPENJDK_TARGET_CPU1=i586,amd64/x86_64,sparc,sparcv9,arm,arm64...
-    # LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,sparc,sparcv9,arm,arm64...
-    # LEGACY_OPENJDK_TARGET_CPU3=sparcv9,amd64 (but only on solaris)
-    # LEGACY_OPENJDK_TARGET_OS_API=solaris,windows
-    #
-    # We also copy the autoconf trip/quadruplet
-    # verbatim to OPENJDK_TARGET_SYSTEM (from the autoconf "host") and OPENJDK_BUILD_SYSTEM
-    OPENJDK_TARGET_SYSTEM="$host"
-    OPENJDK_BUILD_SYSTEM="$build"
-    AC_SUBST(OPENJDK_TARGET_SYSTEM)
-    AC_SUBST(OPENJDK_BUILD_SYSTEM)
-    
-    PLATFORM_EXTRACT_VARS_FROM_OS_TO(OPENJDK_TARGET,$host_os)
-    PLATFORM_EXTRACT_VARS_FROM_CPU_TO(OPENJDK_TARGET,$host_cpu)
-
-    PLATFORM_EXTRACT_VARS_FROM_OS_TO(OPENJDK_BUILD,$build_os)
-    PLATFORM_EXTRACT_VARS_FROM_CPU_TO(OPENJDK_BUILD,$build_cpu)
-
-    if test "x$OPENJDK_TARGET_OS" != xsolaris; then
-        LEGACY_OPENJDK_TARGET_CPU3=""
-        LEGACY_OPENJDK_BUILD_CPU3=""
-    fi
-
-    # On MacOSX and MacOSX only, we have a different name for the x64 CPU in ARCH (LEGACY_OPENJDK_TARGET_CPU1) ...
-    if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$OPENJDK_TARGET_CPU" = xx64; then
-        LEGACY_OPENJDK_TARGET_CPU1="x86_64"
-    fi
-
-    PLATFORM_SET_RELEASE_FILE_OS_VALUES
-])
-
-AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS_TO],
-[
-    PLATFORM_EXTRACT_VARS_FROM_OS($2)
-    $1_OS="$VAR_OS"
-    $1_OS_FAMILY="$VAR_OS_FAMILY"
-    $1_OS_API="$VAR_OS_API"
-
-    AC_SUBST($1_OS)
-    AC_SUBST($1_OS_FAMILY)
-    AC_SUBST($1_OS_API)
-
-    if test "x$$1_OS_API" = xposix; then
-        LEGACY_$1_OS_API="solaris"
-    fi
-    if test "x$$1_OS_API" = xwinapi; then
-        LEGACY_$1_OS_API="windows"
-    fi
-    AC_SUBST(LEGACY_$1_OS_API)    
-])
-
-AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU_TO],
-[
-    PLATFORM_EXTRACT_VARS_FROM_CPU($2)
-    $1_CPU="$VAR_CPU"
-    $1_CPU_ARCH="$VAR_CPU_ARCH"
-    $1_CPU_BITS="$VAR_CPU_BITS"
-    $1_CPU_ENDIAN="$VAR_CPU_ENDIAN"
-
-    AC_SUBST($1_CPU)
-    AC_SUBST($1_CPU_ARCH)
-    AC_SUBST($1_CPU_BITS)
-    AC_SUBST($1_CPU_ENDIAN)
-    
-    # Also store the legacy naming of the cpu.
-    # Ie i586 and amd64 instead of ia32 and x64
-    LEGACY_$1_CPU1="$VAR_LEGACY_CPU"
-    AC_SUBST(LEGACY_$1_CPU1)
-
-    # And the second legacy naming of the cpu.
-    # Ie i386 and amd64 instead of ia32 and x64.
-    LEGACY_$1_CPU2="$LEGACY_$1_CPU1"
-    if test "x$LEGACY_$1_CPU1" = xi586; then 
-        LEGACY_$1_CPU2=i386
-    fi
-    AC_SUBST(LEGACY_$1_CPU2)
-
-    # And the third legacy naming of the cpu.
-    # Ie only amd64 or sparcv9, used for the ISA_DIR on Solaris.
-    LEGACY_$1_CPU3=""
-    if test "x$$1_CPU" = xx64; then 
-        LEGACY_$1_CPU3=amd64
-    fi
-    if test "x$$1_CPU" = xsparcv9; then 
-        LEGACY_$1_CPU3=sparcv9
-    fi
-    AC_SUBST(LEGACY_$1_CPU3)
-])
-
+# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
+# Converts autoconf style CPU name to OpenJDK style, into
+# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
 [
   # First argument is the cpu name from the trip/quad
   case "$1" in
     x86_64)
-      VAR_CPU=x64
+      VAR_CPU=x86_64
       VAR_CPU_ARCH=x86
       VAR_CPU_BITS=64
       VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=amd64
       ;;
     i?86)
-      VAR_CPU=ia32
+      VAR_CPU=x86
       VAR_CPU_ARCH=x86
       VAR_CPU_BITS=32
       VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=i586
-      ;;
-    alpha*)
-      VAR_CPU=alpha
-      VAR_CPU_ARCH=alpha
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=alpha
       ;;
     arm*)
       VAR_CPU=arm
       VAR_CPU_ARCH=arm
       VAR_CPU_BITS=32
       VAR_CPU_ENDIAN=little
-      VAR_LEGACY_CPU=arm
       ;;
-    mips)
-      VAR_CPU=mips
-      VAR_CPU_ARCH=mips
-      VAR_CPU_BITS=woot
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=mips
-       ;;
-    mipsel)
-      VAR_CPU=mipsel
-      VAR_CPU_ARCH=mips
-      VAR_CPU_BITS=woot
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=mipsel
-       ;;
     powerpc)
       VAR_CPU=ppc
       VAR_CPU_ARCH=ppc
       VAR_CPU_BITS=32
       VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=ppc
        ;;
     powerpc64)
       VAR_CPU=ppc64
       VAR_CPU_ARCH=ppc
       VAR_CPU_BITS=64
       VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=ppc64
        ;;
     sparc)
       VAR_CPU=sparc
       VAR_CPU_ARCH=sparc
       VAR_CPU_BITS=32
       VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=sparc
        ;;
-    sparc64)
+    sparcv9)
       VAR_CPU=sparcv9
       VAR_CPU_ARCH=sparc
       VAR_CPU_BITS=64
       VAR_CPU_ENDIAN=big
-      VAR_LEGACY_CPU=sparcv9
-       ;;
-    s390)
-      VAR_CPU=s390
-      VAR_CPU_ARCH=s390
-      VAR_CPU_BITS=32
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=s390
-      VAR_LEGACY_CPU=s390
-       ;;
-    s390x)
-      VAR_CPU=s390x
-      VAR_CPU_ARCH=s390
-      VAR_CPU_BITS=64
-      VAR_CPU_ENDIAN=woot
-      VAR_LEGACY_CPU=s390x
        ;;
     *)
       AC_MSG_ERROR([unsupported cpu $1])
       ;;
   esac
-
-  # Workaround cygwin not knowing about 64 bit.
-  if test "x$VAR_OS" = "xwindows"; then
-      if test "x$PROCESSOR_IDENTIFIER" != "x"; then
-          PROC_ARCH=`echo $PROCESSOR_IDENTIFIER | $CUT -f1 -d' '`
-          case "$PROC_ARCH" in
-            intel64|Intel64|INTEL64|em64t|EM64T|amd64|AMD64|8664|x86_64)
-              VAR_CPU=x64
-              VAR_CPU_BITS=64
-              VAR_LEGACY_CPU=amd64
-              ;;
-          esac
-      fi
-  fi
-
-  # on solaris x86...default seems to be 32-bit
-  if test "x$VAR_OS" = "xsolaris" && \
-     test "x$with_target_bits" = "x" && \
-     test "x$VAR_CPU_ARCH" = "xx86"
-  then
-      with_target_bits=32
-  fi
-
-  if test "x$VAR_CPU_ARCH" = "xx86"; then
-      if test "x$with_target_bits" = "x64"; then
-          VAR_CPU=x64
-          VAR_CPU_BITS=64
-          VAR_LEGACY_CPU=amd64
-      fi
-      if test "x$with_target_bits" = "x32"; then
-          VAR_CPU=ia32
-          VAR_CPU_BITS=32
-          VAR_LEGACY_CPU=i586
-      fi
-  fi 
-
-  if test "x$VAR_CPU_ARCH" = "xsparc"; then
-      if test "x$with_target_bits" = "x64"; then
-          VAR_CPU=sparcv9
-          VAR_CPU_BITS=64
-          VAR_LEGACY_CPU=sparcv9
-      fi
-  fi 
 ])
 
+# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
+# Converts autoconf style OS name to OpenJDK style, into
+# VAR_OS and VAR_OS_API.
 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
 [
   case "$1" in
     *linux*)
       VAR_OS=linux
       VAR_OS_API=posix
-      VAR_OS_FAMILY=gnu
       ;;
     *solaris*)
       VAR_OS=solaris
       VAR_OS_API=posix
-      VAR_OS_FAMILY=sysv
       ;;
     *darwin*)
       VAR_OS=macosx
       VAR_OS_API=posix
-      VAR_OS_FAMILY=bsd
       ;;
     *bsd*)
       VAR_OS=bsd
       VAR_OS_API=posix
-      VAR_OS_FAMILY=bsd
       ;;
     *cygwin*|*windows*)
       VAR_OS=windows
       VAR_OS_API=winapi
-      VAR_OS_FAMILY=windows
       ;;
     *)
       AC_MSG_ERROR([unsupported operating system $1])
@@ -303,6 +110,208 @@
   esac
 ])
 
+# Expects $host_os $host_cpu $build_os and $build_cpu
+# and $with_target_bits to have been setup!
+#
+# Translate the standard triplet(quadruplet) definition
+# of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
+# OPENJDK_BUILD_OS, etc.
+AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
+[
+    # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
+    # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
+    # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
+    # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.     
+    OPENJDK_TARGET_AUTOCONF_NAME="$host"
+    OPENJDK_BUILD_AUTOCONF_NAME="$build"
+    AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
+    AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
+
+    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
+    PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
+    PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
+    # ... and setup our own variables. (Do this explicitely to facilitate searching)
+    OPENJDK_TARGET_OS="$VAR_OS"
+    OPENJDK_TARGET_OS_API="$VAR_OS_API"
+    OPENJDK_TARGET_CPU="$VAR_CPU"
+    OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
+    OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
+    OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
+    AC_SUBST(OPENJDK_TARGET_OS)
+    AC_SUBST(OPENJDK_TARGET_OS_API)
+    AC_SUBST(OPENJDK_TARGET_CPU)
+    AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
+    AC_SUBST(OPENJDK_TARGET_CPU_BITS)
+    AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
+
+    # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
+    PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
+    PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
+    # ..and setup our own variables. (Do this explicitely to facilitate searching)
+    OPENJDK_BUILD_OS="$VAR_OS"
+    OPENJDK_BUILD_OS_API="$VAR_OS_API"
+    OPENJDK_BUILD_CPU="$VAR_CPU"
+    OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
+    OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
+    OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
+    AC_SUBST(OPENJDK_BUILD_OS)
+    AC_SUBST(OPENJDK_BUILD_OS_API)
+    AC_SUBST(OPENJDK_BUILD_CPU)
+    AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
+    AC_SUBST(OPENJDK_BUILD_CPU_BITS)
+    AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
+])
+
+# Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
+# accordingly. Must be done after setting up build and target system, but before
+# doing anything else with these values.
+AC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
+[
+  AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
+     [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
+
+  # We have three types of compiles:
+  # native  == normal compilation, target system == build system
+  # cross   == traditional cross compilation, target system != build system; special toolchain needed
+  # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
+  #
+  if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
+    # We're doing a proper cross-compilation
+    COMPILE_TYPE="cross"
+  else
+    COMPILE_TYPE="native"
+  fi
+
+  if test "x$with_target_bits" != x; then
+    if test "x$COMPILE_TYPE" = "xcross"; then
+      AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
+    fi
+
+    if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+      # A reduced build is requested
+      COMPILE_TYPE="reduced"
+      OPENJDK_TARGET_CPU_BITS=32
+      if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
+        OPENJDK_TARGET_CPU=x86
+      elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
+        OPENJDK_TARGET_CPU=sparc
+      else
+        AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
+      fi 
+    elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
+    elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
+      AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
+    else
+      AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
+    fi
+  fi
+  AC_SUBST(COMPILE_TYPE)
+
+AC_MSG_CHECKING([for compilation type])
+AC_MSG_RESULT([$COMPILE_TYPE])
+])
+
+    # Setup the legacy variables, for controlling the old makefiles.
+    #
+AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
+[
+    # Also store the legacy naming of the cpu.
+    # Ie i586 and amd64 instead of x86 and x86_64
+    OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
+      OPENJDK_TARGET_CPU_LEGACY="i586"
+    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
+      # On all platforms except MacOSX replace x86_64 with amd64.
+      OPENJDK_TARGET_CPU_LEGACY="amd64"
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
+
+    # And the second legacy naming of the cpu.
+    # Ie i386 and amd64 instead of x86 and x86_64.
+    OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
+      OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
+    elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
+      OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
+
+    # This is the name of the cpu (but using i386 and amd64 instead of
+    # x86 and x86_64, respectively), preceeded by a /, to be used when
+    # locating libraries. On macosx, it's empty, though.
+    OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
+    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+        OPENJDK_TARGET_CPU_LIBDIR=""
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
+
+    # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
+    # /amd64 or /sparcv9. This string is appended to some library paths, like this:
+    # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
+    OPENJDK_TARGET_CPU_ISADIR=""
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+      if test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
+          OPENJDK_TARGET_CPU_ISADIR="/amd64"
+      elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then 
+          OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
+      fi
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
+
+    # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
+    OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
+      # On linux only, we replace x86 with i386.
+      OPENJDK_TARGET_CPU_OSARCH="i386"
+    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+      # On all platforms except macosx, we replace x86_64 with amd64.
+      OPENJDK_TARGET_CPU_OSARCH="amd64"
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
+
+    OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
+      OPENJDK_TARGET_CPU_JLI="i386"
+    elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+      # On all platforms except macosx, we replace x86_64 with amd64.
+      OPENJDK_TARGET_CPU_JLI="amd64"
+    fi
+    # Now setup the -D flags for building libjli.
+    OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+      if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
+        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
+      elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then 
+        OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
+      fi
+    fi
+    AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
+
+    # Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
+    if test "x$OPENJDK_TARGET_OS_API" = xposix; then
+        OPENJDK_TARGET_OS_API_DIR="solaris"
+    fi
+    if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
+        OPENJDK_TARGET_OS_API_DIR="windows"
+    fi
+    AC_SUBST(OPENJDK_TARGET_OS_API_DIR)
+
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+        A_LP64="LP64:="
+        ADD_LP64="-D_LP64=1"
+    fi
+    AC_SUBST(LP64,$A_LP64)
+
+    if test "x$COMPILE_TYPE" = "xcross"; then
+      # FIXME: ... or should this include reduced builds..?
+      DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
+    else
+      DEFINE_CROSS_COMPILE_ARCH=""
+    fi
+    AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
+])
+
 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
 [
     if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
@@ -315,7 +324,11 @@
     fi
     if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
         REQUIRED_OS_NAME=Windows
-        REQUIRED_OS_VERSION=5.1
+        if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
+            REQUIRED_OS_VERSION=5.2
+        else
+            REQUIRED_OS_VERSION=5.1
+        fi
     fi
     if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
         REQUIRED_OS_NAME=Darwin
@@ -338,42 +351,10 @@
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 
-AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
-   [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
-
-if test "x$with_target_bits" != x && \
-   test "x$with_target_bits" != x32 && \
-   test "x$with_target_bits" != x64 ; then
-    AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
-fi
-# Translate the standard cpu-vendor-kernel-os quadruplets into
-# the new TARGET_.... and BUILD_... and the legacy names used by
-# the openjdk build.
-# It uses $host_os $host_cpu $build_os $build_cpu and $with_target_bits
-PLATFORM_EXTRACT_TARGET_AND_BUILD_AND_LEGACY_VARS
-
-# The LEGACY_OPENJDK_TARGET_CPU3 is the setting for ISA_DIR.
-if test "x$LEGACY_OPENJDK_TARGET_CPU3" != x; then
-   LEGACY_OPENJDK_TARGET_CPU3="/${LEGACY_OPENJDK_TARGET_CPU3}"
-fi
-
-# Now the following vars are defined.
-# OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
-# OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
-# OPENJDK_TARGET_OS_API=posix,winapi
-#
-# OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
-# OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
-# OPENJDK_TARGET_CPU_BITS=32,64
-# OPENJDK_TARGET_CPU_ENDIAN=big,little
-#
-# There is also a:
-# LEGACY_OPENJDK_TARGET_CPU1=i586,amd64,....  # used to set the old var ARCH
-# LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,.... # used to set the old var LIBARCH
-# LEGACY_OPENJDK_TARGET_CPU3=only sparcv9,amd64 # used to set the ISA_DIR on Solaris
-# There was also a BUILDARCH that had i486,amd64,... but we do not use that
-# in the new build.
-# LEGACY_OPENJDK_TARGET_OS_API=solaris,windows # used to select source roots
+PLATFORM_EXTRACT_TARGET_AND_BUILD
+PLATFORM_SETUP_TARGET_CPU_BITS
+PLATFORM_SET_RELEASE_FILE_OS_VALUES
+PLATFORM_SETUP_LEGACY_VARS
 ])
 
 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
@@ -391,7 +372,26 @@
 AC_SUBST(OS_VERSION_MICRO)
 ])
 
-AC_DEFUN_ONCE([PLATFORM_TEST_OPENJDK_TARGET_BITS],
+# Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
+# Add -mX to various FLAGS variables.
+AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
+[
+  # keep track of c/cxx flags that we added outselves...
+  #   to prevent emitting warning...
+  ADDED_CFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+  ADDED_CXXFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+  ADDED_LDFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
+
+  CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
+  CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
+  LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
+
+  CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
+  CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
+  LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
+])
+
+AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
 [
 ###############################################################################
 #
@@ -399,72 +399,47 @@
 # (The JVM can use 32 or 64 bit Java pointers but that decision
 # is made at runtime.)
 #
-AC_LANG_PUSH(C++)
-OLD_CXXFLAGS="$CXXFLAGS"
-if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
-	CXXFLAGS="-m${with_target_bits} $CXXFLAGS"
+if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+  # Always specify -m flags on Solaris
+  PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
+elif test "x$COMPILE_TYPE" = xreduced; then
+  if test "x$OPENJDK_TARGET_OS" != xwindows; then
+    # Specify -m if running reduced on other Posix platforms
+    PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
+  fi
 fi
-AC_CHECK_SIZEOF([int *], [1111])
-CXXFLAGS="$OLD_CXXFLAGS"
-AC_LANG_POP(C++)
-
-# keep track of c/cxx flags that we added outselves...
-#   to prevent emitting warning...
-ADDED_CFLAGS=
-ADDED_CXXFLAGS=
-ADDED_LDFLAGS=
 
-if test "x$ac_cv_sizeof_int_p" = x0; then 
-    # The test failed, lets pick the assumed value.
-    ARCH_DATA_MODEL=$OPENJDK_TARGET_CPU_BITS
-else
-    ARCH_DATA_MODEL=`expr 8 \* $ac_cv_sizeof_int_p`
+# Make compilation sanity check
+AC_CHECK_HEADERS([stdio.h], , [
+  AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
+  if test "x$COMPILE_TYPE" = xreduced; then
+    AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed.])
+  elif test "x$COMPILE_TYPE" = xcross; then
+    AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
+  fi
+  AC_MSG_ERROR([Cannot continue.])
+])
+
+AC_CHECK_SIZEOF([int *], [1111])
 
-    if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
-       ADDED_CFLAGS=" -m${with_target_bits}"
-       ADDED_CXXFLAGS=" -m${with_target_bits}"
-       ADDED_LDFLAGS=" -m${with_target_bits}"
+if test "x$SIZEOF_INT_P" != "x$ac_cv_sizeof_int_p"; then
+  # Workaround autoconf bug, see http://lists.gnu.org/archive/html/autoconf/2010-07/msg00004.html
+  SIZEOF_INT_P="$ac_cv_sizeof_int_p"
+fi
 
-       CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
-       CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
-       LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
+if test "x$SIZEOF_INT_P" = x; then 
+    # The test failed, lets stick to the assumed value.
+    AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
+else
+    TESTED_TARGET_CPU_BITS=`expr 8 \* $SIZEOF_INT_P`
 
-       CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
-       CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
-       LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
+    if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
+        AC_MSG_ERROR([The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)])
     fi
 fi
 
-if test "x$ARCH_DATA_MODEL" = x64; then
-    A_LP64="LP64:="
-    ADD_LP64="-D_LP64=1"
-fi
 AC_MSG_CHECKING([for target address size])
-AC_MSG_RESULT([$ARCH_DATA_MODEL bits])
-AC_SUBST(LP64,$A_LP64)
-AC_SUBST(ARCH_DATA_MODEL)
-
-if test "x$ARCH_DATA_MODEL" != "x$OPENJDK_TARGET_CPU_BITS"; then
-    AC_MSG_ERROR([The tested number of bits in the target ($ARCH_DATA_MODEL) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)])
-fi
-
-#
-# NOTE: check for -mstackrealign needs to be below potential addition of -m32
-#
-if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
-    # While waiting for a better solution, the current workaround is to use -mstackrealign.
-    CFLAGS="$CFLAGS -mstackrealign"
-    AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
-    AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
-                   [
-		        AC_MSG_RESULT([yes])
-                   ],
-	           [
-		        AC_MSG_RESULT([no])
-	                AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
-	           ])
-fi
+AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
 ])
 
 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
@@ -478,21 +453,7 @@
 if test "x$ENDIAN" = xuniversal_endianness; then
     AC_MSG_ERROR([Building with both big and little endianness is not supported])
 fi
-if test "x$ENDIAN" = xunknown; then
-    ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
+if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
+    AC_MSG_ERROR([The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)])
 fi
-if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
-    AC_MSG_WARN([The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)])
-    ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
-fi
-AC_SUBST(ENDIAN)
 ])
-
-AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ISADIR],
-[
-###############################################################################
-#
-# Could someone enlighten this configure script with a comment about libCrun?
-#
-#
-])
--- a/common/autoconf/source-dirs.m4	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/source-dirs.m4	Tue Sep 25 11:48:00 2012 -0700
@@ -250,31 +250,8 @@
 
 AC_DEFUN_ONCE([SRCDIRS_SETUP_OUTPUT_DIRS],
 [
-LANGTOOLS_OUTPUTDIR="$OUTPUT_ROOT/langtools"
-CORBA_OUTPUTDIR="$OUTPUT_ROOT/corba"
-JAXP_OUTPUTDIR="$OUTPUT_ROOT/jaxp"
-JAXWS_OUTPUTDIR="$OUTPUT_ROOT/jaxws"
-HOTSPOT_OUTPUTDIR="$OUTPUT_ROOT/hotspot"
-JDK_OUTPUTDIR="$OUTPUT_ROOT/jdk"
-IMAGES_OUTPUTDIR="$OUTPUT_ROOT/images"
+BUILD_OUTPUT="$OUTPUT_ROOT"
+AC_SUBST(BUILD_OUTPUT)
 
-AC_SUBST(LANGTOOLS_OUTPUTDIR)
-AC_SUBST(CORBA_OUTPUTDIR)
-AC_SUBST(JAXP_OUTPUTDIR)
-AC_SUBST(JAXWS_OUTPUTDIR)
-AC_SUBST(HOTSPOT_OUTPUTDIR)
-AC_SUBST(JDK_OUTPUTDIR)
-AC_SUBST(IMAGES_OUTPUTDIR)
-
-LANGTOOLS_DIST="$OUTPUT_ROOT/langtools/dist"
-CORBA_DIST="$OUTPUT_ROOT/corba/dist"
-JAXP_DIST="$OUTPUT_ROOT/jaxp/dist"
-JAXWS_DIST="$OUTPUT_ROOT/jaxws/dist"
-HOTSPOT_DIST="$OUTPUT_ROOT/hotspot/dist"
-
-AC_SUBST(LANGTOOLS_DIST)
-AC_SUBST(CORBA_DIST)
-AC_SUBST(JAXP_DIST)
-AC_SUBST(JAXWS_DIST)
-AC_SUBST(HOTSPOT_DIST)
+JDK_OUTPUTDIR="$OUTPUT_ROOT/jdk"
 ])
--- a/common/autoconf/spec.gmk.in	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/spec.gmk.in	Tue Sep 25 11:48:00 2012 -0700
@@ -23,7 +23,11 @@
 # questions.
 #
 
-# Configured @DATE_WHEN_CONFIGURED@ to build for a @OPENJDK_TARGET_SYSTEM@ system,
+# Configured @DATE_WHEN_CONFIGURED@ to build
+# for target system @OPENJDK_TARGET_OS@-@OPENJDK_TARGET_CPU@
+#   (called @OPENJDK_TARGET_AUTOCONF_NAME@ by autoconf)
+# on build system @OPENJDK_BUILD_OS@-@OPENJDK_BUILD_CPU@
+#   (called @OPENJDK_BUILD_AUTOCONF_NAME@ by autoconf)
 # using 'configure @CONFIGURE_COMMAND_LINE@'
 
 # When calling macros, the spaces between arguments are 
@@ -40,6 +44,17 @@
 define NEWLINE:=
 endef
 
+# A self-referential reference to this file.
+SPEC:=@SPEC@
+
+# Specify where the spec file is.
+MAKE_ARGS="SPEC=$(SPEC)"
+
+# TODO The logic for finding and setting MAKE is currently not working 
+# well on windows. Disable it TEMPORARILY there for now.
+ifneq (@OPENJDK_TARGET_OS@,windows)
+    MAKE:=@MAKE@
+endif
 
 # Pass along the verbosity setting.
 ifeq (,$(findstring VERBOSE=,$(MAKE)))
@@ -51,27 +66,16 @@
     MAKE:=$(MAKE) -R
 endif
 
-# Specify where the spec file is.
-ifeq (,$(findstring SPEC=,$(MAKE)))
-    MAKE:=$(MAKE) SPEC=@SPEC@
-endif
-
 # Specify where the common include directory for makefiles is.
 ifeq (,$(findstring -I @SRC_ROOT@/common/makefiles,$(MAKE)))
     MAKE:=$(MAKE) -I @SRC_ROOT@/common/makefiles
 endif
 
-# A self-referential reference to this file.
-SPEC:=@SPEC@
-
 # The "human readable" name of this configuration
 CONF_NAME:=@CONF_NAME@
 
 # The built jdk will run in this target system.
-OPENJDK_TARGET_SYSTEM:=@OPENJDK_TARGET_SYSTEM@
-
 OPENJDK_TARGET_OS:=@OPENJDK_TARGET_OS@
-OPENJDK_TARGET_OS_FAMILY:=@OPENJDK_TARGET_OS_FAMILY@
 OPENJDK_TARGET_OS_API:=@OPENJDK_TARGET_OS_API@
 
 OPENJDK_TARGET_CPU:=@OPENJDK_TARGET_CPU@
@@ -79,12 +83,20 @@
 OPENJDK_TARGET_CPU_BITS:=@OPENJDK_TARGET_CPU_BITS@
 OPENJDK_TARGET_CPU_ENDIAN:=@OPENJDK_TARGET_CPU_ENDIAN@
 
+COMPILE_TYPE:=@COMPILE_TYPE@
+
+# Legacy support
+OPENJDK_TARGET_CPU_ISADIR:=@OPENJDK_TARGET_CPU_ISADIR@
+OPENJDK_TARGET_CPU_LIBDIR:=@OPENJDK_TARGET_CPU_LIBDIR@
+OPENJDK_TARGET_CPU_LEGACY:=@OPENJDK_TARGET_CPU_LEGACY@
+OPENJDK_TARGET_CPU_LEGACY_LIB:=@OPENJDK_TARGET_CPU_LEGACY_LIB@
+OPENJDK_TARGET_CPU_OSARCH:=@OPENJDK_TARGET_CPU_OSARCH@
+OPENJDK_TARGET_CPU_JLI_CFLAGS:=@OPENJDK_TARGET_CPU_JLI_CFLAGS@
+OPENJDK_TARGET_OS_API_DIR:=@OPENJDK_TARGET_OS_API_DIR@
+
 # We are building on this build system.
 # When not cross-compiling, it is the same as the target.
-OPENJDK_BUILD_SYSTEM:=@OPENJDK_BUILD_SYSTEM@
-
 OPENJDK_BUILD_OS:=@OPENJDK_BUILD_OS@
-OPENJDK_BUILD_OS_FAMILY:=@OPENJDK_BUILD_OS_FAMILY@
 OPENJDK_BUILD_OS_API:=@OPENJDK_BUILD_OS_API@
 
 OPENJDK_BUILD_CPU:=@OPENJDK_BUILD_CPU@
@@ -96,21 +108,6 @@
 REQUIRED_OS_NAME:=@REQUIRED_OS_NAME@
 REQUIRED_OS_VERSION:=@REQUIRED_OS_VERSION@
 
-# Old name for OPENJDK_TARGET_OS (aix,bsd,hpux,linux,macosx,solaris,windows etc)
-PLATFORM:=@OPENJDK_TARGET_OS@
-# Old name for OPENJDK_TARGET_CPU, uses i586 and amd64, instead of ia32 and x64.
-ARCH:=@LEGACY_OPENJDK_TARGET_CPU1@
-# Yet another name for arch used for an extra subdir below the jvm lib.
-# Uses i386 and amd64, instead of ia32 and x64.
-LIBARCH:=@LEGACY_OPENJDK_TARGET_CPU2@
-# Use to switch between solaris and windows subdirs in the jdk.
-LEGACY_OPENJDK_TARGET_OS_API:=@LEGACY_OPENJDK_TARGET_OS_API@
-# 32 or 64 bit
-ARCH_DATA_MODEL:=@OPENJDK_TARGET_CPU_BITS@
-# Legacy setting for building for a 64 bit machine.
-# If yes then this expands to _LP64:=1
-@LP64@
-ENDIAN:=@OPENJDK_TARGET_CPU_ENDIAN@
 @SET_OPENJDK@
 JIGSAW:=@JIGSAW@
 LIBM:=-lm
@@ -143,6 +140,9 @@
 HOTSPOT_TOPDIR:=@HOTSPOT_TOPDIR@
 COPYRIGHT_YEAR:=@COPYRIGHT_YEAR@
 
+# Location where build customization files may be found
+CUSTOM_MAKE_DIR:=@CUSTOM_MAKE_DIR@
+
 # Information gathered from the version.numbers file.
 JDK_MAJOR_VERSION:=@JDK_MAJOR_VERSION@
 JDK_MINOR_VERSION:=@JDK_MINOR_VERSION@
@@ -171,17 +171,12 @@
 # The JDK variant is a name for a specific set of modules to be compiled for the JDK.
 JDK_VARIANT:=@JDK_VARIANT@
 
-# Legacy defines controlling the JDK variant embedded.
-@JAVASE_EMBEDDED@
-@MINIMIZE_RAM_USAGE@
-
 # Should we compile support for running with a graphical UI? (ie headful)
 # Should we compile support for running without? (ie headless)
 SUPPORT_HEADFUL:=@SUPPORT_HEADFUL@
 SUPPORT_HEADLESS:=@SUPPORT_HEADLESS@
 # Legacy defines controlled by the SUPPORT_HEADLESS and SUPPORT_HEADFUL options.
 @BUILD_HEADLESS@
-@BUILD_HEADLESS_ONLY@
 
 # These are the libjvms that we want to build.
 # The java launcher uses the default.
@@ -194,53 +189,43 @@
 JVM_VARIANT_ZERO:=@JVM_VARIANT_ZERO@
 JVM_VARIANT_ZEROSHARK:=@JVM_VARIANT_ZEROSHARK@
 
-# Legacy setting: OPT or DBG
-VARIANT:=@VARIANT@
-# Legacy setting: true or false
-FASTDEBUG:=@FASTDEBUG@
-# Legacy setting: debugging the class files?
-DEBUG_CLASSFILES:=@DEBUG_CLASSFILES@
+# Universal binaries on macosx
+MACOSX_UNIVERSAL=@MACOSX_UNIVERSAL@
+
 # Legacy setting: -debug or -fastdebug
+# Still used in version string...
 BUILD_VARIANT_RELEASE:=@BUILD_VARIANT_RELEASE@
 
-LANGTOOLS_OUTPUTDIR:=@LANGTOOLS_OUTPUTDIR@
-CORBA_OUTPUTDIR:=@CORBA_OUTPUTDIR@
-JAXP_OUTPUTDIR:=@JAXP_OUTPUTDIR@
-JAXWS_OUTPUTDIR:=@JAXWS_OUTPUTDIR@
-HOTSPOT_OUTPUTDIR:=@HOTSPOT_OUTPUTDIR@
-
-# This where a working jvm is built.
+# JDK_OUTPUTDIR specifies where a working jvm is built.
 # You can run $(JDK_OUTPUTDIR)/bin/java
 # Though the layout of the contents of $(JDK_OUTPUTDIR) is not
 # yet the same as a default installation.
-JDK_OUTPUTDIR:=@OUTPUT_ROOT@/jdk
-
+#
 # When you run "make install" it will create the standardized
-# layout for the jdk and the jre inside the images subdir.
+# layout for the jdk and the jre inside the IMAGES_OUTPUTDIR subdir.
 # Then it will copy the contents of the jdk into the installation
 # directory.
-IMAGES_OUTPUTDIR:=@OUTPUT_ROOT@/images
-
-LANGTOOLS_DIST:=@LANGTOOLS_DIST@
-CORBA_DIST:=@CORBA_DIST@
-JAXP_DIST:=@JAXP_DIST@
-JAXWS_DIST:=@JAXWS_DIST@
-HOTSPOT_DIST:=@HOTSPOT_DIST@
 
-# Legacy variables used by Release.gmk
-JDK_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2sdk-image
-JRE_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2re-image
+BUILD_OUTPUT:=@BUILD_OUTPUT@
+LANGTOOLS_OUTPUTDIR=$(BUILD_OUTPUT)/langtools
+CORBA_OUTPUTDIR=$(BUILD_OUTPUT)/corba
+JAXP_OUTPUTDIR=$(BUILD_OUTPUT)/jaxp
+JAXWS_OUTPUTDIR=$(BUILD_OUTPUT)/jaxws
+HOTSPOT_OUTPUTDIR=$(BUILD_OUTPUT)/hotspot
+JDK_OUTPUTDIR=$(BUILD_OUTPUT)/jdk
+IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images
 
-# Can be /sparcv9 or /amd64 on Solaris
-ISA_DIR:=@LEGACY_OPENJDK_TARGET_CPU3@
-BINDIR:=$(JDK_OUTPUTDIR)/bin$(ISA_DIR)
+LANGTOOLS_DIST=$(LANGTOOLS_OUTPUTDIR)/dist
+CORBA_DIST=$(CORBA_OUTPUTDIR)/dist
+JAXP_DIST=$(JAXP_OUTPUTDIR)/dist
+JAXWS_DIST=$(JAXWS_OUTPUTDIR)/dist
+HOTSPOT_DIST=$(HOTSPOT_OUTPUTDIR)/dist
 
 # The boot jdk to use
-ALT_BOOTDIR:=@BOOT_JDK@
 BOOT_JDK:=@BOOT_JDK@
 BOOT_JDK_JVMARGS:=@BOOT_JDK_JVMARGS@
 BOOT_RTJAR:=@BOOT_RTJAR@
-BOOT_TOOLSJAR:=@BOOT_TOOLSJAR@
+BOOT_TOOLSJAR=$(BOOT_JDK)/lib/tools.jar
 
 # When compiling Java source to be run by the boot jdk
 # use these extra flags, eg -source 6 -target 6
@@ -248,30 +233,18 @@
 
 # Information about the build system
 NUM_CORES:=@NUM_CORES@
-# This is used from the jdk build for C/C++ code.
-PARALLEL_COMPILE_JOBS:=@CONCURRENT_BUILD_JOBS@
-# Store javac server synchronization files here, and
-# the javac server log files.
-JAVAC_SERVERS:=@JAVAC_SERVERS@
-# Should we use a javac server or not? The javac server gives
-# an enormous performance improvement since it reduces the
-# startup costs of javac and reuses as much as possible of intermediate
-# compilation work. But if we want to compile with a non-Java
-# javac compiler, like gcj. Then we cannot use javac server and
-# this variable is set to false.
-JAVAC_USE_REMOTE:=@JAVAC_USE_REMOTE@
+# Enable sjavac support = use a javac server,
+# multi core javac compilation and dependency tracking.
+ENABLE_SJAVAC:=@ENABLE_SJAVAC@
+# Store sjavac server synchronization files here, and
+# the sjavac server log files.
+SJAVAC_SERVER_DIR:=@SJAVAC_SERVER_DIR@
 # We can block the Javac server to never use more cores than this.
 # This is not for performance reasons, but for memory usage, since each
 # core requires its own JavaCompiler. We might have 64 cores and 4GB
 # of memory, 64 JavaCompilers will currently not fit in a 3GB heap.
 # Since there is no sharing of data between the JavaCompilers.
-JAVAC_SERVER_CORES:=@JAVAC_SERVER_CORES@
-# Should we use dependency tracking between Java packages? true or false.
-JAVAC_USE_DEPS:=@JAVAC_USE_DEPS@
-# We can invoke javac: SINGLE_THREADED_BATCH or MULTI_CORE_CONCURRENT
-JAVAC_USE_MODE:=@JAVAC_USE_MODE@
-# Enable not yet complete sjavac support.
-ENABLE_SJAVAC:=@ENABLE_SJAVAC@
+SJAVAC_SERVER_CORES:=@SJAVAC_SERVER_CORES@
 
 # The OpenJDK makefiles should be changed to using the standard
 # configure output ..._CFLAGS and ..._LIBS. In the meantime we
@@ -280,7 +253,6 @@
 FREETYPE2_LIBS:=@FREETYPE2_LIBS@
 FREETYPE2_CFLAGS:=@FREETYPE2_CFLAGS@
 USING_SYSTEM_FT_LIB=@USING_SYSTEM_FT_LIB@
-ALT_CUPS_HEADERS_PATH:=$(patsubst -I%,%,$(filter -I%,@CUPS_CFLAGS@))
 CUPS_CFLAGS:=@CUPS_CFLAGS@
 
 PACKAGE_PATH=@PACKAGE_PATH@
@@ -288,8 +260,6 @@
 # Source file for cacerts
 CACERTS_FILE=@CACERTS_FILE@
 
-#MOZILLA_HEADERS_PATH:=
-
 # Necessary additional compiler flags to compile X11 
 X_CFLAGS:=@X_CFLAGS@
 X_LIBS:=@X_LIBS@
@@ -338,7 +308,7 @@
 CPP:=@UNCYGDRIVE@ @CPP@
 #CPPFLAGS:=@CPPFLAGS@
 
-# The linker can be gcc or ld on posix systems, or link.exe on winapi systems.
+# The linker can be gcc or ld on posix systems, or link.exe on windows systems.
 LD:=@UNCYGDRIVE@ @LD@
 
 # LDFLAGS used to link the jdk native libraries (C-code)
@@ -353,6 +323,9 @@
 LDFLAGS_JDKEXE:=@LDFLAGS_JDKEXE@
 LDFLAGS_JDKEXE_SUFFIX:=@LDFLAGS_JDKEXE_SUFFIX@
 
+# LDFLAGS specific to C++ linking.
+LDFLAGS_CXX_JDK:=@LDFLAGS_CXX_JDK@
+
 # Sometimes a different linker is needed for c++ libs
 LDCXX:=@UNCYGDRIVE@ @LDCXX@
 # The flags for linking libstdc++ linker.
@@ -361,28 +334,22 @@
 # Sometimes a different linker is needed for c++ executables
 LDEXECXX:=@UNCYGDRIVE@ @LDEXECXX@
 
-# If cross compiling, then define CROSS_COMPILE_ARCH:=cpu_name here.
-@DEFINE_CROSS_COMPILE_ARCH@
-# The HOSTCC should really be named BUILDCC, ie build executable for
-# the build platform. Same as CC when not cross compiling.
-HOSTCC:=@UNCYGDRIVE@ @HOSTCC@
-HOSTCXX:=@UNCYGDRIVE@ @HOSTCXX@
-# And of course, the jdk spells HOSTCC as NIO_CC/HOST_CC 
-HOST_CC:=@UNCYGDRIVE@ @HOSTCC@
-NIO_CC:=@UNCYGDRIVE@ @HOSTCC@
-
-HOST_LD:=@UNCYGDRIVE@ @HOSTLD@
+# BUILD_CC/BUILD_LD is a compiler/linker that generates code that is runnable on the
+# build platform.
+BUILD_CC:=@UNCYGDRIVE@ @BUILD_CC@
+BUILD_LD:=@UNCYGDRIVE@ @BUILD_LD@
 
 AS:=@UNCYGDRIVE@ @AS@
-ASFLAGS:=@ASFLAGS@
 
-# AR is used to create a static library (is ar in posix, lib.exe in winapi)
+# AR is used to create a static library (is ar in posix, lib.exe in windows)
 AR:=@UNCYGDRIVE@ @AR@
 ARFLAGS:=@ARFLAGS@
 
-NM:=@UNCYGDRIVE@ @NM@
-STRIP:=@UNCYGDRIVE@ @STRIP@
-MCS:=@UNCYGDRIVE@ @MCS@
+NM:=@NM@
+STRIP:=@STRIP@
+MCS:=@MCS@
+
+LIPO:=@LIPO@
 
 # Command to create a shared library
 SHARED_LIBRARY_FLAGS:=@SHARED_LIBRARY_FLAGS@
@@ -414,6 +381,7 @@
 # Set origin using the linker, ie use the relative path to the dependent library to find the dependees.
 # (Note absence of := assignment, because we do not want to evaluate the macro body here)
 SET_SHARED_LIBRARY_ORIGIN=@SET_SHARED_LIBRARY_ORIGIN@
+SET_EXECUTABLE_ORIGIN=@SET_EXECUTABLE_ORIGIN@
 
 # Different OS:es have different ways of naming shared libraries.
 # The SHARED_LIBRARY macro takes "verify" as and argument and returns:
@@ -432,21 +400,20 @@
 
 JAVA_FLAGS:=@BOOT_JDK_JVMARGS@
 
-JAVA=@UNCYGDRIVE@ @JAVA@ $(JAVA_FLAGS)
+JAVA=@UNCYGDRIVE@ $(BOOT_JDK)/bin/java $(JAVA_FLAGS)
 
-JAVAC:=@UNCYGDRIVE@ @JAVAC@
-JAVAC_FLAGS:=@JAVAC_FLAGS@
-
-JAVAH:=@UNCYGDRIVE@ @JAVAH@
+JAVAC=@UNCYGDRIVE@ $(BOOT_JDK)/bin/javac
+# Hotspot sets this variable before reading the SPEC when compiling sa-jdi.jar. Avoid
+# overriding that value by using ?=.
+JAVAC_FLAGS?=@JAVAC_FLAGS@
 
-JAR:=@UNCYGDRIVE@ @JAR@
+JAVAH=@UNCYGDRIVE@ $(BOOT_JDK)/bin/javah
 
-RMIC:=@UNCYGDRIVE@ @RMIC@
+JAR=@UNCYGDRIVE@ $(BOOT_JDK)/bin/jar
 
-NATIVE2ASCII:=@UNCYGDRIVE@ @NATIVE2ASCII@
+RMIC=@UNCYGDRIVE@ $(BOOT_JDK)/bin/rmic
 
-BOOT_JAR_CMD:=@UNCYGDRIVE@ @JAR@
-BOOT_JAR_JFLAGS:=
+NATIVE2ASCII=@UNCYGDRIVE@ $(BOOT_JDK)/bin/native2ascii
 
 # Base flags for RC
 # Guarding this against resetting value. Legacy make files include spec multiple
@@ -456,11 +423,12 @@
 endif
 
 # A specific java binary with specific options can be used to run
-# the long running background javac server and other long running tasks.
-SERVER_JAVA:=@UNCYGDRIVE@ @SERVER_JAVA@
+# the long running background sjavac servers and other long running tasks.
+SJAVAC_SERVER_JAVA:=@UNCYGDRIVE@ @SJAVAC_SERVER_JAVA@
 
 # Tools adhering to a minimal and common standard of posix compliance.
 AWK:=@AWK@
+BASENAME:=@BASENAME@
 CAT:=@CAT@
 CCACHE:=@CCACHE@
 # CD is going away, but remains to cater for legacy makefiles.
@@ -520,8 +488,6 @@
 BUILD_LOG_WRAPPER:=@BUILD_LOG_WRAPPER@
 
 # Build setup
-ENABLE_DOCS:=@ENABLE_DOCS@
-GENERATE_DOCS:=@ENABLE_DOCS@
 DISABLE_NIMBUS:=@DISABLE_NIMBUS@
 ENABLE_JFR=@ENABLE_JFR@
 USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@
@@ -561,17 +527,6 @@
 
 ####################################################
 #
-# Legacy Hotspot support
-
-HOTSPOT_DIST:=@HOTSPOT_DIST@
-HOTSPOT_MAKE_ARGS:=@HOTSPOT_MAKE_ARGS@
-# This is used from the libjvm build for C/C++ code.
-HOTSPOT_BUILD_JOBS:=@CONCURRENT_BUILD_JOBS@
-# Control wether Hotspot runs Queens test after building
-TEST_IN_BUILD=@TEST_IN_BUILD@
-
-####################################################
-#
 # INSTALLATION
 #
 
@@ -634,5 +589,5 @@
 OS_VERSION_MINOR:=@OS_VERSION_MINOR@
 OS_VERSION_MICRO:=@OS_VERSION_MICRO@
 
-# Include the closed-spec.gmk file if it exists
--include $(dir @SPEC@)/closed-spec.gmk
+# Include the custom-spec.gmk file if it exists
+-include $(dir @SPEC@)/custom-spec.gmk
--- a/common/autoconf/spec.sh.in	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/spec.sh.in	Tue Sep 25 11:48:00 2012 -0700
@@ -23,505 +23,14 @@
 # questions.
 #
 
-# Configured"@DATE_WHEN_CONFIGURED@ to build for a @OPENJDK_TARGET_SYSTEM@ system,
-# using 'configure @CONFIGURE_COMMAND_LINE@'
-
-# The "human readable" name of this configuration
-CONF_NAME="@CONF_NAME@"
-
-# The built jdk will run in this target system.
-OPENJDK_TARGET_SYSTEM="@OPENJDK_TARGET_SYSTEM@"
-
-OPENJDK_TARGET_OS="@OPENJDK_TARGET_OS@"
-OPENJDK_TARGET_OS_FAMILY="@OPENJDK_TARGET_OS_FAMILY@"
-OPENJDK_TARGET_OS_API="@OPENJDK_TARGET_OS_API@"
-
-OPENJDK_TARGET_CPU="@OPENJDK_TARGET_CPU@"
-OPENJDK_TARGET_CPU_ARCH="@OPENJDK_TARGET_CPU_ARCH@"
-OPENJDK_TARGET_CPU_BITS="@OPENJDK_TARGET_CPU_BITS@"
-OPENJDK_TARGET_CPU_ENDIAN="@OPENJDK_TARGET_CPU_ENDIAN@"
-
-# We are building on this build system.
-# When not cross-compiling, it is the same as the target.
-OPENJDK_BUILD_SYSTEM="@OPENJDK_BUILD_SYSTEM@"
-
-OPENJDK_BUILD_OS="@OPENJDK_BUILD_OS@"
-OPENJDK_BUILD_OS_FAMILY="@OPENJDK_BUILD_OS_FAMILY@"
-OPENJDK_BUILD_OS_API="@OPENJDK_BUILD_OS_API@"
-
-OPENJDK_BUILD_CPU="@OPENJDK_BUILD_CPU@"
-OPENJDK_BUILD_CPU_ARCH="@OPENJDK_BUILD_CPU_ARCH@"
-OPENJDK_BUILD_CPU_BITS="@OPENJDK_BUILD_CPU_BITS@"
-OPENJDK_BUILD_CPU_ENDIAN="@OPENJDK_BUILD_CPU_ENDIAN@"
-
-# Legacy OS values for use in release file.
-REQUIRED_OS_NAME="@REQUIRED_OS_NAME@"
-REQUIRED_OS_VERSION="@REQUIRED_OS_VERSION@"
-
-# Old name for OPENJDK_TARGET_OS (aix,bsd,hpux,linux,macosx,solaris,windows etc)
-PLATFORM="@OPENJDK_TARGET_OS@"
-# Old name for OPENJDK_TARGET_CPU, uses i586 and amd64, instead of ia32 and x64.
-ARCH="@LEGACY_OPENJDK_TARGET_CPU1@"
-# Yet another name for arch used for an extra subdir below the jvm lib.
-# Uses i386 and amd64, instead of ia32 and x64.
-LIBARCH="@LEGACY_OPENJDK_TARGET_CPU2@"
-# Use to switch between solaris and windows subdirs in the jdk.
-LEGACY_OPENJDK_TARGET_OS_API="@LEGACY_OPENJDK_TARGET_OS_API@"
-# 32 or 64 bit
-ARCH_DATA_MODEL="@OPENJDK_TARGET_CPU_BITS@"
-# Legacy setting for building for a 64 bit machine.
-# If yes then this expands to _LP64=1
-ENDIAN="@OPENJDK_TARGET_CPU_ENDIAN@"
-JIGSAW="@JIGSAW@"
-LIBM=-lm
-LIBDL="@LIBDL@"
-
-# colon or semicolon
-PATH_SEP="@PATH_SEP@"
-
-# The sys root where standard headers and libraries are found.
-# Usually not needed since the configure script should have
-# taken it into account already when setting CFLAGS et al.
-SYS_ROOT="@SYS_ROOT@"
-
-# Paths to the source code
-SRC_ROOT="@SRC_ROOT@"
-ADD_SRC_ROOT="@ADD_SRC_ROOT@"
-OVERRIDE_SRC_ROOT="@OVERRIDE_SRC_ROOT@"
-TOPDIR="@SRC_ROOT@"
-OUTPUT_ROOT="@OUTPUT_ROOT@"
-JDK_MAKE_SHARED_DIR="@JDK_TOPDIR@"/makefiles/common/shared
-JDK_TOPDIR="@JDK_TOPDIR@"
-LANGTOOLS_TOPDIR="@LANGTOOLS_TOPDIR@"
-CORBA_TOPDIR="@CORBA_TOPDIR@"
-JAXP_TOPDIR="@JAXP_TOPDIR@"
-JAXWS_TOPDIR="@JAXWS_TOPDIR@"
-HOTSPOT_TOPDIR="@HOTSPOT_TOPDIR@"
-COPYRIGHT_YEAR="@COPYRIGHT_YEAR@"
-
-# Information gathered from the version.numbers file.
-JDK_MAJOR_VERSION="@JDK_MAJOR_VERSION@"
-JDK_MINOR_VERSION="@JDK_MINOR_VERSION@"
-JDK_MICRO_VERSION="@JDK_MICRO_VERSION@"
-JDK_UPDATE_VERSION="@JDK_UPDATE_VERSION@"
-JDK_BUILD_NUMBER="@JDK_BUILD_NUMBER@"
-MILESTONE="@MILESTONE@"
-LAUNCHER_NAME="@LAUNCHER_NAME@"
-PRODUCT_NAME="@PRODUCT_NAME@"
-PRODUCT_SUFFIX="@PRODUCT_SUFFIX@"
-JDK_RC_PLATFORM_NAME="@JDK_RC_PLATFORM_NAME@"
-COMPANY_NAME="@COMPANY_NAME@"
-
-# Different version strings generated from the above information.
-JDK_VERSION="@JDK_VERSION@"
-RUNTIME_NAME="@RUNTIME_NAME@"
-FULL_VERSION="@FULL_VERSION@"
-JRE_RELEASE_VERSION="@FULL_VERSION@"
-RELEASE="@RELEASE@"
-COOKED_BUILD_NUMBER="@COOKED_BUILD_NUMBER@"
-
-# How to compile the code: release, fastdebug or slowdebug
-DEBUG_LEVEL="@DEBUG_LEVEL@"
-
-# This is the JDK variant to build.
-# The JDK variant is a name for a specific set of modules to be compiled for the JDK.
-JDK_VARIANT="@JDK_VARIANT@"
-
-# Should we compile support for running with a graphical UI? (ie headful)
-# Should we compile support for running without? (ie headless)
-SUPPORT_HEADFUL="@SUPPORT_HEADFUL@"
-SUPPORT_HEADLESS="@SUPPORT_HEADLESS@"
-
-# These are the libjvms that we want to build.
-# The java launcher uses the default.
-# The other can be selected by specifying -client -server -kernel -zero or -zeroshark
-# on the java launcher command line.
-JVM_VARIANTS="@JVM_VARIANTS@"
-JVM_VARIANT_SERVER="@JVM_VARIANT_SERVER@"
-JVM_VARIANT_CLIENT="@JVM_VARIANT_CLIENT@"
-JVM_VARIANT_KERNEL="@JVM_VARIANT_KERNEL@"
-JVM_VARIANT_ZERO="@JVM_VARIANT_ZERO@"
-JVM_VARIANT_ZEROSHARK="@JVM_VARIANT_ZEROSHARK@"
-
-# Legacy setting: OPT or DBG
-VARIANT="@VARIANT@"
-# Legacy setting: true or false
-FASTDEBUG="@FASTDEBUG@"
-# Legacy setting: debugging the class files?
-DEBUG_CLASSFILES="@DEBUG_CLASSFILES@"
-# Legacy setting: -debug or -fastdebug
-BUILD_VARIANT_RELEASE="@BUILD_VARIANT_RELEASE@"
-
-LANGTOOLS_OUTPUTDIR="@LANGTOOLS_OUTPUTDIR@"
-CORBA_OUTPUTDIR="@CORBA_OUTPUTDIR@"
-JAXP_OUTPUTDIR="@JAXP_OUTPUTDIR@"
-JAXWS_OUTPUTDIR="@JAXWS_OUTPUTDIR@"
-HOTSPOT_OUTPUTDIR="@HOTSPOT_OUTPUTDIR@"
-
-# This where a working jvm is built.
-# You can run ${JDK_OUTPUTDIR}/bin/java
-# Though the layout of the contents of ${JDK_OUTPUTDIR} is not
-# yet the same as a default installation.
-JDK_OUTPUTDIR="@OUTPUT_ROOT@"/jdk
-
-# When you run "make install" it will create the standardized
-# layout for the jdk and the jre inside the images subdir.
-# Then it will copy the contents of the jdk into the installation
-# directory.
-IMAGES_OUTPUTDIR="@OUTPUT_ROOT@"/images
-
-LANGTOOLS_DIST="@LANGTOOLS_DIST@"
-CORBA_DIST="@CORBA_DIST@"
-JAXP_DIST="@JAXP_DIST@"
-JAXWS_DIST="@JAXWS_DIST@"
-HOTSPOT_DIST="@HOTSPOT_DIST@"
-
-# Legacy variables used by Release.gmk
-JDK_IMAGE_DIR=${IMAGES_OUTPUTDIR}/j2sdk-image
-JRE_IMAGE_DIR=${IMAGES_OUTPUTDIR}/j2re-image
-
-# Can be /sparcv9 or /amd64 on Solaris
-ISA_DIR="@LEGACY_OPENJDK_TARGET_CPU3@"
-BINDIR="${JDK_OUTPUTDIR}/bin${ISA_DIR}"
-
-# The boot jdk to use
-ALT_BOOTDIR="@BOOT_JDK@"
-BOOT_JDK="@BOOT_JDK@"
-BOOT_JDK_JVMARGS="@BOOT_JDK_JVMARGS@"
-BOOT_RTJAR="@BOOT_RTJAR@"
-BOOT_TOOLSJAR="@BOOT_TOOLSJAR@"
-
-# When compiling Java source to be run by the boot jdk
-# use these extra flags, eg -source 6 -target 6
-BOOT_JDK_SOURCETARGET="@BOOT_JDK_SOURCETARGET@"
-
-# Information about the build system
-NUM_CORES="@NUM_CORES@"
-# This is used from the jdk build for C/C++ code.
-PARALLEL_COMPILE_JOBS="@CONCURRENT_BUILD_JOBS@"
-# Store javac server synchronization files here, and
-# the javac server log files.
-JAVAC_SERVERS="@JAVAC_SERVERS@"
-# Should we use a javac server or not? The javac server gives
-# an enormous performance improvement since it reduces the
-# startup costs of javac and reuses as much as possible of intermediate
-# compilation work. But if we want to compile with a non-Java
-# javac compiler, like gcj. Then we cannot use javac server and
-# this variable is set to false.
-JAVAC_USE_REMOTE="@JAVAC_USE_REMOTE@"
-# We can block the Javac server to never use more cores than this.
-# This is not for performance reasons, but for memory usage, since each
-# core requires its own JavaCompiler. We might have 64 cores and 4GB
-# of memory, 64 JavaCompilers will currently not fit in a 3GB heap.
-# Since there is no sharing of data between the JavaCompilers.
-JAVAC_SERVER_CORES="@JAVAC_SERVER_CORES@"
-# Should we use dependency tracking between Java packages? true or false.
-JAVAC_USE_DEPS="@JAVAC_USE_DEPS@"
-# We can invoke javac: SINGLE_THREADED_BATCH or MULTI_CORE_CONCURRENT
-JAVAC_USE_MODE="@JAVAC_USE_MODE@"
-# Enable not yet complete sjavac support.
-ENABLE_SJAVAC="@ENABLE_SJAVAC@"
-
-# The OpenJDK makefiles should be changed to using the standard
-# configure output ..._CFLAGS and ..._LIBS. In the meantime we
-# extract the information here.
-FREETYPE2_LIB_PATH="@FREETYPE2_LIB_PATH@"
-FREETYPE2_LIBS="@FREETYPE2_LIBS@"
-FREETYPE2_CFLAGS="@FREETYPE2_CFLAGS@"
-USING_SYSTEM_FT_LIB="@USING_SYSTEM_FT_LIB@"
-CUPS_CFLAGS="@CUPS_CFLAGS@"
-
-PACKAGE_PATH="@PACKAGE_PATH@"
-
-# Source file for cacerts
-CACERTS_FILE="@CACERTS_FILE@"
-
-#MOZILLA_HEADERS_PATH=
-
-# Necessary additional compiler flags to compile X11 
-X_CFLAGS="@X_CFLAGS@"
-X_LIBS="@X_LIBS@"
-OPENWIN_HOME="@OPENWIN_HOME@"
-
-# There are two types: CC or CL
-# CC is gcc and others behaving reasonably similar.
-# CL is cl.exe only.
-COMPILER_TYPE="@COMPILER_TYPE@"
-
-# Flags used for overriding the default opt setting for a C/C++ source file.
-C_O_FLAG_HIGHEST="@C_O_FLAG_HIGHEST@"
-C_O_FLAG_HI="@C_O_FLAG_HI@"
-C_O_FLAG_NORM="@C_O_FLAG_NORM@"
-C_O_FLAG_NONE="@C_O_FLAG_NONE@"
-CXX_O_FLAG_HIGHEST="@CXX_O_FLAG_HIGHEST@"
-CXX_O_FLAG_HI="@CXX_O_FLAG_HI@"
-CXX_O_FLAG_NORM="@CXX_O_FLAG_NORM@"
-CXX_O_FLAG_NONE="@CXX_O_FLAG_NONE@"
-
-C_FLAG_DEPS="@C_FLAG_DEPS@"
-CXX_FLAG_DEPS="@CXX_FLAG_DEPS@"
-
-# Tools that potentially need to be cross compilation aware.
-CC="@UNCYGDRIVE@ @CCACHE@ @CC@"
-
-# CFLAGS used to compile the jdk native libraries (C-code)
-CFLAGS_JDKLIB="@CFLAGS_JDKLIB@"
-CXXFLAGS_JDKLIB="@CXXFLAGS_JDKLIB@"
-
-# CFLAGS used to compile the jdk native launchers (C-code)
-CFLAGS_JDKEXE="@CFLAGS_JDKEXE@"
-CXXFLAGS_JDKEXE="@CXXFLAGS_JDKEXE@"
-
-CXX="@UNCYGDRIVE@ @CCACHE@ @CXX@"
-#CXXFLAGS="@CXXFLAGS@"
-
-OBJC="@CCACHE@ @OBJC@"
-#OBJCFLAGS="@OBJCFLAGS@"
-
-CPP="@UNCYGDRIVE@ @CPP@"
-#CPPFLAGS="@CPPFLAGS@"
-
-# The linker can be gcc or ld on posix systems, or link.exe on winapi systems.
-LD="@UNCYGDRIVE@ @LD@"
-
-# LDFLAGS used to link the jdk native libraries (C-code)
-LDFLAGS_JDKLIB="@LDFLAGS_JDKLIB@"
-LDFLAGS_JDKLIB_SUFFIX="@LDFLAGS_JDKLIB_SUFFIX@"
-
-# On some platforms the linker cannot be used to create executables, thus
-# the need for a separate LDEXE command.
-LDEXE="@UNCYGDRIVE@ @LDEXE@"
-
-# LDFLAGS used to link the jdk native launchers (C-code)
-LDFLAGS_JDKEXE="@LDFLAGS_JDKEXE@"
-LDFLAGS_JDKEXE_SUFFIX="@LDFLAGS_JDKEXE_SUFFIX@"
-
-# Sometimes a different linker is needed for c++ libs
-LDCXX="@UNCYGDRIVE@ @LDCXX@"
-# The flags for linking libstdc++ linker.
-LIBCXX="@LIBCXX@"
-
-# Sometimes a different linker is needed for c++ executables
-LDEXECXX="@UNCYGDRIVE@ @LDEXECXX@"
-
-# If cross compiling, then define CROSS_COMPILE_ARCH=cpu_name here.
-# The HOSTCC should really be named BUILDCC, ie build executable for
-# the build platform. Same as CC when not cross compiling.
-HOSTCC="@HOSTCC@"
-HOSTCXX="@HOSTCXX@"
-# And of course, the jdk spells HOSTCC as NIO_CC/HOST_CC 
-HOST_CC="@HOSTCC@"
-NIO_CC="@HOSTCC@"
-
-AS="@AS@"
-ASFLAGS="@ASFLAGS@"
-
-# AR is used to create a static library (is ar in posix, lib.exe in winapi)
-AR="@UNCYGDRIVE@ @AR@"
-ARFLAGS="@ARFLAGS@"
-
-NM="@NM@"
-STRIP="@STRIP@"
-MCS="@MCS@"
-
-# Command to create a shared library
-SHARED_LIBRARY_FLAGS="@SHARED_LIBRARY_FLAGS@"
-
-# Options to linker to specify a mapfile. 
-# (Note absence of = assignment, because we do not want to evaluate the macro body here)
-SET_SHARED_LIBRARY_MAPFILE="@SET_SHARED_LIBRARY_MAPFILE@"
-
-# Options for C/CXX compiler to be used if linking is performed
-#   using reorder file
-C_FLAG_REORDER="@C_FLAG_REORDER@"
-CXX_FLAG_REORDER="@CXX_FLAG_REORDER@"
-
-#
-# Options for generating debug symbols
-ENABLE_DEBUG_SYMBOLS="@ENABLE_DEBUG_SYMBOLS@"
-CFLAGS_DEBUG_SYMBOLS="@CFLAGS_DEBUG_SYMBOLS@"
-CXXFLAGS_DEBUG_SYMBOLS="@CXXFLAGS_DEBUG_SYMBOLS@"
-ZIP_DEBUGINFO_FILES="@ZIP_DEBUGINFO_FILES@"
-
-# Options to linker to specify the library name.
-# (Note absence of = assignment, because we do not want to evaluate the macro body here)
-SET_SHARED_LIBRARY_NAME="@SET_SHARED_LIBRARY_NAME@"
-
-# Set origin using the linker, ie use the relative path to the dependent library to find the dependees.
-# (Note absence of = assignment, because we do not want to evaluate the macro body here)
-SET_SHARED_LIBRARY_ORIGIN="@SET_SHARED_LIBRARY_ORIGIN@"
-
-# Different OS:es have different ways of naming shared libraries.
-# The SHARED_LIBRARY macro takes "verify" as and argument and returns:
-#    "libverify.so" or "libverify.dylib" or "verify.dll" depending on platform.
-# (Note absence of = assignment, because we do not want to evaluate the macro body here)
-SHARED_LIBRARY="@SHARED_LIBRARY@"
-STATIC_LIBRARY="@STATIC_LIBRARY@"
-LIBRARY_PREFIX="@LIBRARY_PREFIX@"
-SHARED_LIBRARY_SUFFIX="@SHARED_LIBRARY_SUFFIX@"
-STATIC_LIBRARY_SUFFIX="@STATIC_LIBRARY_SUFFIX@"
-EXE_SUFFIX="@EXE_SUFFIX@"
-OBJ_SUFFIX="@OBJ_SUFFIX@"
+CAT="@CAT@"
+CD=cd
+CP="@CP@"
+DIFF="@DIFF@"
+ECHO="@ECHO@"
+FIND="@FIND@"
+GREP="@GREP@"
+RM="@RM@"
+SED="@SED@"
 
 POST_STRIP_CMD="@POST_STRIP_CMD@"
-POST_MCS_CMD='@POST_MCS_CMD@'
-
-JAVA_FLAGS="@BOOT_JDK_JVMARGS@"
-
-JAVA="@UNCYGDRIVE@ @JAVA@ ${JAVA_FLAGS}"
-
-JAVAC="@UNCYGDRIVE@ @JAVAC@"
-JAVAC_FLAGS="@JAVAC_FLAGS@"
-
-JAVAH="@UNCYGDRIVE@ @JAVAH@"
-
-JAR="@UNCYGDRIVE@ @JAR@"
-
-RMIC="@UNCYGDRIVE@ @RMIC@"
-
-NATIVE2ASCII="@UNCYGDRIVE@ @NATIVE2ASCII@"
-
-BOOT_JAR_CMD="@UNCYGDRIVE@ @JAR@"
-BOOT_JAR_JFLAGS=
-
-# Tools adhering to a minimal and common standard of posix compliance.
-AWK="@AWK@"
-CAT="@CAT@"
-CCACHE="@CCACHE@"
-# CD is going away, but remains to cater for legacy makefiles.
-CD=cd
-CHMOD="@CHMOD@"
-CP="@CP@"
-CPIO="@CPIO@"
-CUT="@CUT@"
-DATE="@DATE@"
-DF="@DF@"
-DIFF="@DIFF@"
-FIND="@FIND@"
-FIND_DELETE="@FIND_DELETE@"
-ECHO="@ECHO@"
-EGREP="@EGREP@"
-FGREP="@FGREP@"
-GREP="@GREP@"
-HEAD="@HEAD@"
-LS="@LS@"
-LN="@LN@"
-MKDIR="@MKDIR@"
-MV="@MV@"
-NAWK="@NAWK@"
-PRINTF="@PRINTF@"
-PWD="@THEPWDCMD@"
-RM="@RM@"
-SED="@SED@"
-SH="@SH@"
-SORT="@SORT@"
-TAR="@TAR@"
-TAIL="@TAIL@"
-TEE="@TEE@"
-TR="@TR@"
-TOUCH="@TOUCH@"
-WC="@WC@"
-XARGS="@XARGS@"
-ZIPEXE="@ZIP@"
-ZIP="@ZIP@"
-UNZIP="@UNZIP@"
-MT="@UNCYGDRIVE@ @MT@"
-RC="@UNCYGDRIVE@ @RC@"
-DUMPBIN="@UNCYGDRIVE@ @DUMPBIN@"
-CYGPATH="@CYGPATH@"
-LDD="@LDD@"
-OTOOL="@OTOOL@"
-READELF="@READELF@"
-EXPR="@EXPR@"
-FILE="@FILE@"
-HG="@HG@"
-OBJCOPY="@OBJCOPY@"
-
-UNCYGDRIVE="@UNCYGDRIVE@"
-
-# Build setup
-ENABLE_DOCS="@ENABLE_DOCS@"
-GENERATE_DOCS="@ENABLE_DOCS@"
-DISABLE_NIMBUS="@DISABLE_NIMBUS@"
-USE_EXTERNAL_LIBJPEG="@USE_EXTERNAL_LIBJPEG@"
-USE_EXTERNAL_LIBGIF="@USE_EXTERNAL_LIBGIF@"
-USE_EXTERNAL_LIBZ="@USE_EXTERNAL_LIBZ@"
-LIBZIP_CAN_USE_MMAP="@LIBZIP_CAN_USE_MMAP@"
-CHECK_FOR_VCINSTALLDIR="@CHECK_FOR_VCINSTALLDIR@"
-MSVCRNN_DLL="@MSVCR100DLL@"
-
-
-####################################################
-#
-# Legacy Hotspot support
-
-HOTSPOT_DIST="@HOTSPOT_DIST@"
-HOTSPOT_MAKE_ARGS="@HOTSPOT_MAKE_ARGS@"
-# This is used from the libjvm build for C/C++ code.
-HOTSPOT_BUILD_JOBS="@CONCURRENT_BUILD_JOBS@"
-# Control wether Hotspot runs Queens test after building
-TEST_IN_BUILD="@TEST_IN_BUILD@"
-
-####################################################
-#
-# INSTALLATION
-#
-
-# Common prefix for all installed files. Defaults to /usr/local,
-# but /opt/myjdk is another common version. 
-INSTALL_PREFIX="@prefix@"
-
-# Directories containing architecture-dependent files should be relative to exec_prefix
-INSTALL_EXECPREFIX="@exec_prefix@"
-
-# java,javac,javah,javap etc are installed here.
-INSTALL_BINDIR="@bindir@"
-
-# Read only architecture-independent data
-INSTALL_DATADIR="@datadir@"
-
-# Root of above.
-INSTALL_DATAROOTDIR="@datarootdir@"
-
-# Doc files, other than info and man.
-INSTALL_DOCDIR="@docdir@"
-
-# Html documentation
-INSTALL_HTMLDIR="@htmldir@"
-
-# Installing C header files, JNI headers for example.
-INSTALL_INCLUDEDIR="@includedir@"
-
-# Installing library files....
-INSTALL_INCLUDEDIR="@libdir@"
-
-# Executables that other programs run.
-INSTALL_LIBEXECDIR="@libexecdir@"
-
-# Locale-dependent but architecture-independent data, such as message catalogs. 
-INSTALL_LOCALEDIR="@localedir@"
-
-# Modifiable single-machine data
-INSTALL_LOCALSTATEDIR="@localstatedir@"
-
-# Man pages
-INSTALL_MANDIR="@mandir@"
-
-# Modifiable architecture-independent data.
-INSTALL_SHAREDSTATEDIR="@sharedstatedir@"
-
-# Read-only single-machine data
-INSTALL_SYSCONFDIR="@sysconfdir@"
-
-
-####################################################
-#
-# Misc
-#
-
-# Name of Service Agent library
-SALIB_NAME="@SALIB_NAME@"
-
-OS_VERSION_MAJOR="@OS_VERSION_MAJOR@"
-OS_VERSION_MINOR="@OS_VERSION_MINOR@"
-OS_VERSION_MICRO="@OS_VERSION_MICRO@"
--- a/common/autoconf/toolchain.m4	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/autoconf/toolchain.m4	Tue Sep 25 11:48:00 2012 -0700
@@ -31,6 +31,19 @@
 # the set env variables into the spec file.
 SETUPDEVENV="# No special vars"
 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+    # Store path to cygwin link.exe to help excluding it when searching for 
+    # VS linker.
+    AC_PATH_PROG(CYGWIN_LINK, link)
+    AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
+    "$CYGWIN_LINK" --version > /dev/null
+    if test $? -eq 0 ; then
+      AC_MSG_RESULT([yes])
+    else
+      AC_MSG_RESULT([no])
+      # This might be the VS linker. Don't exclude it later on.
+      CYGWIN_LINK=""
+    fi
+    
     # If vcvarsall.bat has been run, then VCINSTALLDIR is set.
     if test "x$VCINSTALLDIR" != x; then
         # No further setup is needed. The build will happen from this kind
@@ -57,12 +70,12 @@
             AC_MSG_RESULT([no])
             AC_MSG_ERROR([Tried to find a VS installation using both $SEARCH_ROOT but failed. Please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.])
         fi
-        case "$LEGACY_OPENJDK_TARGET_CPU1" in
-          i?86)
+        case "$OPENJDK_TARGET_CPU" in
+          x86)
             VARSBAT_ARCH=x86
             ;;
-          *)
-            VARSBAT_ARCH=$LEGACY_OPENJDK_TARGET_CPU1
+          x86_64)
+            VARSBAT_ARCH=amd64
             ;;
         esac
         # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
@@ -122,9 +135,6 @@
 # Configure the development tool paths and potential sysroot.
 #
 AC_LANG(C++)
-DEVKIT=
-SYS_ROOT=/
-AC_SUBST(SYS_ROOT)
 
 # The option used to specify the target .o,.a or .so file.
 # When compiling, how to specify the to be created object file.
@@ -153,44 +163,28 @@
 # Setting only --host, does not seem to be really supported.
 # Please set both --build and --host if you want to cross compile.
 
-DEFINE_CROSS_COMPILE_ARCH=""
-HOSTCC=""
-HOSTCXX=""
-HOSTLD=""
-AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
-AC_MSG_CHECKING([if this is a cross compile])
-if test "x$OPENJDK_BUILD_SYSTEM" != "x$OPENJDK_TARGET_SYSTEM"; then
-    AC_MSG_RESULT([yes, from $OPENJDK_BUILD_SYSTEM to $OPENJDK_TARGET_SYSTEM])
-    # We have detected a cross compile!
-    DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$LEGACY_OPENJDK_TARGET_CPU1"
+if test "x$COMPILE_TYPE" = "xcross"; then
     # Now we to find a C/C++ compiler that can build executables for the build
     # platform. We can't use the AC_PROG_CC macro, since it can only be used
-    # once.
-    AC_PATH_PROGS(HOSTCC, [cl cc gcc])
-    WHICHCMD(HOSTCC)
-    AC_PATH_PROGS(HOSTCXX, [cl CC g++])
-    WHICHCMD(HOSTCXX)
-    AC_PATH_PROG(HOSTLD, ld)
-    WHICHCMD(HOSTLD)
-    # Building for the build platform should be easy. Therefore
-    # we do not need any linkers or assemblers etc.    
-else
-    AC_MSG_RESULT([no])
+    # once. Also, we need to do this before adding a tools dir to the path,
+    # otherwise we might pick up cross-compilers which don't use standard naming.
+    # Otherwise, we'll set the BUILD_tools to the native tools, but that'll have
+    # to wait until they are properly discovered.
+    AC_PATH_PROGS(BUILD_CC, [cl cc gcc])
+    SET_FULL_PATH(BUILD_CC)
+    AC_PATH_PROGS(BUILD_CXX, [cl CC g++])
+    SET_FULL_PATH(BUILD_CXX)
+    AC_PATH_PROG(BUILD_LD, ld)
+    SET_FULL_PATH(BUILD_LD)
 fi
+AC_SUBST(BUILD_CC)
+AC_SUBST(BUILD_CXX)
+AC_SUBST(BUILD_LD)
 
-# You can force the sys-root if the sys-root encoded into the cross compiler tools
-# is not correct.
-AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
-    [pass this sys-root to the compilers and linker (useful if the sys-root encoded in
-     the cross compiler tools is incorrect)])])
-
-if test "x$with_sys_root" != x; then
-    SYS_ROOT=$with_sys_root
-fi
-                     
 # If a devkit is found on the builddeps server, then prepend its path to the
 # PATH variable. If there are cross compilers available in the devkit, these
 # will be found by AC_PROG_CC et al.
+DEVKIT=
 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
                     [# Found devkit
                      PATH="$DEVKIT/bin:$PATH"
@@ -218,21 +212,6 @@
 ORG_CXXFLAGS="$CXXFLAGS"
 ORG_OBJCFLAGS="$OBJCFLAGS"
 
-AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
-	[search this directory for compilers and tools])], [TOOLS_DIR=$with_tools_dir])
-
-AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
-	[use this directory as base for tools-dir and sys-root])], [
-    if test "x$with_sys_root" != x; then
-      AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time])
-    fi
-    if test "x$with_tools_dir" != x; then
-      AC_MSG_ERROR([Cannot specify both --with-devkit and --with-tools-dir at the same time])
-    fi
-    TOOLS_DIR=$with_devkit/bin
-    SYS_ROOT=$with_devkit/$host_alias/libc
-    ])
-
 # autoconf magic only relies on PATH, so update it if tools dir is specified
 OLD_PATH="$PATH"
 if test "x$TOOLS_DIR" != x; then
@@ -251,7 +230,7 @@
     # Do not use cc on MacOSX use gcc instead.
     CC="gcc"
 fi
-WHICHCMD(CC)
+SET_FULL_PATH(CC)
 
 AC_PROG_CXX([cl CC g++])
 if test "x$CXX" = xCC && test "x$OPENJDK_BUILD_OS" = xmacosx; then
@@ -259,7 +238,7 @@
     # c++ code. Override.
     CXX="g++"
 fi
-WHICHCMD(CXX)
+SET_FULL_PATH(CXX)
 
 if test "x$CXX" = x || test "x$CC" = x; then
     HELP_MSG_MISSING_DEPENDENCY([devkit])
@@ -268,7 +247,7 @@
 
 if test "x$OPENJDK_BUILD_OS" != xwindows; then
     AC_PROG_OBJC
-    WHICHCMD(OBJC)
+    SET_FULL_PATH(OBJC)
 else
     OBJC=
 fi
@@ -279,19 +258,11 @@
 CXXFLAGS="$ORG_CXXFLAGS"
 OBJCFLAGS="$ORG_OBJCFLAGS"
 
-# If we are not cross compiling, use the same compilers for
-# building the build platform executables.
-if test "x$DEFINE_CROSS_COMPILE_ARCH" = x; then
-    HOSTCC="$CC"
-    HOSTCXX="$CXX"
-fi
-
-AC_CHECK_TOOL(LD, ld)
-WHICHCMD(LD)
 LD="$CC"
 LDEXE="$CC"
 LDCXX="$CXX"
 LDEXECXX="$CXX"
+AC_SUBST(LD)
 # LDEXE is the linker to use, when creating executables.
 AC_SUBST(LDEXE)
 # Linking C++ libraries.
@@ -299,8 +270,10 @@
 # Linking C++ executables.
 AC_SUBST(LDEXECXX)
 
-AC_CHECK_TOOL(AR, ar)
-WHICHCMD(AR)
+if test "x$OPENJDK_BUILD_OS" != xwindows; then
+    AC_CHECK_TOOL(AR, ar)
+    SET_FULL_PATH(AR)
+fi
 if test "x$OPENJDK_BUILD_OS" = xmacosx; then
     ARFLAGS="-r"
 else
@@ -316,25 +289,31 @@
     EXE_OUT_OPTION=-out:
     LD_OUT_OPTION=-out:
     AR_OUT_OPTION=-out:
-    # On Windows, reject /usr/bin/link, which is a cygwin
+    # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
     # program for something completely different.
-    AC_CHECK_PROG([WINLD], [link],[link],,, [/usr/bin/link])
+    AC_CHECK_PROG([WINLD], [link],[link],,, [$CYGWIN_LINK])
     # Since we must ignore the first found link, WINLD will contain
     # the full path to the link.exe program.
-    WHICHCMD_SPACESAFE([WINLD])
+    SET_FULL_PATH_SPACESAFE([WINLD])
+    printf "Windows linker was found at $WINLD\n"
+    AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
+    "$WINLD" --version > /dev/null
+    if test $? -eq 0 ; then
+      AC_MSG_RESULT([no])
+      AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
+    else
+      AC_MSG_RESULT([yes])
+    fi
     LD="$WINLD"
     LDEXE="$WINLD"
     LDCXX="$WINLD"
     LDEXECXX="$WINLD"
-    # Set HOSTLD to same as LD until we fully support cross compilation
-    # on windows.
-    HOSTLD="$WINLD"
 
     AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
-    WHICHCMD_SPACESAFE([MT])
+    SET_FULL_PATH_SPACESAFE([MT])
     # The resource compiler
     AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
-    WHICHCMD_SPACESAFE([RC])
+    SET_FULL_PATH_SPACESAFE([RC])
 
     RC_FLAGS="-nologo /l 0x409 /r"
     AS_IF([test "x$VARIANT" = xOPT], [
@@ -354,12 +333,12 @@
 
     # lib.exe is used to create static libraries.
     AC_CHECK_PROG([WINAR], [lib],[lib],,,)
-    WHICHCMD_SPACESAFE([WINAR])
+    SET_FULL_PATH_SPACESAFE([WINAR])
     AR="$WINAR"
     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
 
     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
-    WHICHCMD_SPACESAFE([DUMPBIN])
+    SET_FULL_PATH_SPACESAFE([DUMPBIN])
 
     COMPILER_TYPE=CL
     CCXXFLAGS="$CCXXFLAGS -nologo"
@@ -368,10 +347,20 @@
 AC_SUBST(COMPILER_TYPE)
 
 AC_PROG_CPP
-WHICHCMD(CPP)
+SET_FULL_PATH(CPP)
 
 AC_PROG_CXXCPP
-WHICHCMD(CXXCPP)
+SET_FULL_PATH(CXXCPP)
+
+if test "x$COMPILE_TYPE" != "xcross"; then
+    # If we are not cross compiling, use the same compilers for
+    # building the build platform executables. The cross-compilation
+    # case needed to be done earlier, but this can only be done after
+    # the native tools have been localized.
+    BUILD_CC="$CC"
+    BUILD_CXX="$CXX"
+    BUILD_LD="$LD"
+fi
 
 # for solaris we really need solaris tools, and not gnu equivalent
 #   these seems to normally reside in /usr/ccs/bin so add that to path before
@@ -386,27 +375,24 @@
 # Find the right assembler.
 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
     AC_PATH_PROG(AS, as)
-    WHICHCMD(AS)
-    ASFLAGS=" "
+    SET_FULL_PATH(AS)
 else
     AS="$CC -c"
-    ASFLAGS=" "
 fi
 AC_SUBST(AS)
-AC_SUBST(ASFLAGS)
 
 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
-    AC_PATH_PROG(NM, nm)
-    WHICHCMD(NM)
+    AC_PATH_PROGS(NM, [gnm nm])
+    SET_FULL_PATH(NM)
     AC_PATH_PROG(STRIP, strip)
-    WHICHCMD(STRIP)
+    SET_FULL_PATH(STRIP)
     AC_PATH_PROG(MCS, mcs)
-    WHICHCMD(MCS)
-else
+    SET_FULL_PATH(MCS)
+elif test "x$OPENJDK_BUILD_OS" != xwindows; then
     AC_CHECK_TOOL(NM, nm)
-    WHICHCMD(NM)
+    SET_FULL_PATH(NM)
     AC_CHECK_TOOL(STRIP, strip)
-    WHICHCMD(STRIP)
+    SET_FULL_PATH(STRIP)
 fi
 
 ###
@@ -421,6 +407,11 @@
    AC_PATH_TOOL(OBJCOPY, objcopy)
 fi
 
+if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
+   AC_PATH_PROG(LIPO, lipo)
+   SET_FULL_PATH(LIPO)
+fi
+
 # Restore old path without tools dir
 PATH="$OLD_PATH"
 ])
@@ -449,15 +440,13 @@
     SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
     C_FLAG_REORDER=''
     CXX_FLAG_REORDER=''
-    SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN/[$]1'
+    SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
+    SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
     LD="$CC"
     LDEXE="$CC"
     LDCXX="$CXX"
     LDEXECXX="$CXX"
     POST_STRIP_CMD="$STRIP -g"
-    if test "x$JDK_VARIANT" = xembedded; then
-        POST_STRIP_CMD="$STRIP --strip-unneeded"
-    fi
 
     # Linking is different on MacOSX
     if test "x$OPENJDK_BUILD_OS" = xmacosx; then
@@ -470,6 +459,7 @@
         SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 
         SET_SHARED_LIBRARY_MAPFILE=''
         SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
+        SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
         POST_STRIP_CMD="$STRIP -S"
     fi
 else
@@ -480,7 +470,7 @@
         LIBRARY_PREFIX=lib
         SHARED_LIBRARY='lib[$]1.so'
         STATIC_LIBRARY='lib[$]1.a'
-        SHARED_LIBRARY_FLAGS="-z defs -xildoff -ztext -G"
+        SHARED_LIBRARY_FLAGS="-G"
         SHARED_LIBRARY_SUFFIX='.so'
         STATIC_LIBRARY_SUFFIX='.a'
         OBJ_SUFFIX='.o'
@@ -489,7 +479,8 @@
         SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
 	C_FLAG_REORDER='-xF'
 	CXX_FLAG_REORDER='-xF'
-        SET_SHARED_LIBRARY_ORIGIN='-R \$$$$ORIGIN/[$]1'
+        SET_SHARED_LIBRARY_ORIGIN='-R\$$$$ORIGIN[$]1'
+        SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
         CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
         CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
         CFLAGS_JDKLIB_EXTRA='-xstrconst'
@@ -511,6 +502,7 @@
         SET_SHARED_LIBRARY_NAME=''
         SET_SHARED_LIBRARY_MAPFILE=''
         SET_SHARED_LIBRARY_ORIGIN=''
+        SET_EXECUTABLE_ORIGIN=''
     fi
 fi
 
@@ -527,6 +519,7 @@
 AC_SUBST(C_FLAG_REORDER)
 AC_SUBST(CXX_FLAG_REORDER)
 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
+AC_SUBST(SET_EXECUTABLE_ORIGIN)
 AC_SUBST(POST_STRIP_CMD)
 AC_SUBST(POST_MCS_CMD)
 
@@ -542,6 +535,25 @@
 # Setup the opt flags for different compilers
 # and different operating systems.
 #
+
+#
+# NOTE: check for -mstackrealign needs to be below potential addition of -m32
+#
+if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
+    # While waiting for a better solution, the current workaround is to use -mstackrealign.
+    CFLAGS="$CFLAGS -mstackrealign"
+    AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
+    AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
+                   [
+		        AC_MSG_RESULT([yes])
+                   ],
+	           [
+		        AC_MSG_RESULT([no])
+	                AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
+	           ])
+fi
+
 C_FLAG_DEPS="-MMD -MF"
 CXX_FLAG_DEPS="-MMD -MF"
 
@@ -566,7 +578,7 @@
 	    CXXFLAGS_DEBUG_SYMBOLS="-g"
 	    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
 	       CFLAGS_DEBUG_SYMBOLS="-g1"
-	       CXXFLAGS_DEBUG_SYMBOLSG="-g1"
+	       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 	    fi
 	    ;;
 	esac
@@ -578,52 +590,56 @@
         #
         # Forte has different names for this with their C++ compiler...
         #
-	C_FLAG_DEPS="-xMMD -xMF"
-	CXX_FLAG_DEPS="-xMMD -xMF"
+        C_FLAG_DEPS="-xMMD -xMF"
+        CXX_FLAG_DEPS="-xMMD -xMF"
 
-# Extra options used with HIGHEST
-#
-# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
-#          done with care, there are some assumptions below that need to
-#          be understood about the use of pointers, and IEEE behavior.
-#
-# Use non-standard floating point mode (not IEEE 754)
-CC_HIGHEST="$CC_HIGHEST -fns"
-# Do some simplification of floating point arithmetic (not IEEE 754)
-CC_HIGHEST="$CC_HIGHEST -fsimple"
-# Use single precision floating point with 'float'
-CC_HIGHEST="$CC_HIGHEST -fsingle"
-# Assume memory references via basic pointer types do not alias
-#   (Source with excessing pointer casting and data access with mixed 
-#    pointer types are not recommended)
-CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
-# Use intrinsic or inline versions for math/std functions
-#   (If you expect perfect errno behavior, do not use this)
-CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
-# Loop data dependency optimizations (need -xO3 or higher)
-CC_HIGHEST="$CC_HIGHEST -xdepend"
-# Pointer parameters to functions do not overlap
-#   (Similar to -xalias_level=basic usage, but less obvious sometimes.
-#    If you pass in multiple pointers to the same data, do not use this)
-CC_HIGHEST="$CC_HIGHEST -xrestrict"
-# Inline some library routines
-#   (If you expect perfect errno behavior, do not use this)
-CC_HIGHEST="$CC_HIGHEST -xlibmil"
-# Use optimized math routines
-#   (If you expect perfect errno behavior, do not use this)
-#  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
-#CC_HIGHEST="$CC_HIGHEST -xlibmopt"
+        # Extra options used with HIGHEST
+        #
+        # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
+        #          done with care, there are some assumptions below that need to
+        #          be understood about the use of pointers, and IEEE behavior.
+        #
+        # Use non-standard floating point mode (not IEEE 754)
+        CC_HIGHEST="$CC_HIGHEST -fns"
+        # Do some simplification of floating point arithmetic (not IEEE 754)
+        CC_HIGHEST="$CC_HIGHEST -fsimple"
+        # Use single precision floating point with 'float'
+        CC_HIGHEST="$CC_HIGHEST -fsingle"
+        # Assume memory references via basic pointer types do not alias
+        #   (Source with excessing pointer casting and data access with mixed 
+        #    pointer types are not recommended)
+        CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
+        # Use intrinsic or inline versions for math/std functions
+        #   (If you expect perfect errno behavior, do not use this)
+        CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
+        # Loop data dependency optimizations (need -xO3 or higher)
+        CC_HIGHEST="$CC_HIGHEST -xdepend"
+        # Pointer parameters to functions do not overlap
+        #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
+        #    If you pass in multiple pointers to the same data, do not use this)
+        CC_HIGHEST="$CC_HIGHEST -xrestrict"
+        # Inline some library routines
+        #   (If you expect perfect errno behavior, do not use this)
+        CC_HIGHEST="$CC_HIGHEST -xlibmil"
+        # Use optimized math routines
+        #   (If you expect perfect errno behavior, do not use this)
+        #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
+        #CC_HIGHEST="$CC_HIGHEST -xlibmopt"
 
-        case $LEGACY_OPENJDK_TARGET_CPU1 in
-          i586)
-            C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xchip=pentium"
-            C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
-            C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
-            C_O_FLAG_NONE=""
-            CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xchip=pentium"
-            CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz"
-            CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz"
-            CXX_O_FLAG_NONE=""
+        case $OPENJDK_TARGET_CPU_ARCH in
+          x86)
+            C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
+            C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
+            C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
+            C_O_FLAG_NONE="-xregs=no%frameptr"
+            CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
+            CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
+            CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
+            CXX_O_FLAG_NONE="-xregs=no%frameptr"
+            if test "x$OPENJDK_TARGET_CPU" = xx86; then
+               C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
+               CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
+            fi
             ;;
           sparc)
             CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
@@ -647,9 +663,11 @@
     ;;
   CL )
     D_FLAG=
-    C_O_FLAG_HI="-O2"
+    C_O_FLAG_HIGHEST="-O2"
+    C_O_FLAG_HI="-O1"
     C_O_FLAG_NORM="-O1"
     C_O_FLAG_NONE="-Od"
+    CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
     CXX_O_FLAG_HI="$C_O_FLAG_HI"
     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
@@ -680,15 +698,15 @@
 [
 
 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
-   AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags"])
+   AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
 fi
 
 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
-   AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags"])
+   AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
 fi
 
 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
-   AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags"])
+   AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
 fi
 
 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
@@ -704,6 +722,15 @@
 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
 
+# Hotspot needs these set in their legacy form
+LEGACY_EXTRA_CFLAGS=$with_extra_cflags
+LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
+LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
+
+AC_SUBST(LEGACY_EXTRA_CFLAGS)
+AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
+AC_SUBST(LEGACY_EXTRA_LDFLAGS)
+
 ###############################################################################
 #
 # Now setup the CFLAGS and LDFLAGS for the JDK build.
@@ -729,19 +756,30 @@
 	  esac
           ;;
       ossc )
-      	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -norunpath -xnolib"
-      	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX"
+          CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
+          case $OPENJDK_TARGET_CPU_ARCH in
+          x86 )
+            CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -Di386"
+       	    CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
+          ;;
+          esac
+
+      	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
+      	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
+
+          LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
+          LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
           ;;
       cl )
           CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
                -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
 	       -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 	       -DWIN32 -DIAL"
-          case $LEGACY_OPENJDK_TARGET_CPU1 in
-              i?86 )
+          case $OPENJDK_TARGET_CPU in
+              x86 )
                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
                   ;;
-              amd64 )
+              x86_64 )
                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
                   ;;
           esac
@@ -749,24 +787,6 @@
 esac
 
 ###############################################################################
-#
-# Cross-compile arch specific flags
-
-#
-if test "x$JDK_VARIANT" = "xembedded"; then
-   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DJAVASE_EMBEDDED"
-fi
-
-case $OPENJDK_TARGET_CPU_ARCH in
-arm )
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
-    ;;
-ppc )
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
-    ;;
-esac
-
-###############################################################################
 
 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
 
@@ -774,11 +794,17 @@
 PACKAGE_PATH=/opt/local
 AC_SUBST(PACKAGE_PATH)
 
-# Sometimes we use a cpu dir (.../lib/amd64/server) 
-# Sometimes not (.../lib/server) 
-LIBARCHDIR="$LEGACY_OPENJDK_TARGET_CPU2/"
-if test "x$ENDIAN" = xlittle; then
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
+if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
+    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
+    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
+    #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
+    #   Note: -Dmacro         is the same as    #define macro 1
+    #         -Dmacro=	    is the same as    #define macro
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
+    else
+        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
+    fi
 else
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
 fi
@@ -793,27 +819,29 @@
 fi
 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
-    LIBARCHDIR=""
 fi
 if test "x$OPENJDK_TARGET_OS" = xbsd; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
 fi
 if test "x$DEBUG_LEVEL" = xrelease; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
+    fi
 else
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
 fi
 
-CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$LEGACY_OPENJDK_TARGET_CPU1\"' -D$LEGACY_OPENJDK_TARGET_CPU1"
+CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'"
 
 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
         -I${JDK_OUTPUTDIR}/include \
         -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
         -I${JDK_TOPDIR}/src/share/javavm/export \
-        -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/javavm/export \
+        -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/javavm/export \
         -I${JDK_TOPDIR}/src/share/native/common \
-        -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/native/common"
+        -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
 
 # The shared libraries are compiled using the picflag.
 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
@@ -833,7 +861,7 @@
 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
 if test "x$COMPILER_TYPE" = xCL; then
     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
-    if test "x$LEGACY_OPENJDK_TARGET_CPU1" = xi586; then 
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
         LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
     fi
     # TODO: make -debug optional "--disable-full-debug-symbols"
@@ -861,20 +889,18 @@
     fi
 
     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
-                    -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}server \
-                    -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}client \
-  	            -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}"
-    LDFLAGS_JDKLIB_SUFFIX="-ljvm -ljava"
+                    -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server \
+                    -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client \
+                    -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
+
+    LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
     if test "x$COMPILER_NAME" = xossc; then
         LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
     fi
 
-    # Only the jli library is explicitly linked when the launchers are built.
-    # The libjvm is then dynamically loaded/linked by the launcher.
     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
-    if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then
-       LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}jli"
-       LDFLAGS_JDKEXE_SUFFIX="-ljli"
+    if test "x$OPENJDK_TARGET_OS" = xlinux; then
+        LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
     fi
 fi
 
@@ -905,4 +931,5 @@
 AC_SUBST(LDFLAGS_JDKEXE)
 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
+AC_SUBST(LDFLAGS_CXX_JDK)
 ])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/bin/boot_cycle.sh	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,77 @@
+#!/bin/bash
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# The boot_cycle.sh script performs two complete image builds (no javadoc though....)
+# where the second build uses the first build as the boot jdk.
+#
+# This is useful to verify that the build is self hoisting and assists
+# in flushing out bugs. You can follow up with compare_objects.sh to check
+# that the two boot_cycle_?/images/j2sdk are identical. They should be.
+#
+# Usage:
+# Specify the configure arguments to boot_cycle.sh, for example:
+#
+#    sh common/bin/boot_cycle.sh --enable-debug --with-jvm-variants=server
+#
+# The same arguments will be used for both builds, except of course --with-boot-jdk
+# that will be adjusted to boot_cycle_1 for the second build.
+
+SCRIPT_DIR=`pwd`/`dirname $0`
+ROOT_DIR=`(cd $SCRIPT_DIR/../.. ; pwd)`
+BUILD_DIR=$ROOT_DIR/build
+mkdir -p $BUILD_DIR
+AUTOCONF_DIR=`(cd $SCRIPT_DIR/../autoconf ; pwd)`
+BOOT_CYCLE_1_DIR=$BUILD_DIR/boot_cycle_1
+BOOT_CYCLE_2_DIR=$BUILD_DIR/boot_cycle_2
+
+# Create the boot cycle dirs in the build directory.
+mkdir -p $BOOT_CYCLE_1_DIR
+mkdir -p $BOOT_CYCLE_2_DIR
+
+cd $BOOT_CYCLE_1_DIR
+# Configure!
+sh $AUTOCONF_DIR/configure "$@"
+# Now build!
+make images
+
+if ! test -x $BOOT_CYCLE_1_DIR/images/j2sdk-image/bin/java ; then
+    echo Failed to build the executable $BOOT_CYCLE_1_DIR/images/j2sdk-image/bin/java
+    exit 1
+fi
+
+cd $BOOT_CYCLE_2_DIR
+# Pickup the configure arguments, but drop any --with-boot-jdk=....
+# and add the correct --with-boot-jdk=...boot_cycle_1... at the end.
+ARGUMENTS="`cat $BOOT_CYCLE_1_DIR/configure-arguments|sed 's/--with-boot-jdk=[^ ]*//'` --with-boot-jdk=$BOOT_CYCLE_1_DIR/images/j2sdk-image"
+# Configure using these adjusted arguments.
+sh $AUTOCONF_DIR/configure $ARGUMENTS
+# Now build!
+make images
+
+if ! test -x $BOOT_CYCLE_2_DIR/images/j2sdk-image/bin/java ; then
+    echo Failed to build the final executable $BOOT_CYCLE_2_DIR/images/j2sdk-image/bin/java
+    exit 1
+fi
+
+
--- a/common/bin/compare-objects.sh	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/bin/compare-objects.sh	Tue Sep 25 11:48:00 2012 -0700
@@ -30,7 +30,7 @@
 #
 
 if [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ] || [ "x$1" == "x" ]; then
-    echo "bash ./common/bin/compare-build.sh old_jdk_build_dir new_jdk_build_dir"
+    echo "bash ./common/bin/compare-objects.sh old_jdk_build_dir new_jdk_build_dir <pattern>"
     echo ""
     echo "Compare object files"
     echo ""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/bin/test_builds.sh	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,184 @@
+#!/bin/bash
+
+set -x
+set -e
+
+options="$*"
+option="$1"
+
+tmp=/tmp/test_builds.$$
+rm -f -r ${tmp}
+mkdir -p ${tmp}
+
+errMessages=${tmp}/error_messages.txt
+
+#######
+# Error function
+error() # message
+{
+   echo "ERROR: $1" | tee -a ${errMessages}
+}
+# Check errors
+checkErrors()
+{
+    if [ -s ${errMessages} ] ; then
+        cat ${errMessages}
+	exit 1
+    fi
+}
+#######
+
+os="`uname -s`"
+arch="`uname -p`"
+make=make
+
+if [ "${os}" = "SunOS" ] ; then
+  make=gmake
+  export J7="/opt/java/jdk1.7.0"
+elif [ "${os}" = "Darwin" ] ; then
+  export J7="/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home"
+elif [ "${os}" = "Linux" -a "${arch}" = "x86_64" ] ; then
+  export J7="/usr/lib/jvm/java-7-openjdk-amd64/"
+else
+  echo "What os/arch is this: ${os}/${arch}"
+  exit 1
+fi
+
+# Must have a jdk7
+if [ ! -d ${J7} ] ; then
+  echo "No JDK7 found at: ${J7}"
+  exit 1
+fi
+
+# What sources we use
+fromroot="http://hg.openjdk.java.net/build-infra/jdk8"
+
+# Where we do it
+root="testbuilds"
+mkdir -p ${root}
+
+# Three areas, last three are cloned from first to insure sameness
+t0=${root}/t0
+t1=${root}/t1
+t2=${root}/t2
+t3=${root}/t3
+repolist="${t0} ${t1} ${t2} ${t3}"
+
+# Optional complete clobber
+if [ "${option}" = "clobber" ] ; then
+  for i in ${repolist} ; do
+    rm -f -r ${i}
+  done
+fi
+
+# Get top repos
+if [ ! -d ${t0}/.hg ] ; then
+  rm -f -r ${t0}
+  hg clone ${fromroot} ${t0}
+fi
+for i in ${t1} ${t2} ${t3} ; do
+  if [ ! -d ${i}/.hg ] ; then
+    hg clone ${t0} ${i}
+  fi
+done
+
+# Get repos updated
+for i in ${repolist} ; do
+  ( \
+    set -e \
+    && cd ${i} \
+    && sh ./get_source.sh \
+    || error "Cannot get source" \
+  ) 2>&1 | tee ${i}.get_source.txt
+  checkErrors
+done
+
+# Optional clean
+if [ "${option}" = "clean" ] ; then
+  for i in ${repolist} ; do
+    rm -f -r ${i}/build
+    rm -f -r ${i}/*/build
+    rm -f -r ${i}/*/dist
+  done
+fi
+
+# Check changes on working set files
+for i in ${repolist} ; do
+  ( \
+    set -e \
+    && cd ${i} \
+    && sh ./make/scripts/hgforest.sh status \
+    || error "Cannot check status" \
+  ) 2>&1 | tee ${i}.hg.status.txt
+  checkErrors
+done
+
+# Configure for build-infra building
+for i in ${t1} ${t2} ; do
+  ( \
+    set -e \
+    && cd ${i}/common/makefiles \
+    && sh ../autoconf/configure --with-boot-jdk=${J7} \
+    || error "Cannot configure" \
+  ) 2>&1 | tee ${i}.config.txt
+  checkErrors
+done
+
+# Do build-infra builds
+for i in ${t1} ${t2} ; do
+  ( \
+    set -e \
+    && cd ${i}/common/makefiles \
+    && ${make}  \
+      FULL_VERSION:=1.8.0-internal-b00 \
+      JRE_RELEASE_VERSION:=1.8.0-internal-b00 \
+      USER_RELEASE_SUFFIX:=compare \
+      RELEASE:=1.8.0-internal \
+      VERBOSE= \
+      LIBARCH= \
+         all images \
+    || error "Cannot build" \
+  ) 2>&1 | tee ${i}.build.txt
+  checkErrors
+done
+
+# Compare build-infra builds
+( \
+  sh ${t0}/common/bin/compareimage.sh \
+    ${t1}/build/*/images/j2sdk-image \
+    ${t2}/build/*/images/j2sdk-image \
+    || error "Cannot compare" \
+) 2>&1 | tee ${root}/build-infra-comparison.txt
+checkErrors
+
+# Do old build
+unset JAVA_HOME
+export ALT_BOOTDIR="${J7}"
+( \
+  cd ${t3} \
+  && ${make} FULL_VERSION='"1.8.0-internal" sanity \
+  || error "Cannot sanity" \
+) 2>&1 | tee ${t3}.sanity.txt
+checkErrors
+( \
+  cd ${t3} \
+  && ${make} \
+      FULL_VERSION='"1.8.0-internal" \
+      JRE_RELEASE_VERSION:=1.8.0-internal-b00 \
+      USER_RELEASE_SUFFIX:=compare \
+      RELEASE:=1.8.0-internal \
+  || error "Cannot build old way" \
+) 2>&1 | tee ${t3}.build.txt
+checkErrors
+
+# Compare old build to build-infra build 
+( \
+  sh ${t0}/common/bin/compareimage.sh \
+    ${t3}/build/*/j2sdk-image \
+    ${t1}/build/*/images/j2sdk-image \
+    || error "Cannot compare" \
+) 2>&1 | tee ${root}/build-comparison.txt
+checkErrors
+
+exit 0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/bin/unicode2x.sed	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,100 @@
+s/\\u0020/\x20/g
+s/\\u003A/\x3A/g
+s/\\u006B/\x6B/g
+s/\\u0075/\x75/g
+s/\\u00A0/\xA0/g
+s/\\u00A3/\xA3/g
+s/\\u00B0/\xB0/g
+s/\\u00B7/\xB7/g
+s/\\u00BA/\xBA/g
+s/\\u00BF/\xBF/g
+s/\\u00C0/\xC0/g
+s/\\u00C1/\xC1/g
+s/\\u00C2/\xC2/g
+s/\\u00C4/\xC4/g
+s/\\u00C5/\xC5/g
+s/\\u00C8/\xC8/g
+s/\\u00C9/\xC9/g
+s/\\u00CA/\xCA/g
+s/\\u00CD/\xCD/g
+s/\\u00CE/\xCE/g
+s/\\u00D3/\xD3/g
+s/\\u00D4/\xD4/g
+s/\\u00D6/\xD6/g
+s/\\u00DA/\xDA/g
+s/\\u00DC/\xDC/g
+s/\\u00DD/\xDD/g
+s/\\u00DF/\xDF/g
+s/\\u00E0/\xE0/g
+s/\\u00E1/\xE1/g
+s/\\u00E2/\xE2/g
+s/\\u00E3/\xE3/g
+s/\\u00E4/\xE4/g
+s/\\u00E5/\xE5/g
+s/\\u00E6/\xE6/g
+s/\\u00E7/\xE7/g
+s/\\u00E8/\xE8/g
+s/\\u00E9/\xE9/g
+s/\\u00EA/\xEA/g
+s/\\u00EB/\xEB/g
+s/\\u00EC/\xEC/g
+s/\\u00ED/\xED/g
+s/\\u00EE/\xEE/g
+s/\\u00EF/\xEF/g
+s/\\u00F1/\xF1/g
+s/\\u00F2/\xF2/g
+s/\\u00F3/\xF3/g
+s/\\u00F4/\xF4/g
+s/\\u00F5/\xF5/g
+s/\\u00F6/\xF6/g
+s/\\u00F9/\xF9/g
+s/\\u00FA/\xFA/g
+s/\\u00FC/\xFC/g
+s/\\u0020/\x20/g
+s/\\u003f/\x3f/g
+s/\\u006f/\x6f/g
+s/\\u0075/\x75/g
+s/\\u00a0/\xa0/g
+s/\\u00a3/\xa3/g
+s/\\u00b0/\xb0/g
+s/\\u00ba/\xba/g
+s/\\u00bf/\xbf/g
+s/\\u00c1/\xc1/g
+s/\\u00c4/\xc4/g
+s/\\u00c5/\xc5/g
+s/\\u00c8/\xc8/g
+s/\\u00c9/\xc9/g
+s/\\u00ca/\xca/g
+s/\\u00cd/\xcd/g
+s/\\u00d6/\xd6/g
+s/\\u00dc/\xdc/g
+s/\\u00dd/\xdd/g
+s/\\u00df/\xdf/g
+s/\\u00e0/\xe0/g
+s/\\u00e1/\xe1/g
+s/\\u00e2/\xe2/g
+s/\\u00e3/\xe3/g
+s/\\u00e4/\xe4/g
+s/\\u00e5/\xe5/g
+s/\\u00e7/\xe7/g
+s/\\u00e8/\xe8/g
+s/\\u00e9/\xe9/g
+s/\\u00ea/\xea/g
+s/\\u00eb/\xeb/g
+s/\\u00ec/\xec/g
+s/\\u00ed/\xed/g
+s/\\u00ee/\xee/g
+s/\\u00ef/\xef/g
+s/\\u00f0/\xf0/g
+s/\\u00f1/\xf1/g
+s/\\u00f2/\xf2/g
+s/\\u00f3/\xf3/g
+s/\\u00f4/\xf4/g
+s/\\u00f5/\xf5/g
+s/\\u00f6/\xf6/g
+s/\\u00f7/\xf7/g
+s/\\u00f8/\xf8/g
+s/\\u00f9/\xf9/g
+s/\\u00fa/\xfa/g
+s/\\u00fc/\xfc/g
+s/\\u00ff/\xff/g
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/makefiles/HotspotWrapper.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  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.
+#
+
+# Include the legacy hotspot-spec.gmk (which in turns includes spec.gmk)
+BASE_SPEC:=$(SPEC)
+include $(dir $(SPEC))hotspot-spec.gmk
+include MakeBase.gmk
+
+# Inclusion of this pseudo-target will cause make to execute this file
+# serially, regardless of -j. Recursively called makefiles will not be
+# affected, however. This is required for correct dependency management.
+.NOTPARALLEL:
+
+default: all
+
+# Get all files except .hg in the hotspot directory.
+HOTSPOT_FILES :=  $(shell $(FIND) $(HOTSPOT_TOPDIR) -name ".hg" -prune -o -print)
+
+$(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp: $(HOTSPOT_FILES)
+	@($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) -j1 $(HOTSPOT_MAKE_ARGS) SPEC=$(HOTSPOT_SPEC) BASE_SPEC=$(BASE_SPEC))
+	$(TOUCH) $@
+
+hotspot: $(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp
+
+all: hotspot
+
+.PHONY: default all hotspot
--- a/common/makefiles/JavaCompilation.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/makefiles/JavaCompilation.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -23,40 +23,14 @@
 # questions.
 #
 
-# The complexity of this makefile is not the fault of make, but the fault
-# of javac and javah. The basic problems are:
-#
-#    1) Compiling a single Java source file unpredictably generates anything
-#       between zero (0!) and an infinite number of .class files!
-#    2) There is no hint, for which classes javah needs to be run,
-#       and it happily generates .h files for classes with no native methods.
-#    3) javac and javah do not cleanup anything, for example if an internal
-#       class (potentially with native methods) is removed from a Java source file.
-#
-# This makefile is a tribute to GNU make. And yes, it was harder to write than it is
-# to read. The include/excludes of directories and files are only a temporary measure
-# to work around the messy jdk sources that put platform specific code in src/share/classes.
-#
-# We should move most of the functionality of this makefile into a
-# smart javac/javah/javadoc/jar combo tool. sjavac ?
-#
-# I.e. 1) It always generates a single output, a zip-file from a number of source roots.
-#         The zip file contains information that enable incremental builds with full 
-#         dependency tracking between packages.
-#      2) It automatically generates the right .h files.
-#      3) It keeps its house clean.
-#      *) Generates intermediate files to be used for javadoc generation later.
-#      and does all the other useful things that this makefile does, such as:
-#          use all cores for compilation, reuse the running JVM for all compilations,
-#          and has pubapi dependency tracking to minimize the number of files
-#          that need to be recompiled during an incremental build.
-# 
-# A zip file, or several zip files combined, can then be converted to a .jar file, or to a .jmod file.
-#
-# This would make this makefile much much simpler. I.e. make can be used
-# for its real purpose, track dependencies and trigger a recompile if a
-# dependency has changed.
-#
+# This makefile is much simpler now that it can use the smart javac wrapper
+# for dependency tracking between java packages and incremental compiles.
+# It could be even more simple if we added support for incremental jar updates
+# directly from the smart javac wrapper.
+
+# Cleaning/copying properties here is not a good solution. The properties
+# should be cleaned/copied by a annotation processor in sjavac.
+
 # When you read this source. Remember that $(sort ...) has the side effect
 # of removing duplicates. It is actually this side effect that is
 # desired whenever sort is used below!
@@ -67,25 +41,15 @@
 
 FALSE_FIND_PATTERN:=-name FILE_NAME_THAT_DOESNT_EXIST
 
-# If compilation of java package fails, then the public api file for that
-# package will not be genereated. We add this fallback rule to generate
-# an empty pubapi file. 
-%.api:
-	if test ! -f $@; then $(MKDIR) -p $(@D); $(TOUCH) $@; fi
-
 define SetupJavaCompiler
     # param 1 is for example BOOT_JAVAC or NEW_JAVAC
     # This is the name later used to decide which java compiler to use.
     # param 2-9 are named args.
     #   JVM:=The jvm used to run the javac/javah command
     #   JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out
-    #   JAVAH:=The javah jar and bootstrap classpath changes, or just bin/javah if JVM is left out
     #   FLAGS:=Flags to be supplied to javac
-    #   MODE:=SINGLE_THREADED_BATCH (primarily for old javac) or MULTI_CORE_CONCURRENT
-    #      only for MULTI_CORE_CONCURRENT are the options below relevant:
     #   SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here
     #   SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above.
-    #   USE_DEPS:=true means use -XDdeps,-XDpubapi and -XDnativeapi to track java dependencies
     $(if $2,$1_$(strip $2))
     $(if $3,$1_$(strip $3))
     $(if $4,$1_$(strip $4))
@@ -96,21 +60,17 @@
     $(if $9,$1_$(strip $9))
     $(if $(10),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk))
 
-    ifeq ($$($1_MODE),MULTI_CORE_CONCURRENT)
-	ifneq (,$$($1_SERVER_DIR))
-            # A javac server has been requested.
-            # The port file contains the tcp/ip on which the server listens
-            # and the cookie necessary to talk to the server.
-            $1_JAVAC_PORTFILE:=$$($1_SERVER_DIR)/$1.port
-            ifeq ($$($1_SERVER_JVM),)
-                # You can use a different JVM to run the background javac server.
-                # But if not set, it defaults to the same JVM that is used to start
-                # the javac command.
-                $1_SERVER_JVM:=$$($1_JVM)
-            endif
-            # Set the $1_REMOTE to spawn a background javac server.
-	    $1_REMOTE:=-XDserver:portfile=$$($1_JAVAC_PORTFILE),poolsize=$(JAVAC_SERVER_CORES),javac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_JAVAC))))
+    ifeq ($$(ENABLE_SJAVAC),yes)
+        # The port file contains the tcp/ip on which the server listens
+        # and the cookie necessary to talk to the server.
+        $1_JAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port
+        # You can use a different JVM to run the background javac server.
+        ifeq ($$($1_SERVER_JVM),)
+            # It defaults to the same JVM that is used to start the javac command.
+            $1_SERVER_JVM:=$$($1_JVM)
         endif
+        # Set the $1_REMOTE to spawn a background javac server.
+        $1_REMOTE:=-XDserver:portfile=$$($1_JAVAC_PORTFILE),poolsize=$(SJAVAC_SERVER_CORES),id=$1,javac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_JAVAC))))
     endif
 endef
 
@@ -127,7 +87,7 @@
     #    JAR:=Jar file to create
     #    MANIFEST:=Optional manifest file template.
     #    JARMAIN:=Optional main class to add to manifest
-    #    JARINDEX := 
+    #    JARINDEX:=true means generate the index in the jar file.
     #    SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically 
     #                  added to the archive.
     #    EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest.
@@ -152,9 +112,6 @@
     $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest
     $1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess
     $1_DELETES_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletes
-    $1_PUBAPI_NOTIFICATIONS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_pubapi_notifications
-    $1_NATIVEAPI_NOTIFICATIONS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_native_notifications
-    $1_NATIVEAPI_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_native
     $1_BIN:=$$(dir $$($1_JAR))
 
     ifeq (,$$($1_SUFFIXES))
@@ -180,6 +137,7 @@
         $1_GREP_EXCLUDES:=| $(GREP) -v -f $$($1_BIN)/_the.$$($1_JARNAME)_exclude
     endif
 
+    # Check if this jar needs to have its index generated.
     ifneq (,$$($1_JARINDEX))
       $1_JARINDEX = (cd $$(dir $$@) && $(JAR) -i $$(notdir $$@))
     else
@@ -188,14 +146,17 @@
     # When this macro is run in the same makefile as the java compilation, dependencies are transfered
     # in make variables. When the macro is run in a different makefile than the java compilation, the 
     # dependencies need to be found in the filesystem.
-    $1_ALL_SRCS:=$$(foreach src,$$($1_SRCS),$$(shell ($(FIND) $$(src) -type f \
+    ifneq (,$2)
+        $1_DEPS:=$2
+    else
+        $1_DEPS:=$$(foreach src,$$($1_SRCS),$$(shell ($(FIND) $$(src) -type f \
 			-a \( $$($1_FIND_PATTERNS) \) $$($1_GREP_INCLUDES) \
-			$$($1_GREP_EXCLUDES) && $(ECHO) $$($1_EXTRA_FILES))))
-    ifeq (,$$($1_SKIP_METAINF))
-        $1_ALL_SRCS+=$$(foreach src,$$($1_SRCS),$$(shell $(FIND) $$(src)/META-INF -type f 2> /dev/null))
+			$$($1_GREP_EXCLUDES) && $(ECHO) $$(addprefix $$(src)/,$$($1_EXTRA_FILES)))))
+        ifeq (,$$($1_SKIP_METAINF))
+            $1_DEPS+=$$(foreach src,$$($1_SRCS),$$(shell $(FIND) $$(src)/META-INF -type f 2> /dev/null))
+        endif
     endif
 
-
     # Utility macros, to make the shell script receipt somewhat easier to dechipher.
 
     # The capture contents macro finds all files (matching the patterns, typically
@@ -208,19 +169,12 @@
     # The capture deletes macro finds all deleted files and concatenates them. The resulting file
     # tells us what to remove from the jar-file.
     $1_CAPTURE_DELETES=$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.deleted -newer $$@ -exec $(SED) 's|$$(src)||g' \{\} >> $$($1_DELETES_FILE) \;) &&)
-    # The capture pubapi notifications scans for pubapi change notifications. If such notifications are
-    # found, then we will build the classes leading up to the jar again, to take into account the new timestamps
-    # on the changed pubapi files.
-    $1_CAPTURE_PUBAPI_NOTIFICATIONS=$$(foreach src,$$($1_SRCS),\
-                    (cd $$(src) && \
-                    $(FIND) . -name _the.package.api.notify -exec dirname \{\} \; >> $$($1_PUBAPI_NOTIFICATIONS_FILE) ; \
-                    true) &&)
     # The update contents macro updates the jar file with the previously capture contents.
     $1_UPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\
                     (cd $$(src) && \
                      if [ -s _the.$$($1_JARNAME)_contents ]; then \
                          $(ECHO) "  updating" `$(WC) -l _the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \
-                         $(JAR) uf $$@ @_the.$$($1_JARNAME)_contents; \
+                         $(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @_the.$$($1_JARNAME)_contents; \
                      fi) &&)
     # The s-variants of the above macros are used when the jar is created from scratch.
     $1_SCAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\
@@ -234,30 +188,25 @@
 			$$(src)/_the.$$($1_JARNAME)_contents) && )
     endif
     $1_SUPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\
-                    (cd $$(src) && $(JAR) uf $$@ @$$(src)/_the.$$($1_JARNAME)_contents) &&)
+                    (cd $$(src) && $(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @$$(src)/_the.$$($1_JARNAME)_contents) &&)
 
-    # The TOUCH macro is used to make sure all timestamps are identical for package files and the pubapi files.
-    # If we do not do this, we get random recompilations, the next time we run make, since the order of package building is random,
-    # ie independent of package --dependes on-> public api of another package. This is of course
-    # due to the fact that Java source often (always?) has circular dependencies. (Thus there is no correct order
-    # to compile packages, and we can just as well do them in a random order. Which we do.)
-    $1_TOUCH_API_FILES=$$(foreach src,$$($1_SRCS),\
-                    ($(FIND) $$(src) -name _the.package.api -exec $(TOUCH) -r $$($1_JAR) \{\} \; ; true) && \
-                    ($(FIND) $$(src) -name _the.package -exec $(TOUCH) -r $$($1_JAR) \{\} \; ; true) &&)
     # Use a slightly shorter name for logging, but with enough path to identify this jar.
     $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_JAR))
 
     ifneq (,$$($1_CHECK_COMPRESS_JAR))
         $1_JAR_CREATE_OPTIONS := c0fm
+        $1_JAR_UPDATE_OPTIONS := u0f
         ifeq ($(COMPRESS_JARS), true)
             $1_JAR_CREATE_OPTIONS := cfm
+            $1_JAR_UPDATE_OPTIONS := uf
         endif
     else
         $1_JAR_CREATE_OPTIONS := cfm
+        $1_JAR_UPDATE_OPTIONS := uf
     endif
 
     # Here is the rule that creates/updates the jar file.
-    $$($1_JAR) : $2 $$($1_ALL_SRC)
+    $$($1_JAR) : $$($1_DEPS)
 	$(MKDIR) -p $$($1_BIN)
 	if [ -n "$$($1_MANIFEST)" ]; then \
 		$(SED) -e "s#@@RELEASE@@#$(RELEASE)#"           \
@@ -272,46 +221,28 @@
 		$(PRINTF) "$$($1_EXTRA_MANIFEST_ATTR)\n" >> $$($1_MANIFEST_FILE); \
 	fi
 	+if [ -s $$@ ]; then \
-		$(RM) -r $$($1_PUBAPI_NOTIFICATIONS_FILE) && \
-		$$($1_CAPTURE_PUBAPI_NOTIFICATIONS) \
-		if [ -s $$($1_PUBAPI_NOTIFICATIONS_FILE) ]; then \
-			$(ECHO) Public api change detected in: && \
-			$(CAT) $$($1_PUBAPI_NOTIFICATIONS_FILE) | $(TR) '/' '.' | $(SED) 's|^..||g' | $(SED) 's|\.$$$$||g' | $(AWK) '{print "  "$$$$1}' && \
-			$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.api.notify $(FIND_DELETE); true) &&) \
-			$(MAKE) -f $(word 1,$(MAKEFILE_LIST)) $$($1_JAR) ; \
-		else \
-			$(ECHO) Modifying $$($1_NAME) && \
-			$$($1_CAPTURE_CONTENTS) \
-			$$($1_CAPTURE_METAINF) \
-			$(RM) $$($1_DELETES_FILE) && \
-			$$($1_CAPTURE_DELETES) \
-			$(CAT) $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) && \
-			if [ -s $$($1_DELETESS_FILE) ]; then \
-				$(ECHO) "  deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \
-	                        $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \
-			fi && \
-			$$($1_UPDATE_CONTENTS) true && \
-			$$($1_JARINDEX) && \
-			$$($1_TOUCH_API_FILES) true && \
-			$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.api.notify $(FIND_DELETE); true) &&) true ; \
-		fi ; \
+		$(ECHO) Modifying $$($1_NAME) && \
+		$$($1_CAPTURE_CONTENTS) \
+		$$($1_CAPTURE_METAINF) \
+		$(RM) $$($1_DELETES_FILE) && \
+		$$($1_CAPTURE_DELETES) \
+		$(CAT) $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) && \
+		if [ -s $$($1_DELETESS_FILE) ]; then \
+			$(ECHO) "  deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \
+	                       $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \
+		fi && \
+		$$($1_UPDATE_CONTENTS) true && \
+		$$($1_JARINDEX) && true ; \
 	else \
 		$(ECHO) Creating $$($1_NAME) && $(JAR) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) && \
 	        $$($1_SCAPTURE_CONTENTS) \
 		$$($1_SCAPTURE_METAINF) \
 		$$($1_SUPDATE_CONTENTS) \
-		$$($1_JARINDEX) && \
-		$$($1_TOUCH_API_FILES) true && \
-		$(RM) -r $$($1_NATIVEAPI_NOTIFICATIONS_FILE) $$($1_NATIVEAPI_FILE) && \
-		$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name "*.notify" $(FIND_DELETE); true) &&) true ; \
+		$$($1_JARINDEX) && true ; \
 	fi; 
 
 endef
 
-define append_to
-    $(ECHO) "$1" >> $2
-endef
-
 define SetupZipArchive
     # param 1 is for example ZIP_MYSOURCE
     # param 2,3,4,5,6,7,8,9 are named args.
@@ -343,7 +274,7 @@
     ifneq ($$($1_EXCLUDES),)
         $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
         $1_ZIP_EXCLUDES := $$(addprefix -x$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_EXCLUDES)))
-        $1_ALL_SRCS     := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
+        $1_ALL_SRCS     := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRC))
     endif
 
     # Use a slightly shorter name for logging, but with enough path to identify this zip.
@@ -381,7 +312,8 @@
 # This macro is used only for properties files that are to be
 # copied over to the classes directory in cleaned form:
 # Previously this was inconsistently done in different repositories.
-# This is the new clean standard.
+# This is the new clean standard. Though it is to be superseded by
+# a standard annotation processor from with sjavac.
 define add_file_to_copy_and_clean
     # param 1 = BUILD_MYPACKAGE
     # parma 2 = The source file to copy and clean.
@@ -391,109 +323,8 @@
     # Now we can setup the depency that will trigger the copying.
     $$($1_BIN)$$($2_TARGET) : $2
 	$(MKDIR) -p $$(@D)
-	$(ECHO) Cleaning $$($2_TARGET)
 	$(CAT) $$< | $(SED) -e 's/\([^\\]\):/\1\\:/g' -e  's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \
-                   | $(SED) \
--e 's/\\u0020/\x20/g' \
--e 's/\\u003A/\x3A/g' \
--e 's/\\u006B/\x6B/g' \
--e 's/\\u0075/\x75/g' \
--e 's/\\u00A0/\xA0/g' \
--e 's/\\u00A3/\xA3/g' \
--e 's/\\u00B0/\xB0/g' \
--e 's/\\u00B7/\xB7/g' \
--e 's/\\u00BA/\xBA/g' \
--e 's/\\u00BF/\xBF/g' \
--e 's/\\u00C0/\xC0/g' \
--e 's/\\u00C1/\xC1/g' \
--e 's/\\u00C2/\xC2/g' \
--e 's/\\u00C4/\xC4/g' \
--e 's/\\u00C5/\xC5/g' \
--e 's/\\u00C8/\xC8/g' \
--e 's/\\u00C9/\xC9/g' \
--e 's/\\u00CA/\xCA/g' \
--e 's/\\u00CD/\xCD/g' \
--e 's/\\u00CE/\xCE/g' \
--e 's/\\u00D3/\xD3/g' \
--e 's/\\u00D4/\xD4/g' \
--e 's/\\u00D6/\xD6/g' \
--e 's/\\u00DA/\xDA/g' \
--e 's/\\u00DC/\xDC/g' \
--e 's/\\u00DD/\xDD/g' \
--e 's/\\u00DF/\xDF/g' \
--e 's/\\u00E0/\xE0/g' \
--e 's/\\u00E1/\xE1/g' \
--e 's/\\u00E2/\xE2/g' \
--e 's/\\u00E3/\xE3/g' \
--e 's/\\u00E4/\xE4/g' \
--e 's/\\u00E5/\xE5/g' \
--e 's/\\u00E6/\xE6/g' \
--e 's/\\u00E7/\xE7/g' \
--e 's/\\u00E8/\xE8/g' \
--e 's/\\u00E9/\xE9/g' \
--e 's/\\u00EA/\xEA/g' \
--e 's/\\u00EB/\xEB/g' \
--e 's/\\u00EC/\xEC/g' \
--e 's/\\u00ED/\xED/g' \
--e 's/\\u00EE/\xEE/g' \
--e 's/\\u00EF/\xEF/g' \
--e 's/\\u00F1/\xF1/g' \
--e 's/\\u00F2/\xF2/g' \
--e 's/\\u00F3/\xF3/g' \
--e 's/\\u00F4/\xF4/g' \
--e 's/\\u00F5/\xF5/g' \
--e 's/\\u00F6/\xF6/g' \
--e 's/\\u00F9/\xF9/g' \
--e 's/\\u00FA/\xFA/g' \
--e 's/\\u00FC/\xFC/g' \
--e 's/\\u0020/\x20/g' \
--e 's/\\u003f/\x3f/g' \
--e 's/\\u006f/\x6f/g' \
--e 's/\\u0075/\x75/g' \
--e 's/\\u00a0/\xa0/g' \
--e 's/\\u00a3/\xa3/g' \
--e 's/\\u00b0/\xb0/g' \
--e 's/\\u00ba/\xba/g' \
--e 's/\\u00bf/\xbf/g' \
--e 's/\\u00c1/\xc1/g' \
--e 's/\\u00c4/\xc4/g' \
--e 's/\\u00c5/\xc5/g' \
--e 's/\\u00c8/\xc8/g' \
--e 's/\\u00c9/\xc9/g' \
--e 's/\\u00ca/\xca/g' \
--e 's/\\u00cd/\xcd/g' \
--e 's/\\u00d6/\xd6/g' \
--e 's/\\u00dc/\xdc/g' \
--e 's/\\u00dd/\xdd/g' \
--e 's/\\u00df/\xdf/g' \
--e 's/\\u00e0/\xe0/g' \
--e 's/\\u00e1/\xe1/g' \
--e 's/\\u00e2/\xe2/g' \
--e 's/\\u00e3/\xe3/g' \
--e 's/\\u00e4/\xe4/g' \
--e 's/\\u00e5/\xe5/g' \
--e 's/\\u00e7/\xe7/g' \
--e 's/\\u00e8/\xe8/g' \
--e 's/\\u00e9/\xe9/g' \
--e 's/\\u00ea/\xea/g' \
--e 's/\\u00eb/\xeb/g' \
--e 's/\\u00ec/\xec/g' \
--e 's/\\u00ed/\xed/g' \
--e 's/\\u00ee/\xee/g' \
--e 's/\\u00ef/\xef/g' \
--e 's/\\u00f0/\xf0/g' \
--e 's/\\u00f1/\xf1/g' \
--e 's/\\u00f2/\xf2/g' \
--e 's/\\u00f3/\xf3/g' \
--e 's/\\u00f4/\xf4/g' \
--e 's/\\u00f5/\xf5/g' \
--e 's/\\u00f6/\xf6/g' \
--e 's/\\u00f7/\xf7/g' \
--e 's/\\u00f8/\xf8/g' \
--e 's/\\u00f9/\xf9/g' \
--e 's/\\u00fa/\xfa/g' \
--e 's/\\u00fc/\xfc/g' \
--e 's/\\u00ff/\xff/g' \
+                   | $(SED) -f "$(SRC_ROOT)/common/bin/unicode2x.sed" \
 		   | $(SED) -e '/^#/d' -e '/^$$$$/d' \
 		            -e :a -e '/\\$$$$/N; s/\\\n//; ta' \
 			    -e 's/^[ \t]*//;s/[ \t]*$$$$//' \
@@ -504,122 +335,6 @@
     $1_ALL_COPY_CLEAN_TARGETS += $$($1_BIN)$$($2_TARGET)
 endef
 
-define add_java_package
-    # param 1 = BUILD_MYPACKAGE
-    # param 2 = the package target file (_the.package)
-    # param 3 = src roots, all of them, separated with space
-    # param 4 = bin root
-    # param 5 = include these dependecies
-    # param 6 = not used
-    # param 7 = if non-empty, then use -Xdeps and -Xpubapi
-    # param 8 = xremote configuration, or empty.
-    # param 9 = javac command
-    # param 10 = javac flags
-    # param 11 = exclude these files!
-    # param 12 = only include these files!
-    # param 13 = javah command
-    # param 14 = override src roots to be passed into -sourcepath, ugly ugly ugly, do not use this!
-    #            it is only here to workaround ugly things in the source code in the jdk that ought
-    #            to be fixed instead!
-    ifdef $2_USED_BY
-        $$(error Attempting to add the package $2 from $3 which is already added with sources from $$($2_USED_BY))
-    endif
-    $2_USED_BY:=$3
-    # Remove the _the.package file to get the target bin dir for the classes in this package.
-    $2_PACKAGE_BDIR:=$(dir $2)
-    # The source roots separated with a path separator (: or ; depending on os)
-    # (The patsubst is necessary to trim away unnecessary spaces.)
-    ifneq ($(14),)
-      $2_SRCROOTSC:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$(14))))
-    else
-      $2_SRCROOTSC:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$3)))
-    endif
-    # Suffix the package path to the src roots, to get a list of all possible source locations
-    # for this package.
-    $2_PACKAGE_SDIRS:=$$(foreach i,$3,$$(subst $4,$$i,$$($2_PACKAGE_BDIR)))
-    # Use wildcard in all potential source locations to find the actual sources.
-    $2_PACKAGE_SRCS:=$$(filter-out $(11),$$(wildcard $$(addsuffix *.java,$$($2_PACKAGE_SDIRS))))
-    ifneq ($(12),)
-      # Filter on include file filter if set.
-      $2_PACKAGE_SRCS:=$$(filter $(12),$$($2_PACKAGE_SRCS))
-    endif
-    # Generate a proper package name from the file name.
-    $2_PACKAGE:=$(patsubst .%.,%,$(subst /,.,$(subst $4,,$(dir $2))))
-    # Use a javac server for this package?
-    $2_REMOTE:=$8
-
-    # Include previously generated information about what classes are output by this package
-    # and what sources were used for the compile.
-    -include $$($2_PACKAGE_BDIR)_the.package.d
-
-    # Include the notify, file, that exists if the package has been compiled during a previous make round.
-    # I.e. we are now dealing with a compile triggered by a pubapi change.
-    -include $$($2_PACKAGE_BDIR)_the.package.notify
-
-    # If the notify file existed, then $$($2_NOTIFIED) will be equal to true.
-    # Use this information to block dependency tracking for this package. 
-    # This is necessary to cut the circular dependency chains that are so common in Java sources.
-
-    ifneq ($$($2_NOTIFIED),true)
-        # No need to block, since this package has not yet been recompiled.
-        # Thus include previously generated dependency information. (if it exists)
-        -include $$($2_PACKAGE_BDIR)_the.package.dddd
-#    else
-#        $$(info WAS NOTIFIED $2)
-    endif
-
-    # Should we create proper dependencies between packages?
-    ifneq ($7,)
-      # The flag: -XDpubapi:file=foo,package=mypack,notify writes a file foo that contains a 
-      # database of the public api of the classes supplied on the command line and are
-      # inside the package mypack. If foo already exists, javac will only write to foo,
-      # if there is a change in the pubapi. I.e. we can use the timestamp of this file
-      # for triggering dependencies. "notify" means create a "file" suffixed with notify
-      # if the pubapi really changed. 
-      $2_PUBAPI=-XDpubapi=file=$$($2_PACKAGE_BDIR)_the.package.api,notify,package=$$($2_PACKAGE)
-      # The flag: -XDnativeapi:file=foo,package=mypack,notify works similar to pubabi, but
-      # instead tracks native methods. This file can be used to trigger dependencies for
-      # native compilations.
-      $2_NATIVEAPI=-XDnativeapi=file=$$($2_PACKAGE_BDIR)_the.package.native,notify,package=$$($2_PACKAGE)
-      # The flag -XDdeps:file=foo.deps,groupon=package writes a foo.deps file containing packages dependencies:
-      #     java.net : java.io java.lang
-      # I.e. the classes in .net depend on the public apis of java.io and java.lang
-      # The dependencies can be grouped on classes instead (groupon=class)
-      #     java.net.Bar : java.io.Socket java.lang.String
-      $2_DEPS:=-XDdeps=file=$$($2_PACKAGE_BDIR)_the.package.deps,groupon=package
-      # The next command rewrites the deps output from javac into a proper makefile dependency.
-      # The dependencies are always to an .api file generated by the pubapi option above.
-      # This is necessary since java package dependencies are almost always circular.
-      $2_APPEND_DEPS:=($(CAT) $$($2_PACKAGE_BDIR)_the.package.deps | $(TR) '.' '/' | $(AWK) '{ print "$4/" $$$$3 }' | sort > $$($2_PACKAGE_BDIR)_the.package.ddd && $(GREP) -f $$($2_PACKAGE_BDIR)_the.package.ddd $5 | $(AWK) '{ print "$(dir $2)_the.package : " $$$$1 "_the.package.api" }' > $$($2_PACKAGE_BDIR)_the.package.dddd ; true)
-    else
-        # If not using dependencies, use $2 as fallback to trigger regeneration of javah header files.
-        # This will generate a surplus of header files, but this does not hurt compilation.
-        $2_NATIVEAPICHANGE_TRIGGER:=$2
-        $2_FETCH_NATIVEAPICHANGE_CLASSES:=$(CAT) $$($2_PACKAGE_BDIR)_the.package.now|$(GREP) -v '\$$$$'|$(SED) -e 's|$4/||g'|$(SED) 's|.class||g'| $(TR) '/' '.'
-    endif 
-
-    # The _the.package file is dependent on the java files inside the package.
-    # Fill the _the.package file with a list of the java files and compile them
-    # to class files.
-    $2 : $$($2_PACKAGE_SRCS)
-	$(MKDIR) -p $$($2_PACKAGE_BDIR)
-	$(RM) $2.tmp
-	$$(call ListPathsSafely,$2_PACKAGE_SRCS,\n, >> $2.tmp)
-	$(ECHO) $$($2_PACKAGE_BDIR)*.class | $(GREP) -v \*.class | $(TR) ' ' '\n' > $$($2_PACKAGE_BDIR)_the.package.prev
-	$(RM) $$($2_PACKAGE_BDIR)*.class $$($2_PACKAGE_BDIR)*.notify $$($2_PACKAGE_BDIR)*.deleted
-	$(ECHO) Compiling `$(WC) $2.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files in package $(patsubst $4/%/,%,$(dir $2.tmp))
-	$9 $$($2_REMOTE) $$($2_DEPS) $$($2_PUBAPI) $$($2_NATIVEAPI) $(10) -implicit:none -sourcepath "$$($2_SRCROOTSC)" -d $4 @$2.tmp
-	$(ECHO) $$($2_PACKAGE_BDIR)*.class | $(GREP) -v \*.class | $(TR) ' ' '\n' > $$($2_PACKAGE_BDIR)_the.package.now
-	($(GREP) -xvf $$($2_PACKAGE_BDIR)_the.package.now $$($2_PACKAGE_BDIR)_the.package.prev > $$($2_PACKAGE_BDIR)_the.package.deleted;true)
-	$(ECHO) $1_CLASSES += `$(CAT) $$($2_PACKAGE_BDIR)_the.package.now` | \
-		$(SED) 's/\$$$$/\$$$$\$$$$/g' > $$($2_PACKAGE_BDIR)_the.package.d
-	$(ECHO) $1_JAVAS += $$($2_PACKAGE_SRCS) >> $$($2_PACKAGE_BDIR)_the.package.d
-	$(ECHO) $2_NOTIFIED:=true > $$($2_PACKAGE_BDIR)_the.package.notify
-	$$($2_APPEND_DEPS)
-	$$($2_COPY_FILES)
-	$(MV) -f $2.tmp $2
-endef
-
 define remove_string
     $2 := $$(subst $1,,$$($2))
 endef
@@ -664,140 +379,101 @@
     $(if $(14),$1_$(strip $(14)))
     $(if $(15),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk))
 
-# Extract the info from the java compiler setup.
-$1_MODE := $$($$($1_SETUP)_MODE)
-ifneq (SINGLE_THREADED_BATCH,$$($1_MODE))
-    ifneq (MULTI_CORE_CONCURRENT,$$($1_MODE))
+    # Extract the info from the java compiler setup.
+    $1_REMOTE := $$($$($1_SETUP)_REMOTE)
+    $1_JVM   := $$($$($1_SETUP)_JVM)
+    $1_JAVAC := $$($$($1_SETUP)_JAVAC)
+    $1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS)
+    ifeq ($$($1_JAVAC),)
         $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP))
     endif
-endif
-$1_USE_DEPS := $$($$($1_SETUP)_USE_DEPS)
-$1_REMOTE := $$($$($1_SETUP)_REMOTE)
-$1_JVM   := $$($$($1_SETUP)_JVM)
-$1_JAVAC := $$($$($1_SETUP)_JAVAC)
-$1_JAVAH := $$($$($1_SETUP)_JAVAH)
-$1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS)
+
+    # Handle addons and overrides.
+    $1_SRC:=$$(call ADD_SRCS,$$($1_SRC))
+    # Make sure the dirs exist.
+    $$(shell $(MKDIR) -p $$($1_SRC) $$($1_BIN))
+    # Find all files in the source trees.
+    $1_ALL_SRCS := $$(filter-out $(OVR_SRCS),$$(foreach i,$$($1_SRC),$$(shell $(FIND) $$i -type f)))
+    # Extract the java files.
+    ifneq ($$($1_EXCLUDE_FILES),)
+        $1_EXCLUDE_FILES_PATTERN:=$$(addprefix %,$$($1_EXCLUDE_FILES))
+    endif
+    $1_SRCS     := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$(filter %.java,$$($1_ALL_SRCS)))
+    ifneq ($$($1_INCLUDE_FILES),)
+        $1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES)))
+        $1_SRCS := $$(filter $$($1_INCLUDE_FILES), $$($1_SRCS))
+    endif
 
-# Handle addons and overrides.
-$1_SRC:=$$(call ADD_SRCS,$$($1_SRC))
-# Make sure the dirs exist.
-$$(shell $(MKDIR) -p $$($1_SRC) $$($1_BIN))
-# Find all files in the source trees.
-$1_ALL_SRCS := $$(filter-out $(OVR_SRCS),$$(foreach i,$$($1_SRC),$$(shell $(FIND) $$i -type f)))
-# Extract the java files.
-ifneq ($$($1_EXCLUDE_FILES),)
-  $1_EXCLUDE_FILES_PATTERN:=$$(addprefix %,$$($1_EXCLUDE_FILES))
-endif
-$1_SRCS     := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$(filter %.java,$$($1_ALL_SRCS)))
-ifneq ($$($1_INCLUDE_FILES),)
-  $1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES)))
-  $1_SRCS := $$(filter $$($1_INCLUDE_FILES), $$($1_SRCS))
-endif
-$1_PKGS     := $$(sort $$(dir $$($1_SRCS)))
-# Remove the source root from each found path.
-$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$1_PKGS)))
-$1_PKGS     := $$(sort $$($1_PKGS))
-# There can be only a single bin dir root, no need to foreach over the roots.
-$1_BINS     := $$(shell $(FIND) $$($1_BIN) -name "*.class")
+    # Now we have a list of all java files to compile: $$($1_SRCS)
+
+    # Create the corresponding smart javac wrapper command line.
+    $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix .*,$$(subst /,.,$$($1_EXCLUDES)))) \
+		$$(addprefix -i ,$$(addsuffix .*,$$(subst /,.,$$($1_INCLUDES)))) \
+		$$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES))) \
+		$$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) \
+		-src "$$(subst $$(SPACE),$$(PATH_SEP),$$(strip $$($1_SRC)))"
 
-# Now we have a list of all java files to compile: $$($1_SRCS)
-# and we have a list of all existing class files: $$($1_BINS)
-
-# Create the corresponding smart javac wrapper command line.
-$1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix .*,$$(subst /,.,$$($1_EXCLUDES)))) \
-$$(addprefix -i ,$$(addsuffix .*,$$(subst /,.,$$($1_INCLUDES)))) \
-$$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES))) \
-$$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) -src $$(subst $$(SPACE),$$(PATH_SEP),$$(strip $$($1_SRC)))
-
-# Prepend the source/bin path to the filter expressions.
-ifneq ($$($1_INCLUDES),)
-  $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES))))
-  $1_PKG_INCLUDES := $$(addprefix /,$$(addsuffix /%,$$($1_INCLUDES)))
-  $1_BIN_INCLUDES := $$(addprefix $$($1_BIN)/,$$(addsuffix /%,$$($1_INCLUDES)))
-  $1_SRCS     := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
-  $1_PKGS     := $$(filter $$($1_PKG_INCLUDES),$$($1_PKGS))
-  $1_BINS     := $$(filter $$($1_BIN_INCLUDES),$$($1_BINS))
-endif
-ifneq ($$($1_EXCLUDES),)
-  $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
-  $1_PKG_EXCLUDES := $$(addprefix /,$$(addsuffix /%,$$($1_EXCLUDES)))
-  $1_BIN_EXCLUDES := $$(addprefix $$($1_BIN)/,$$(addsuffix /%,$$($1_EXCLUDES)))
-  $1_SRCS     := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
-  $1_PKGS     := $$(filter-out $$($1_PKG_EXCLUDES),$$($1_PKGS))
-  $1_BINS     := $$(filter-out $$($1_BIN_EXCLUDES),$$($1_BINS))
-endif
+    # Prepend the source/bin path to the filter expressions.
+    ifneq ($$($1_INCLUDES),)
+        $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES))))
+        $1_SRCS     := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
+    endif
+    ifneq ($$($1_EXCLUDES),)
+        $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
+        $1_SRCS     := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
+    endif
 
-# Find all files to be copied from source to bin.
-ifneq (,$$($1_COPY))
-    # Rewrite list of patterns into a find statement.
-    $1_COPY_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_COPY))
-    # Search for all files to be copied.
-    $1_ALL_COPIES := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i \( $$($1_COPY_PATTERN) \) -a -type f))
-    # Copy these explicitly
-    $1_ALL_COPIES += $$($1_COPY_FILES)
-    # Copy must also respect filters.
-    ifneq (,$$($1_INCLUDES))
-        $1_ALL_COPIES := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_COPIES))
+    # Find all files to be copied from source to bin.
+    ifneq (,$$($1_COPY))
+        # Rewrite list of patterns into a find statement.
+        $1_COPY_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_COPY))
+        # Search for all files to be copied.
+        $1_ALL_COPIES := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i \( $$($1_COPY_PATTERN) \) -a -type f))
+        # Copy these explicitly
+        $1_ALL_COPIES += $$($1_COPY_FILES)
+        # Copy must also respect filters.
+        ifneq (,$$($1_INCLUDES))
+            $1_ALL_COPIES := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_COPIES))
+        endif
+        ifneq (,$$($1_EXCLUDES))
+            $1_ALL_COPIES := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_COPIES))
+        endif
+        ifneq (,$$($1_EXCLUDE_FILES))
+            $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_COPIES))
+        endif
+        # All files below META-INF are always copied.
+        $1_ALL_COPIES += $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i/META-INF -type f 2> /dev/null))
+        ifneq (,$$($1_ALL_COPIES))
+            # Yep, there are files to be copied!
+            $1_ALL_COPY_TARGETS:=
+            $$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i)))
+            # Now we can depend on $$($1_ALL_COPY_TARGETS) to copy all files!
+        endif
     endif
-    ifneq (,$$($1_EXCLUDES))
-        $1_ALL_COPIES := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_COPIES))
-    endif
-    ifneq (,$$($1_EXCLUDE_FILES))
-        $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_COPIES))
-    endif
-    # All files below META-INF are always copied.
-    $1_ALL_COPIES += $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i/META-INF -type f 2> /dev/null))
-    ifneq (,$$($1_ALL_COPIES))
-        # Yep, there are files to be copied!
-        $1_ALL_COPY_TARGETS:=
-        $$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i)))
-        # Now we can depend on $$($1_ALL_COPY_TARGETS) to copy all files!
-    endif
-endif
 
-# Find all property files to be copied and cleaned from source to bin.
-ifneq (,$$($1_CLEAN))
-    # Rewrite list of patterns into a find statement.
-    $1_CLEAN_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_CLEAN))
-    # Search for all files to be copied.
-    $1_ALL_CLEANS := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i \( $$($1_CLEAN_PATTERN) \) -a -type f))
-    # Copy and clean must also respect filters.
-    ifneq (,$$($1_INCLUDES))
-        $1_ALL_CLEANS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_CLEANS))
-    endif
-    ifneq (,$$($1_EXCLUDES))
-        $1_ALL_CLEANS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_CLEANS))
-    endif
-    ifneq (,$$($1_EXCLUDE_FILES))
-        $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_CLEANS))
-    endif
-    ifneq (,$$($1_ALL_CLEANS))
-        # Yep, there are files to be copied and cleaned!
-        $1_ALL_COPY_CLEAN_TARGETS:=
-        $$(foreach i,$$($1_ALL_CLEANS),$$(eval $$(call add_file_to_copy_and_clean,$1,$$i)))
-        # Now we can depend on $$($1_ALL_COPY_CLEAN_TARGETS) to copy all files!
+    # Find all property files to be copied and cleaned from source to bin.
+    ifneq (,$$($1_CLEAN))
+        # Rewrite list of patterns into a find statement.
+        $1_CLEAN_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_CLEAN))
+        # Search for all files to be copied.
+        $1_ALL_CLEANS := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i \( $$($1_CLEAN_PATTERN) \) -a -type f))
+        # Copy and clean must also respect filters.
+        ifneq (,$$($1_INCLUDES))
+            $1_ALL_CLEANS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_CLEANS))
+        endif
+        ifneq (,$$($1_EXCLUDES))
+            $1_ALL_CLEANS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_CLEANS))
+        endif
+        ifneq (,$$($1_EXCLUDE_FILES))
+            $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_CLEANS))
+        endif
+        ifneq (,$$($1_ALL_CLEANS))
+            # Yep, there are files to be copied and cleaned!
+            $1_ALL_COPY_CLEAN_TARGETS:=
+            $$(foreach i,$$($1_ALL_CLEANS),$$(eval $$(call add_file_to_copy_and_clean,$1,$$i)))
+            # Now we can depend on $$($1_ALL_COPY_CLEAN_TARGETS) to copy all files!
+        endif
     endif
-endif
-
-# Find all the directories that contain java sources, each directory
-# corresponds to a package because we expect the source
-# code to be organized in this standardized way!
-$1_SDIRS := $$(sort $$(dir $$($1_SRCS)))
-# Now prefix each package with the bin root.
-$1_BDIRS := $$(foreach i,$$($1_PKGS),$$(addprefix $$($1_BIN),$$i))
-# Now create a list of the packages that are about to compile. This list is
-# later used to filter out dependencies that point outside of this set.
-$$(shell $(RM) $$($1_BIN)/_the.list_of_packages)
-$$(eval $$(call ListPathsSafelyNow,$1_BDIRS,\n, >> $$($1_BIN)/_the.list_of_packages))
-
-ifeq ($$($1_MODE),SINGLE_THREADED_BATCH)
-    # Ok, we will feed all the found java files into a single javac invocation.
-    # There can be no dependency checking, nor incremental builds. It is
-    # the best we can do with the old javac. If the javac supports a javac server
-    # then we can use the javac server.
-
-    # We can depend on this target file to trigger a regeneration of all the sources
-    $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/_the.batch
 
     # Prep the source paths.
     ifneq ($$($1_JAVAC_SOURCE_PATH_UGLY_OVERRIDE),)
@@ -807,113 +483,73 @@
     endif
 
     ifneq (,$$($1_HEADERS))
-      $1_HEADERS_ARG := -h $$($1_HEADERS)
+        $1_HEADERS_ARG := -h $$($1_HEADERS)
     endif
 
     # Create a sed expression to remove the source roots and to replace / with .
     # and remove .java at the end. 
     $1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g'
 
-    # Here is the batch rules that depends on all the sources.
-    $$($1_BIN)/_the.batch: $$($1_SRCS) $$($1_DEPENDS)
-	$(MKDIR) -p $$(@D)
-	$(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp
-	$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp)
-	$(ECHO) Compiling `$(WC) $$($1_BIN)/_the.batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files in batch $1
-ifeq ($$($1_NOSJAVAC),)
-ifeq ($$(ENABLE_SJAVAC),yes)
-	mkdir -p $$($1_BIN)_sjavac
-	$$($1_JVM) $$(word 1,$$($1_JAVAC)) com.sun.tools.javac.smart.Main $$($1_SJAVAC_ARGS) -mfl $$($1_BIN)/_the.batch.tmp -d $$($1_BIN)_sjavac
-endif
-endif
-	($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) -implicit:none -sourcepath "$$($1_SRCROOTSC)" -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.batch.tmp && \
-         $(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch)
-else
-    # Ok, we have a modern javac server running!
-    # Since a single Java file can generate zero to an infinity number of .class files
-    # the exact number and names of the .class files will only be known after the compile.
-    # Thus after the compile, a list of the generated classes will be stored in _the.package.d
-    # which is included by the makefile during the next compile. These .d files will
-    # add the generated class names to the BUILD_MYPACKAGE_CLASSES variable and used java file names
-    # to the BUILD_MYPACKAGE_JAVAS variable.
-    $1_CLASSES := 
-    $1_JAVAS   := 
-    # Create a file in each package that represents the package dependency.
-    # This file (_the.package) will also contain a list of the source files
-    # to be compiled for this package.
-    $1 := $$(sort $$(patsubst %,%_the.package,$$($1_BDIRS)))
-    # Now call add_java_package for each package to create the dependencies.
-    $$(foreach p,$$($1),$$(eval $$(call add_java_package,$1,$$p,$$($1_SRC),$$($1_BIN),$$($1_BIN)/_the.list_of_packages,NOTUSED,$$($1_USE_DEPS),$$($1_REMOTE),$$($1_JVM) $$($1_JAVAC),$$($1_FLAGS),$$($1_EXCLUDE_FILES_PATTERN) $(OVR_SRCS),$$($1_INCLUDE_FILES),$$($1_JVM) $$($1_JAVAH),$$($1_JAVAC_SOURCE_PATH_UGLY_OVERRIDE))))
-    # All dependencies are setup, now we only need to depend on $1 (aka $(BUILD_MYPACKAGE))
-    # and they will automatically be built!
+    ifeq ($$($1_DISABLE_SJAVAC)x$$(ENABLE_SJAVAC),xyes)
+        # Using sjavac to compile. 
+        $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/javac_state
 
-    # Now add on any files to copy targets
-    $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1)
-    # Remove the set of found classes from the set of all previously known classes
-    # and the remainder is the set of missing classes.
-    $1_MISSING_CLASSES:=$$(filter-out $$($1_BINS),$$($1_CLASSES))
-    $1_PKGS_MISSING_CLASSES:=$$(sort $$(dir $$($1_MISSING_CLASSES)))
-    # Remove the set of found java files from the set of all previously known java files
-    # the remainder is Java files that have gone missing.
-    $1_MISSING_JAVAS:=$$(filter-out $$($1_SRCS),$$($1_JAVAS))
-    $1_PKGS_MISSING_JAVAS:=$$(sort $$(dir $$($1_MISSING_JAVAS)))
-    # Remove each source root from the found paths.
-    $$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$1_PKGS_MISSING_JAVAS)))
-    # Finally remove duplicates and prefix with the binary path instead.
-    $1_PKGS_MISSING_JAVAS:= $$(addprefix $$($1_BIN),$$(sort $$($1_PKGS_MISSING_JAVAS)))
-
-    # Remove the set of all theoretical classes from the set of found classes.
-    # the remainder is the set of superfluous classes.
-    $1_SUPERFLUOUS_CLASSES:=$$(sort $$(filter-out $$($1_CLASSES),$$($1_BINS)))
-    $1_PKGS_SUPERFLUOUS_CLASSES:=$$(sort $$(dir $$($1_SUPERFLUOUS_CLASSES)))
+        $$($1_BIN)/javac_state: $$($1_SRCS) $$($1_DEPENDS)
+		$(MKDIR) -p $$(@D)
+		$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp)
+		$(ECHO) Compiling $1
+		$$($1_JVM) $$(word 1,$$($1_JAVAC)) com.sun.tools.sjavac.Main \
+			$$($1_REMOTE) $$($1_SJAVAC_ARGS) --permit-unidentified-artifacts -mfl $$($1_BIN)/_the.batch.tmp \
+			$$($1_FLAGS) \
+			-implicit:none -d $$($1_BIN) $$($1_HEADERS_ARG)
+    else
+        # Using plain javac to batch compile everything.
+        $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/_the.batch
 
-    # Now delete the _the.package files inside the problematic dirs.
-    # This will force a rebuild of these packages!
-    $1_FOO:=$$(sort $$($1_PKGS_MISSING_CLASSES) \
-                                                 $$($1_PKGS_SUPERFLUOUS_CLASSES) \
-                                                 $$($1_PKGS_MISSING_JAVAS))
-#    ifneq (,$$($1_FOO))
-#            $$(info MESSED UP PACKAGES $$($1_FOO))
-#    endif
-
-    $$(shell $(RM) $$(addsuffix _the.package,$$(sort $$($1_PKGS_MISSING_CLASSES) \
-                                                 $$($1_PKGS_SUPERFLUOUS_CLASSES) \
-                                                 $$($1_PKGS_MISSING_JAVAS))))
-
-    # Normal makefile dependencies based on timestamps will detect the normal use case
-    # when Java files are simply added or modified.
-endif
-
-ifneq (,$$($1_JAR))
-
-    ifeq (,$$($1_SUFFIXES))
-        $1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY)
+        # When not using sjavac, pass along all sources to javac using an @file.
+        $$($1_BIN)/_the.batch: $$($1_SRCS) $$($1_DEPENDS)
+		$(MKDIR) -p $$(@D)
+		$(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp
+		$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp)
+		$(ECHO) Compiling `$(WC) $$($1_BIN)/_the.batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1
+		($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) \
+			-implicit:none -sourcepath "$$($1_SRCROOTSC)" \
+			-d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.batch.tmp && \
+			$(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch)
     endif
 
-    # A jar file was specified. Set it up.
-    $$(eval $$(call SetupArchive,ARCHIVE_$1,$$($1),\
-	SRCS:=$$($1_BIN),\
-	SUFFIXES:=$$($1_SUFFIXES),\
-	EXCLUDE:=$$($1_EXCLUDES),\
-	INCLUDES:=$$($1_INCLUDES),\
-	EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS),\
-	JAR:=$$($1_JAR),\
-	JARMAIN:=$$($1_JARMAIN),\
-	MANIFEST:=$$($1_MANIFEST),\
-	EXTRA_MANIFEST_ATTR:=$$($1_EXTRA_MANIFEST_ATTR),\
-	JARINDEX:=$$($1_JARINDEX),\
-	HEADERS:=$$($1_HEADERS),\
-	SETUP:=$$($1_SETUP)))
-endif
+    # Check if a jar file was specified, then setup the rules for the jar.
+    ifneq (,$$($1_JAR))
+        # If no suffixes was explicitly set for this jar file.
+        # Use class and the cleaned/copied properties file suffixes as the default
+        # for the types of files to be put into the jar.
+        ifeq (,$$($1_SUFFIXES))
+            $1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY)
+        endif
 
-ifneq (,$$($1_SRCZIP))
-    # A srczip file was specified. Set it up.
-    $$(eval $$(call SetupZipArchive,ARCHIVE_$1,\
+        $$(eval $$(call SetupArchive,ARCHIVE_$1,$$($1),\
+		SRCS:=$$($1_BIN),\
+		SUFFIXES:=$$($1_SUFFIXES),\
+		EXCLUDE:=$$($1_EXCLUDES),\
+		INCLUDES:=$$($1_INCLUDES),\
+		EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS),\
+		JAR:=$$($1_JAR),\
+		JARMAIN:=$$($1_JARMAIN),\
+		MANIFEST:=$$($1_MANIFEST),\
+		EXTRA_MANIFEST_ATTR:=$$($1_EXTRA_MANIFEST_ATTR),\
+		JARINDEX:=$$($1_JARINDEX),\
+		HEADERS:=$$($1_HEADERS),\
+		SETUP:=$$($1_SETUP)))
+    endif
+
+    # Check if a srczip was specified, then setup the rules for the srczip.
+    ifneq (,$$($1_SRCZIP))
+        $$(eval $$(call SetupZipArchive,ARCHIVE_$1,\
 		SRC:=$$($1_SRC),\
 		ZIP:=$$($1_SRCZIP),\
 		INCLUDES:=$$($1_INCLUDES),\
 		EXCLUDES:=$$($1_EXCLUDES),\
 		EXCLUDE_FILES:=$$($1_EXCLUDE_FILES)))
-endif
+    endif
 
 endef
--- a/common/makefiles/MakeBase.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/makefiles/MakeBase.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -138,7 +138,7 @@
 
 # Hook to be called as the very first thing when running a normal build
 define AtRootMakeStart
-	$(if $(findstring -j,$(MAKEFLAGS)), $(error make -j is not supported, use make JOBS=n))
+	$(if $(findstring --jobserver,$(MAKEFLAGS)), $(error make -j is not supported, use make JOBS=n))
 	$(call PrintStartMessage)
 	$(call StartTimer)
 endef
--- a/common/makefiles/MakeHelpers.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/makefiles/MakeHelpers.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -57,9 +57,25 @@
 define ParseLogLevel
     ifeq ($$(origin VERBOSE),undefined)
         # Setup logging according to LOG (but only if VERBOSE is not given)
+        
+       # If the "nofile" argument is given, act on it and strip it away
+        ifneq ($$(findstring nofile,$$(LOG)),)
+          # Reset the build log wrapper, regardless of other values
+          override BUILD_LOG_WRAPPER=
+          # COMMA is defined in spec.gmk, but that is not included yet
+          COMMA=,
+          # First try to remove ",nofile" if it exists
+          LOG_STRIPPED1=$$(subst $$(COMMA)nofile,,$$(LOG))
+          # Otherwise just remove "nofile"
+          LOG_STRIPPED2=$$(subst nofile,,$$(LOG_STRIPPED1))
+          # We might have ended up with a leading comma. Remove it
+          LOG_STRIPPED3=$$(strip $$(patsubst $$(COMMA)%,%,$$(LOG_STRIPPED2)))
+          override LOG:=$$(LOG_STRIPPED3)
+        endif
+
         ifeq ($$(LOG),)
             # Set LOG to "warn" as default if not set (and no VERBOSE given)
-            LOG=warn
+            override LOG=warn
         endif
         ifeq ($$(LOG),warn)
             VERBOSE=-s
@@ -182,4 +198,11 @@
     $(call CheckEnvironment)
 endef
 
+# Cleans the component given as $1
+define CleanComponent
+    @$(PRINTF) "Cleaning $1 build artifacts ..."
+    @($(CD) $(OUTPUT_ROOT) && $(RM) -r $1)
+    @$(PRINTF) " done\n"
+endef
+
 endif # _MAKEHELPERS_GMK
--- a/common/makefiles/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/makefiles/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -26,6 +26,11 @@
 # This must be the first rule
 default: all
 
+# Inclusion of this pseudo-target will cause make to execute this file
+# serially, regardless of -j. Recursively called makefiles will not be
+# affected, however. This is required for correct dependency management.
+.NOTPARALLEL:
+
 # Locate this Makefile
 ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
     makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
@@ -41,18 +46,18 @@
 $(eval $(call SetupLogging))
 $(eval $(call ParseConfAndSpec))
 
-# Setup number of jobs to use. -jN is unfortunately not available for us to parse from the command line,
-# hence this workaround.
-ifeq ($(JOBS),)
-    JOBS=$(NUM_CORES)
-endif
-
 ifneq ($(words $(SPEC)),1)
 ### We have multiple configurations to build, call make repeatedly
-all jdk hotspot jaxws jaxp corba langtools install images clean dist-clean:
-	@$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@ $(MAKE_ARGS)) &&) true
+all clean dist-clean:
+langtools corba jaxp jaxws hotspot jdk images overlay-images install:
+langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only:
+clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images:
+	@$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@) &&) true
 
-.PHONY: all jdk hotspot jaxws jaxp corba langtools install images clean dist-clean
+.PHONY: all clean dist-clean
+.PHONY: langtools corba jaxp jaxws hotspot jdk images overlay-images install
+.PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only
+.PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images
 
 else
 ### This is the main part of the Makefile, for the normal case with SPEC specifying a single existing spec.gmk file.
@@ -77,77 +82,110 @@
 endif
 # Remove any javac server logs and port files. This
 # prevents a new make run to reuse the previous servers.
-ifneq (,$(JAVAC_SERVERS))
-    $(shell mkdir -p $(JAVAC_SERVERS) && rm -rf $(JAVAC_SERVERS)/*)
+ifneq (,$(SJAVAC_SERVER_DIR))
+    $(shell $(MKDIR) -p $(SJAVAC_SERVER_DIR) && $(RM) -rf $(SJAVAC_SERVER_DIR)/*)
 endif
 # Clean out any notifications from the previous build.
-$(shell find $(OUTPUT_ROOT) -name "_the.*.notify" $(FIND_DELETE))
+$(shell $(FIND) $(OUTPUT_ROOT) -name "_the.*.notify" $(FIND_DELETE))
 
 # Reset the build timers.
 $(eval $(call ResetTimers))
 
+# Setup number of jobs to use. -jN is unfortunately not available for us to parse from the command line,
+# hence this workaround.
+ifeq ($(JOBS),)
+    JOBS=$(NUM_CORES)
+endif
+MAKE_ARGS:=$(MAKE_ARGS) -j$(JOBS)
+
 ### Main targets
 
 all: jdk
-	@$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
+	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
 	@$(call AtRootMakeEnd)
+.PHONY: all
 
 langtools: start-make langtools-only
 langtools-only:
 	@$(call MakeStart,langtools,all)
-	@($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
+	@($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
 	@$(call MakeFinish,langtools,all)
 
 corba: langtools corba-only
 corba-only:
 	@$(call MakeStart,corba,all)
-	@($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
+	@($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
 	@$(call MakeFinish,corba,all)
 
 jaxp: langtools jaxp-only
 jaxp-only:
 	@$(call MakeStart,jaxp,all)
-	@($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
+	@($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
 	@$(call MakeFinish,jaxp,all)
 
 jaxws: langtools jaxp jaxws-only
 jaxws-only:
 	@$(call MakeStart,jaxws,all)
-	@($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
+	@($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
 	@$(call MakeFinish,jaxws,all)
 
 hotspot: langtools hotspot-only
 hotspot-only:
 	@$(call MakeStart,hotspot,all)
-	@($(CD) $(HOTSPOT_TOPDIR)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 $(HOTSPOT_MAKE_ARGS) $(MAKE_ARGS))
+	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk)
 	@$(call MakeFinish,hotspot,all)
 
 jdk: langtools corba jaxp jaxws hotspot jdk-only
 jdk-only:
 	@$(call MakeStart,jdk,all)
-	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
+	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(JDK_TARGET))
 	@$(call MakeFinish,jdk,all)
 
 images: source-tips start-make jdk langtools corba jaxp jaxws hotspot images-only
 images-only:
 	@$(call MakeStart,jdk-images,$@)
-	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(JDK_MAKE_ARGS) $(MAKE_ARGS) images)
+	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) images)
 	@$(call MakeFinish,jdk-images,$@)
-	@$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
+	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
+	@$(call AtRootMakeEnd)
+
+overlay-images: source-tips start-make jdk langtools corba jaxp jaxws hotspot overlay-images-only
+overlay-images-only:
+	@$(call MakeStart,jdk-overlay-images,$@)
+	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) overlay-images)
+	@$(call MakeFinish,jdk-overlay-images,$@)
+	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
 	@$(call AtRootMakeEnd)
 
 install: source-tips start-make jdk langtools corba jaxp jaxws hotspot install-only
 install-only:
 	@$(call MakeStart,jdk-images,$@)
-	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(JDK_MAKE_ARGS) $(MAKE_ARGS) install)
+	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) install)
 	@$(call MakeFinish,jdk-images,$@)
-	@$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
+	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
 	@$(call AtRootMakeEnd)
 
+docs: start-make jdk docs-only
+docs-only:
+	@$(call MakeStart,docs,$@)
+	@($(CD) $(SRC_ROOT)/common/makefiles/javadoc && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs)
+	@$(call MakeFinish,docs,$@)
+	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
+	@$(call AtRootMakeEnd)
+
+
+.PHONY: langtools corba jaxp jaxws hotspot jdk images install
+.PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only install-only
+
 start-make:
 	@$(call AtRootMakeStart)
+.PHONY: start-make
 
-.PHONY: jdk hotspot jaxws jaxp corba langtools install images start-make
+bootcycle-images:
+	@$(ECHO) Boot cycle build step 1: Building the JDK image normally
+	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(SPEC) images)
+	@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
+	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(dir $(SPEC))bootcycle-spec.gmk images)
 
 test: start-make
 	@$(call MakeStart,test,$(if $(TEST),$(TEST),all))
@@ -167,8 +205,8 @@
 
 
 # Remove everything, except the output from configure.
-clean:
-	@(cd $(OUTPUT_ROOT) && $(RM) -r `$(LS) $(OUTPUT_ROOT) | grep -v spec.gmk | grep -v spec.sh | grep -v Makefile | grep -v config.status | grep -v config.log | grep -v config.h | grep -v configure-arguments | grep -v "localdevenv.*" | grep -v uncygdrive.exe`)
+clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-bootcycle-build
+	@($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log*)
 	@$(ECHO) Cleaned everything except the build configuration.
 .PHONY: clean
 
@@ -178,11 +216,24 @@
 	@$(ECHO) Cleaned everything, you will have to re-run configure.
 .PHONY: dist-clean
 
+clean-langtools:
+	$(call CleanComponent,langtools)
+clean-corba:
+	$(call CleanComponent,corba)
+clean-jaxp:
+	$(call CleanComponent,jaxp)
+clean-jaxws:
+	$(call CleanComponent,jaxws)
+clean-hotspot:
+	$(call CleanComponent,hotspot)
 clean-jdk:
-	@(cd $(OUTPUT_ROOT) && $(RM) -r `$(LS) $(OUTPUT_ROOT) | grep -v spec.gmk | grep -v spec.sh | grep -v Makefile | grep -v config.status | grep -v config.log |  grep -v config.h | grep -v configure-arguments | \
-                               grep -v langtools | grep -v corba | grep -v jaxp | grep -v jaxws | grep -v hotspot`)
-	@$(ECHO) "Cleaned jdk build artifacts (but not langtools,corba,jaxp,jaxws,hotspot nor the build configuration)"
-.PHONY: clean
+	$(call CleanComponent,jdk)
+clean-images:
+	$(call CleanComponent,images)
+clean-bootcycle-build:
+	$(call CleanComponent,bootcycle-build)
+
+.PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images
 
 endif
 
@@ -195,24 +246,39 @@
 	$(info =====================)
 	$(info )
 	$(info Common make targets)
-	$(info .  make [all]            # Compile all code but do not create images)
-	$(info .  make images           # Create complete j2sdk and j2re images)
-	$(info .  make install          # Install the generated images locally)
-	$(info .  make clean            # Remove all files generated by make, but not those generated by configure)
-	$(info .  make dist-clean       # Remove all files generated by both make and configure)
-	$(info .  make help             # Give some help on using make)
-	$(info .  make test             # Run tests, default is all tests (see TEST below))
+	$(info .  make [all]             # Compile all code but do not create images)
+	$(info .  make images            # Create complete j2sdk and j2re images)
+	$(info .  make overlay-images    # Create limited images for sparc 64 bit platforms)
+	$(info .  make bootcycle-images  # Build images twice, second time with newly build JDK)
+	$(info .  make install           # Install the generated images locally)
+	$(info .  make clean             # Remove all files generated by make, but not those)
+	$(info .                         # generated by configure)
+	$(info .  make dist-clean        # Remove all files, including configuration)
+	$(info .  make help              # Give some help on using make)
+	$(info .  make test              # Run tests, default is all tests (see TEST below))
+	$(info )
+	$(info Targets for specific components)
+	$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk or images))
+	$(info .  make <component>       # Build <component> and everything it depends on. )
+	$(info .  make <component>-only  # Build <component> only, without dependencies. This)
+	$(info .                         # is faster but can result in incorrect build results!)
+	$(info .  make clean-<component> # Remove files generated by make for <component>)
 	$(info )
 	$(info Useful make variables)
-	$(info .  make CONF=            # Build all configurations (note, assignment is empty))
-	$(info .  make CONF=<substring> # Build the configuration(s) with a name matching the given substring)
+	$(info .  make CONF=             # Build all configurations (note, assignment is empty))
+	$(info .  make CONF=<substring>  # Build the configuration(s) with a name matching)
+	$(info .                         # <substring>)
 	$(info )
-	$(info .  make LOG=<loglevel>   # Change loglevel from warn (default) to the given loglevel)
-	$(info .                        # Available loglevels are: warn, info, debug and trace)
-	$(info .                        # To see executed command lines, use LOG=info)
+	$(info .  make LOG=<loglevel>    # Change the log level from warn to <loglevel>)
+	$(info .                         # Available log levels are:)
+	$(info .                         # 'warn' (default), 'info', 'debug' and 'trace')
+	$(info .                         # To see executed command lines, use LOG=info)
 	$(info )
-	$(info .  make test TEST=<test> # Only run the given test or tests, e.g.)
-	$(info .                        # make test TEST="jdk_lang jdk_net")
+	$(info .  make JOBS=<n>          # Run <n> parallel make jobs)
+	$(info .                         # Note that -jN does not work as expected!)
+	$(info )
+	$(info .  make test TEST=<test>  # Only run the given test or tests, e.g.)
+	$(info .                         # make test TEST="jdk_lang jdk_net")
 	$(info )
 .PHONY: help
 FRC: # Force target
--- a/common/makefiles/NativeCompilation.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/common/makefiles/NativeCompilation.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -55,22 +55,22 @@
 
     ifneq (,$$(filter %.c,$2))
         # Compile as a C file
-        $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -c
+        $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
         $1_$2_COMP=$5
         $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
     else ifneq (,$$(filter %.m,$2))
         # Compile as a objective-c file
-        $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) -c
+        $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
         $1_$2_COMP=$5
         $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
     else ifneq (,$$(filter %.s,$2))
         # Compile as assembler file
-        $1_$2_FLAGS=$8
+        $1_$2_FLAGS=$8 -DTHIS_FILE='"$$(<F)"'
         $1_$2_COMP=$(AS)
         $1_$2_DEP_FLAG:=
     else
         # Compile as a C++ file
-        $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) -c
+        $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) -DTHIS_FILE='"$$(<F)"' -c
         $1_$2_COMP=$7
         $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS)
     endif
@@ -98,7 +98,6 @@
 		$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2
         endif
         ifeq ($(COMPILER_TYPE),CL)
-		$$(call COMPILING_MSG,$$(notdir $2))
 		$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEBUG_OUT_FLAGS) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2
         endif
     endif
@@ -129,6 +128,7 @@
     #    DEBUG_SYMBOLS add debug symbols (if configured on)
     #    CC the compiler to use, default is $(CC)
     #    LDEXE the linker to use for linking executables, default is $(LDEXE)
+    #    OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST
     $(if $2,$1_$(strip $2))
     $(if $3,$1_$(strip $3))
     $(if $4,$1_$(strip $4))
@@ -149,7 +149,11 @@
     $(if $(19),$1_$(strip $(19)))
     $(if $(20),$1_$(strip $(20)))
     $(if $(21),$1_$(strip $(21)))
-    $(if $(22),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk))
+    $(if $(22),$1_$(strip $(22)))
+    $(if $(23),$1_$(strip $(23)))
+    $(if $(24),$1_$(strip $(24)))
+    $(if $(25),$1_$(strip $(25)))
+    $(if $(26),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk))
 
     ifneq (,$$($1_BIN))
         $$(error BIN has been replaced with OBJECT_DIR)
@@ -315,6 +319,17 @@
         $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release)
     endif
 
+    ifneq (,$$($1_DEBUG_SYMBOLS))	
+        ifeq ($(ENABLE_DEBUG_SYMBOLS), yes)
+            # Programs don't get the debug symbols added in the old build. It's not clear if
+            # this is intentional.
+            ifeq ($$($1_PROGRAM),)
+                $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS)
+                $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS)
+            endif
+        endif
+    endif
+
     ifeq ($$($1_CXXFLAGS),)
         $1_CXXFLAGS:=$$($1_CFLAGS)
     endif
@@ -327,40 +342,20 @@
           $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER)
     endif
 
-    ifneq (no, $(ENABLE_DEBUG_SYMBOLS))
-	ifneq ($(OPENJDK_TARGET_OS), solaris)
-# <weird code />
-# There is very weird code in Defs-solaris.gmk that first sets variables as decribed below
-#   and then a couple of hundreds of line below resets them...
-#   this feels like a sure bug...but before this is confirmed, mimic this behaviour
-# (note: skip indenting this as it will surely be removed anyway)
-# <weird code />
-
-        ifneq (,$$($1_DEBUG_SYMBOLS))
-		$1_OPTIMIZATION := LOW
-		$1_EXTRA_CFLAGS += $(CFLAGS_DEBUG_SYMBOLS)
-		$1_EXTRA_CXXFLAGS += $(CXXFLAGS_DEBUG_SYMBOLS)
-        endif
-
-# <weird code />
-	endif
-# <weird code />
-    endif
-
     ifeq (NONE, $$($1_OPTIMIZATION))
-	$1_EXTRA_CFLAGS += $$(C_O_FLAG_NONE)
-	$1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_NONE)
+        $1_EXTRA_CFLAGS += $(C_O_FLAG_NONE)
+        $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_NONE)
     else ifeq (LOW, $$($1_OPTIMIZATION))
-	$1_EXTRA_CFLAGS += $$(C_O_FLAG_NORM)
-	$1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_NORM)
+        $1_EXTRA_CFLAGS += $(C_O_FLAG_NORM)
+        $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_NORM)
     else ifeq (HIGH, $$($1_OPTIMIZATION))
-	$1_EXTRA_CFLAGS += $$(C_O_FLAG_HI)
-	$1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_HI)
+        $1_EXTRA_CFLAGS += $(C_O_FLAG_HI)
+        $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HI)
     else ifeq (HIGHEST, $$($1_OPTIMIZATION))
-	$1_EXTRA_CFLAGS += $$(C_O_FLAG_HIGHEST)
-	$1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_HIGHEST)
+        $1_EXTRA_CFLAGS += $(C_O_FLAG_HIGHEST)
+        $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HIGHEST)
     else ifneq (, $$($1_OPTIMIZATION))
-	$$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION))
+        $$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION))
     endif
 
     # Now create a list of the packages that are about to compile. Used when sending source
@@ -375,7 +370,7 @@
 			$$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS),$(CXX),$$($1_ASFLAGS))))
 
     # On windows we need to create a resource file
-    ifeq ($(OPENJDK_TARGET_OS_API), winapi)
+    ifeq ($(OPENJDK_TARGET_OS), windows)
         ifneq (,$$($1_VERSIONINFO_RESOURCE))
             $1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res
             $$($1_RES): $$($1_VERSIONINFO_RESOURCE)
@@ -409,8 +404,8 @@
     endif
     endif
 
-    # Pickup extra OPENJDK_TARGET_OS_API dependent variables (posix or winapi) and 
-    # (linux,solaris,windows,bsd) for LDFLAGS and LDFLAGS_SUFFIX
+    # Pickup extra OPENJDK_TARGET_OS_API and/or OPENJDK_TARGET_OS dependent variables
+    # for LDFLAGS and LDFLAGS_SUFFIX
     $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
     $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS))
     ifneq (,$$($1_REAL_MAPFILE))
@@ -432,9 +427,10 @@
 				      "-map:$$($1_OBJECT_DIR)/$$($1_LIBRARY).map"
                 endif
 
-                $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/%
+                ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR))
+                    $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/%
 			$(CP) $$< $$@
-
+                endif
 
                 ifeq ($(OPENJDK_TARGET_OS), solaris)
                     # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
@@ -509,8 +505,10 @@
 				      "-map:$$($1_OBJECT_DIR)/$$($1_PROGRAM).map"
                 endif
 
-                $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/%
+                ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR))
+                    $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/%
 			$(CP) $$< $$@
+                endif
 
                 ifeq ($(OPENJDK_TARGET_OS), solaris)
                     # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/makefiles/javadoc/CORE_PKGS.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,293 @@
+#
+# 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
+# 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.
+#
+
+# EXCLUDE_PKGS is the list of packages to exclude from the
+# Java API Specification.  Do not add these to CORE_PKGS.
+# The concatenation of EXCLUDE_PKGS and CORE_PKGS
+# should make up the list of all packages under the
+# src/shared/classes directory of the JDK source tree.
+#
+EXCLUDE_PKGS =             \
+  java.awt.peer            \
+  java.awt.dnd.peer        \
+  sun.*                    \
+  com.sun.*                \
+  org.apache.*             \
+  org.jcp.*		   \
+  org.w3c.dom.css          \
+  org.w3c.dom.html         \
+  org.w3c.dom.stylesheets  \
+  org.w3c.dom.traversal    \
+  org.w3c.dom.ranges       \
+  org.w3c.dom.views        \
+  org.omg.stub.javax.management.remote.rmi
+
+#
+# ACTIVE_JSR_PKGS are packages that are part of an active JSR process--
+# one that is doing its own review. These packages are not included when
+# creating diff pages for the platform's JCP process.
+# 
+#       (see /java/pubs/apisrc/jdk/6.0/beta/make/docs/active_jsr_pkgs)
+# Note:
+# This is a list of regular expressions. So foo.* matches "foo" and "foo.bar".
+#
+ACTIVE_JSR_PKGS= \
+  java.lang.invoke \
+  java.sql  \
+  javax.activation  \
+  javax.annotation.*  \
+  javax.jws.*  \
+  javax.lang.*  \
+  javax.management.*  \
+  javax.script  \
+  javax.sql.*  \
+  javax.tools.*  \
+  javax.xml.*  \
+  org.w3c.*  \
+  org.xml.sax
+
+#
+# CORE_PKGS is the list of packages that form the
+# Java API Specification.
+#
+### ***IMPORTANT NOTE***
+### There is also a "REGEXP" variable in the docs/makefile that
+### determines which table the packages go in on the main page.
+### Currently, there is only table ("Platform Packages") and
+### everything goes in it, so REGEXP is "*". But if that policy
+### changes, packages added will need to be reflected in  that
+### list of wildcard expressions, as well.
+###
+CORE_PKGS =                                      \
+  java.applet                                    \
+  java.awt                                       \
+  java.awt.color                                 \
+  java.awt.datatransfer                          \
+  java.awt.dnd                                   \
+  java.awt.event                                 \
+  java.awt.font                                  \
+  java.awt.geom                                  \
+  java.awt.im                                    \
+  java.awt.im.spi                                \
+  java.awt.image                                 \
+  java.awt.image.renderable                      \
+  java.awt.print                                 \
+  java.beans                                     \
+  java.beans.beancontext                         \
+  java.io                                        \
+  java.lang                                      \
+  java.lang.annotation                           \
+  java.lang.instrument                           \
+  java.lang.invoke                               \
+  java.lang.management                           \
+  java.lang.ref                                  \
+  java.lang.reflect                              \
+  java.math                                      \
+  java.net                                       \
+  java.nio                                       \
+  java.nio.channels                              \
+  java.nio.channels.spi                          \
+  java.nio.charset                               \
+  java.nio.charset.spi                           \
+  java.nio.file					 \
+  java.nio.file.attribute			 \
+  java.nio.file.spi				 \
+  java.rmi                                       \
+  java.rmi.activation                            \
+  java.rmi.dgc                                   \
+  java.rmi.registry                              \
+  java.rmi.server                                \
+  java.security                                  \
+  java.security.acl                              \
+  java.security.cert                             \
+  java.security.interfaces                       \
+  java.security.spec                             \
+  java.sql                                       \
+  java.text                                      \
+  java.text.spi                                  \
+  java.util                                      \
+  java.util.concurrent                           \
+  java.util.concurrent.atomic                    \
+  java.util.concurrent.locks                     \
+  java.util.jar                                  \
+  java.util.logging                              \
+  java.util.prefs                                \
+  java.util.regex                                \
+  java.util.spi                                  \
+  java.util.zip                                  \
+  javax.accessibility                            \
+  javax.activation                               \
+  javax.activity                                 \
+  javax.annotation                               \
+  javax.annotation.processing                    \
+  javax.crypto                                   \
+  javax.crypto.interfaces                        \
+  javax.crypto.spec                              \
+  javax.imageio                                  \
+  javax.imageio.event                            \
+  javax.imageio.metadata                         \
+  javax.imageio.plugins.jpeg                     \
+  javax.imageio.plugins.bmp                      \
+  javax.imageio.spi                              \
+  javax.imageio.stream                           \
+  javax.jws                                      \
+  javax.jws.soap                                 \
+  javax.lang.model                               \
+  javax.lang.model.element                       \
+  javax.lang.model.type                          \
+  javax.lang.model.util                          \
+  javax.management                               \
+  javax.management.loading                       \
+  javax.management.monitor                       \
+  javax.management.relation                      \
+  javax.management.openmbean                     \
+  javax.management.timer                         \
+  javax.management.modelmbean                    \
+  javax.management.remote                        \
+  javax.management.remote.rmi                    \
+  javax.naming                                   \
+  javax.naming.directory                         \
+  javax.naming.event                             \
+  javax.naming.ldap                              \
+  javax.naming.spi                               \
+  javax.net                                      \
+  javax.net.ssl                                  \
+  javax.print                                    \
+  javax.print.attribute                          \
+  javax.print.attribute.standard                 \
+  javax.print.event                              \
+  javax.rmi                                      \
+  javax.rmi.CORBA                                \
+  javax.rmi.ssl                                  \
+  javax.script                                   \
+  javax.security.auth                            \
+  javax.security.auth.callback                   \
+  javax.security.auth.kerberos                   \
+  javax.security.auth.login                      \
+  javax.security.auth.spi                        \
+  javax.security.auth.x500                       \
+  javax.security.cert                            \
+  javax.security.sasl                            \
+  javax.sound.sampled                            \
+  javax.sound.sampled.spi                        \
+  javax.sound.midi                               \
+  javax.sound.midi.spi                           \
+  javax.sql                                      \
+  javax.sql.rowset                               \
+  javax.sql.rowset.serial                        \
+  javax.sql.rowset.spi                           \
+  javax.swing                                    \
+  javax.swing.border                             \
+  javax.swing.colorchooser                       \
+  javax.swing.filechooser                        \
+  javax.swing.event                              \
+  javax.swing.table                              \
+  javax.swing.text                               \
+  javax.swing.text.html                          \
+  javax.swing.text.html.parser                   \
+  javax.swing.text.rtf                           \
+  javax.swing.tree                               \
+  javax.swing.undo                               \
+  javax.swing.plaf                               \
+  javax.swing.plaf.basic                         \
+  javax.swing.plaf.metal                         \
+  javax.swing.plaf.multi                         \
+  javax.swing.plaf.nimbus                        \
+  javax.swing.plaf.synth                         \
+  javax.tools                                    \
+  javax.tools.annotation                         \
+  javax.transaction                              \
+  javax.transaction.xa                           \
+  javax.xml.parsers                              \
+  javax.xml.bind                                 \
+  javax.xml.bind.annotation                      \
+  javax.xml.bind.annotation.adapters             \
+  javax.xml.bind.attachment                      \
+  javax.xml.bind.helpers                         \
+  javax.xml.bind.util                            \
+  javax.xml.soap                                 \
+  javax.xml.ws                                   \
+  javax.xml.ws.handler                           \
+  javax.xml.ws.handler.soap                      \
+  javax.xml.ws.http                              \
+  javax.xml.ws.soap                              \
+  javax.xml.ws.spi                               \
+  javax.xml.ws.spi.http                          \
+  javax.xml.ws.wsaddressing                      \
+  javax.xml.transform                            \
+  javax.xml.transform.sax                        \
+  javax.xml.transform.dom                        \
+  javax.xml.transform.stax                       \
+  javax.xml.transform.stream                     \
+  javax.xml                                      \
+  javax.xml.crypto				 \
+  javax.xml.crypto.dom				 \
+  javax.xml.crypto.dsig				 \
+  javax.xml.crypto.dsig.dom			 \
+  javax.xml.crypto.dsig.keyinfo			 \
+  javax.xml.crypto.dsig.spec			 \
+  javax.xml.datatype                             \
+  javax.xml.validation                           \
+  javax.xml.namespace                            \
+  javax.xml.xpath                                \
+  javax.xml.stream                               \
+  javax.xml.stream.events                        \
+  javax.xml.stream.util                          \
+  org.ietf.jgss                                  \
+  org.omg.CORBA                                  \
+  org.omg.CORBA.DynAnyPackage                    \
+  org.omg.CORBA.ORBPackage                       \
+  org.omg.CORBA.TypeCodePackage                  \
+  org.omg.stub.java.rmi                          \
+  org.omg.CORBA.portable                         \
+  org.omg.CORBA_2_3                              \
+  org.omg.CORBA_2_3.portable                     \
+  org.omg.CosNaming                              \
+  org.omg.CosNaming.NamingContextExtPackage      \
+  org.omg.CosNaming.NamingContextPackage         \
+  org.omg.SendingContext                         \
+  org.omg.PortableServer                         \
+  org.omg.PortableServer.CurrentPackage          \
+  org.omg.PortableServer.POAPackage              \
+  org.omg.PortableServer.POAManagerPackage       \
+  org.omg.PortableServer.ServantLocatorPackage   \
+  org.omg.PortableServer.portable                \
+  org.omg.PortableInterceptor                    \
+  org.omg.PortableInterceptor.ORBInitInfoPackage \
+  org.omg.Messaging                              \
+  org.omg.IOP                                    \
+  org.omg.IOP.CodecFactoryPackage                \
+  org.omg.IOP.CodecPackage                       \
+  org.omg.Dynamic                                \
+  org.omg.DynamicAny                             \
+  org.omg.DynamicAny.DynAnyPackage               \
+  org.omg.DynamicAny.DynAnyFactoryPackage        \
+  org.w3c.dom                                    \
+  org.w3c.dom.events                             \
+  org.w3c.dom.bootstrap                          \
+  org.w3c.dom.ls                                 \
+  org.xml.sax                                    \
+  org.xml.sax.ext                                \
+  org.xml.sax.helpers
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/makefiles/javadoc/Javadoc.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,1184 @@
+# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  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.
+#
+
+include $(SPEC)
+include MakeBase.gmk
+
+.SUFFIXES: # Delete the default suffixes
+.SUFFIXES: .java
+
+#
+# Definitions for $(DOCSDIR), $(MKDIR), $(BINDIR), etc.
+#
+
+CLASSPATH_SEPARATOR = :
+
+DOCSDIR=$(OUTPUT_ROOT)/docs
+TEMPDIR=$(OUTPUT_ROOT)/docstemp
+
+JDK_SHARE_SRC=$(JDK_TOPDIR)/src/share
+JDK_SHARE_CLASSES=$(JDK_SHARE_SRC)/classes
+
+JDK_IMPSRC = $(JDK_OUTPUTDIR)/impsrc
+
+JDK_GENSRC = $(JDK_OUTPUTDIR)/gensrc
+
+HOTSPOT_DOCS_IMPORT_PATH=$(HOTSPOT_OUTPUTDIR)/docs
+
+BUILD_NUMBER=$(JDK_BUILD_NUMBER)
+
+BOOT_JAVA_CMD=$(JAVA)
+
+# Langtools
+JAVAC_JAR   = $(LANGTOOLS_DIST)/bootstrap/lib/javac.jar
+JAVADOC_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/javadoc.jar
+DOCLETS_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/doclets.jar
+JAVADOC_CMD = $(BOOT_JAVA_CMD) \
+              -Xmx1024m \
+	      -Djava.awt.headless=true \
+              "-Xbootclasspath/p:$(JAVADOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)$(CLASSPATH_SEPARATOR)$(DOCLETS_JAR)" \
+              -jar $(JAVADOC_JAR)
+
+JAVADOC_CMD = javadoc 
+
+# Copyright year for beginning of Java and some of the apis
+#   (Needed when creating the javadocs)
+FIRST_COPYRIGHT_YEAR                = 1993
+DOMAPI_FIRST_COPYRIGHT_YEAR         = 2005
+MIRROR_FIRST_COPYRIGHT_YEAR         = 2004
+DOCLETAPI_FIRST_COPYRIGHT_YEAR      = 1993
+TAGLETAPI_FIRST_COPYRIGHT_YEAR      = 1993
+JDI_FIRST_COPYRIGHT_YEAR            = 1999
+JAAS_FIRST_COPYRIGHT_YEAR           = 1998
+JGSS_FIRST_COPYRIGHT_YEAR           = 2000
+SMARTCARDIO_FIRST_COPYRIGHT_YEAR    = 2005
+HTTPSERVER_FIRST_COPYRIGHT_YEAR     = 2005
+MGMT_FIRST_COPYRIGHT_YEAR           = 2003
+ATTACH_FIRST_COPYRIGHT_YEAR         = 2005
+JCONSOLE_FIRST_COPYRIGHT_YEAR       = 2006
+SCTPAPI_FIRST_COPYRIGHT_YEAR        = 2009
+TRACING_FIRST_COPYRIGHT_YEAR        = 2008
+TREEAPI_FIRST_COPYRIGHT_YEAR        = 2005
+JNLP_FIRST_COPYRIGHT_YEAR           = 1998
+PLUGIN2_FIRST_COPYRIGHT_YEAR        = 2007
+
+# Oracle name
+FULL_COMPANY_NAME = Oracle and/or its affiliates
+
+# Copyright address
+COMPANY_ADDRESS = 500 Oracle Parkway<br>Redwood Shores, CA 94065 USA.
+
+# The trademark symbol
+TRADEMARK = &trade;
+
+# Common copyright lines used
+#   The word "Copyright" might optionally be a link to the file cpyr.html.
+#   The first year of copyright may vary or not be available.
+#   The address to the company might be optional.
+COMMA:= ,
+EMPTY:=
+SPACE:=$(EMPTY) $(EMPTY)
+COPYRIGHT_SYMBOL = &\#x00a9;
+# Macro to construct the copyright line
+#   (The GNU make 3.78.1 "if" conditional is broken, fixed in GNU make 3.81)
+define CopyrightLine # optionalurl optionalfirstyear optionaladdress
+$(if $(strip $1),<a href="$(strip $1)">Copyright</a>,Copyright) \
+$(COPYRIGHT_SYMBOL) $(if $2,$2${COMMA},) $(COPYRIGHT_YEAR),\
+$(FULL_COMPANY_NAME). $3 All rights reserved.
+endef
+
+# Url to root of documents
+DOCSDIR_URL = {@docroot}/$(GET2DOCSDIR)
+
+# Url to copyright html file
+COPYRIGHT_URL-7 = $(DOCSDIR_URL)/legal/cpyr.html
+COPYRIGHT_URL-8 = $(DOCSDIR_URL)/legal/cpyr.html
+COPYRIGHT_URL = $(COPYRIGHT_URL-$(JDK_MINOR_VERSION))
+
+# Url to bug filing site
+BUG_SUBMIT_URL = http://bugreport.sun.com/bugreport/
+
+# Common line for how to submit a bug or rfe
+BUG_SUBMIT_LINE = <a href="$(BUG_SUBMIT_URL)">Submit a bug or feature</a>
+
+# Url to devdocs page
+#   Was: http://java.sun.com/javase/6/webnotes/devdocs-vs-specs.html
+DEV_DOCS_URL-7 = http://download.oracle.com/javase/7/docs/index.html
+DEV_DOCS_URL-8 = http://download.oracle.com/javase/7/docs/index.html
+DEV_DOCS_URL = $(DEV_DOCS_URL-$(JDK_MINOR_VERSION))
+DOCS_BASE_URL = http://download.oracle.com/javase/7/docs
+
+# Common Java trademark line
+JAVA_TRADEMARK_LINE = Java is a trademark or registered trademark of \
+$(FULL_COMPANY_NAME) in the US and other countries.
+
+#################################################################
+# Macros:
+
+
+# List of all possible directories for javadoc to look for sources
+#    NOTE: Quotes are required around sourcepath argument only on Windows.
+#          Otherwise, you get "No packages or classes specified." due 
+#          to $(CLASSPATH_SEPARATOR) being interpreted as an end of 
+#          command (newline or shell ; character)
+ALL_SOURCE_DIRS = $(JDK_IMPSRC) \
+                  $(JDK_GENSRC) \
+                  $(JDK_SHARE_CLASSES) \
+                  $(JDK_TOPDIR)/src/solaris/classes \
+                  $(JDK_TOPDIR)/src/windows/classes \
+		  $(JDK_SHARE_SRC)/doc/stub
+
+# List of directories that actually exist
+ALL_EXISTING_SOURCE_DIRS := $(wildcard $(ALL_SOURCE_DIRS))
+
+# List with classpath separator between them
+EMPTY:=
+SPACE:= $(EMPTY) $(EMPTY)
+RELEASEDOCS_SOURCEPATH = \
+    $(subst $(SPACE),$(CLASSPATH_SEPARATOR),$(strip $(ALL_SOURCE_DIRS)))
+
+define prep-target
+$(MKDIR) -p $(@D)
+$(RM) $@
+endef
+
+# Prep for javadoc creation, assumes $@ is an index.html file
+define prep-javadoc
+@if [ -f "$@" -a "$?" != "" ] ; then \
+  $(ECHO) "# Dependencies have changed: $?"; \
+fi
+$(RM) -r $(@D)
+$(MKDIR) -p $(@D)
+endef
+
+# A cache of the directories in ALL_SOURCE_DIRS
+DIRECTORY_CACHE = $(DOCSTMPDIR)/directory.cache
+
+# Given a list of packages, return a list of files or dirs to be dependent on
+#   (Currently only returning a list of directories)
+define PackageDependencies # packages
+$(shell							\
+  if [ "$1" != "" -a -f $(DIRECTORY_CACHE) ] ; then	\
+    for p in $1 ; do 					\
+      pd=`$(ECHO) $${p} | $(SED) -e 's@[.]@/@g'`;	\
+      $(CAT) $(DIRECTORY_CACHE) | $(GREP) "/$${pd}/" ; 	\
+    done; 						\
+  fi							\
+)
+endef
+
+# Given a list of packages, add packages that exist to $@, print summary
+define PackageFilter # packages
+@if [ "$1" != "" ] ; then 				\
+  for p in $1 ; do 					\
+    pd=`$(ECHO) $${p} | $(SED) -e 's@[.]@/@g'`; 	\
+    found="false"; 					\
+    for cp in $(ALL_SOURCE_DIRS) ; do 			\
+      if [ -d $${cp}/$${pd} ] ; then 			\
+        $(ECHO) "$${p}" >> $@; 				\
+	found="true";					\
+	break; 						\
+      fi; 						\
+    done; 						\
+    if [ "$${found}" = "false" ] ; then 		\
+      $(ECHO) "WARNING: Package not found: $${p}"; 	\
+    fi; 						\
+  done; 						\
+fi
+endef
+
+# Print out a summary of the javadoc command about to be run
+define JavadocSummary # optionsfile packagesfile
+@$(ECHO) "# Summary for $@";\
+ $(ECHO) "# Options (`$(BASENAME) $1`):"; $(SED) -e 's@^@#   @' $1; \
+ $(ECHO) "# Packages (`$(BASENAME) $2`):";$(SED) -e 's@^@#   @' $2
+endef
+
+#
+# Temporary directory for javadoc creation
+#
+DOCSTMPDIR = $(TEMPDIR)/doctmp
+
+#
+# Different api directories created from root directory
+#
+COREAPI_DOCSDIR   = $(DOCSDIR)/api
+JDK_API_DOCSDIR   = $(DOCSDIR)/jdk/api
+JRE_API_DOCSDIR   = $(DOCSDIR)/jre/api
+PLATFORM_DOCSDIR  = $(DOCSDIR)/platform
+
+# The non-core api javadocs need to be able to access the root of the core
+#   api directory, so for jdk/api or jre/api to get to the core api/
+#   directory we would use this:
+JDKJRE2COREAPI    = ../../api
+
+# Common bottom argument
+define CommonBottom # year
+<font size="-1"><br> $(call CopyrightLine,,$1,)</font>
+endef
+
+# Common trademark bottom argument (Not sure why this is used sometimes)
+define CommonTrademarkBottom # year
+<font size="-1">\
+$(BUG_SUBMIT_LINE)<br>$(JAVA_TRADEMARK_LINE)<br>\
+$(call CopyrightLine,,$1,$(COMPANY_ADDRESS))\
+</font>
+endef
+
+# Common echo of option
+define OptionOnly # opt
+$(PRINTF) "%s\n" "$1"
+endef
+define OptionPair # opt arg
+$(PRINTF) "%s '%s'\n" "$1" '$2'
+endef
+define OptionTrip # opt arg arg
+$(PRINTF) "%s '%s' '%s'\n" "$1" '$2' '$3'
+endef
+
+# Core api bottom argument (with special sauce)
+COREAPI_BOTTOM = <font size="-1"> $(BUG_SUBMIT_LINE)\
+<br>For further API reference and developer documentation, \
+see <a href="$(DEV_DOCS_URL)" target="_blank">Java SE Documentation</a>. \
+That documentation contains more detailed, developer-targeted descriptions, \
+with conceptual overviews, definitions of terms, workarounds, \
+and working code examples.<br>\
+$(call CopyrightLine,$(COPYRIGHT_URL),$(FIRST_COPYRIGHT_YEAR),)\
+</font>
+
+# Common javadoc options used by all
+COMMON_JAVADOCFLAGS =					\
+                -XDignore.symbol.file=true              \
+		-quiet					\
+                -use					\
+                -keywords				\
+		$(ADDITIONAL_JAVADOCFLAGS)
+
+ifdef OPENJDK
+  ADDITIONAL_JAVADOCFLAGS =				\
+                -Xdocrootparent $(DOCS_BASE_URL)
+else
+  ADDITIONAL_JAVADOCFLAGS =
+endif
+
+# Draft used for non-fcs documents
+DRAFT_HEADER =
+ifneq ($(MILESTONE), fcs)
+    DRAFT_HEADER = <br><strong>DRAFT&nbsp;$(MILESTONE)-$(BUILD_NUMBER)</strong>
+    DRAFT_BOTTOM = <br><strong>DRAFT&nbsp;$(MILESTONE)-$(BUILD_NUMBER)</strong>
+    DRAFT_WINTITLE = $(BUILD_NUMBER)
+    # Early access top text (not used in FCS releases)
+    COREAPI_TOP_EARLYACCESS = \
+<div style="background-color: \#EEEEEE"> \
+<div style="padding: 6px; margin-top: 2px; margin-bottom: 6px; \
+margin-left: 6px; margin-right: 6px; text-align: justify; \
+font-size: 80%; font-family: Helvetica, Arial, sans-serif; \
+font-weight: normal;"> \
+Please note that the specifications and other information \
+contained herein are not final and are subject to change. \
+The information is being made available to you solely for purpose of \
+evaluation. \
+</div> </div>
+endif
+
+#################################################################
+
+#
+# CORE_PKGS environment variable has been moved to the following file
+#
+include CORE_PKGS.gmk
+
+#
+# Load environment variables for API package names that are not part of
+# the Java SE platform
+#
+include NON_CORE_PKGS.gmk
+
+#################################################################
+
+#
+# Default target is same as docs target, create core api and all others it can
+#
+
+all: docs
+docs: coredocs otherdocs
+
+#################################################################
+# Production Targets -- USE THESE TARGETS WHEN:
+#    a) You're generating docs outside of release engineering's
+#       standard control build.
+#    b) The docs will be pushed to the web and/or included in
+#       the downloaded doc bundle.
+#
+# See:  Notes.html#releaseTargets
+# Note: Spaces precede ifdef/ifndef indents. Tabs precede target commands (!)
+#
+
+sanitycheckcoredocs:
+	@$(ECHO) ""
+	@$(ECHO) "Building core api docs with these values:"
+	@$(ECHO) "    BUILD_NUMBER = $(BUILD_NUMBER)"
+	@$(ECHO) "    MILESTONE = $(MILESTONE)"
+	@$(ECHO) ""
+  ifeq ($(BUILD_NUMBER), b00)
+	@$(ECHO) "ERROR: Build number must be defined"
+	@$(ECHO) "MILESTONE is set to $(MILESTONE)"
+	@$(ECHO) ""
+	exit 1
+  endif
+
+#############################################################
+#
+# coredocs
+#
+COREAPI_DOCTITLE  = Java$(TRADEMARK) Platform, Standard Edition \
+$(JDK_MINOR_VERSION)<br>API Specification
+COREAPI_WINDOWTITLE  = Java Platform SE $(JDK_MINOR_VERSION)
+COREAPI_HEADER = \
+<strong>Java$(TRADEMARK)&nbsp;Platform<br>Standard&nbsp;Ed.&nbsp;$(JDK_MINOR_VERSION)</strong>
+
+# Java language specification cite
+TAG_JLS = jls:a:See <cite> \
+The Java&trade; Language Specification</cite>:
+
+# Overview file for core apis
+COREAPI_OVERVIEW = $(JDK_SHARE_CLASSES)/overview-core.html
+
+# The index.html, options, and packages files
+COREAPI_INDEX_FILE    = $(COREAPI_DOCSDIR)/index.html
+COREAPI_OPTIONS_FILE  = $(DOCSTMPDIR)/coredocs.options
+COREAPI_PACKAGES_FILE = $(DOCSTMPDIR)/coredocs.packages
+
+coredocs: $(COREAPI_INDEX_FILE)
+
+# Set relative location to core api document root
+$(COREAPI_INDEX_FILE): GET2DOCSDIR=..
+
+# Run javadoc if the index file is out of date or missing
+$(COREAPI_INDEX_FILE): $(COREAPI_OPTIONS_FILE) $(COREAPI_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(COREAPI_OPTIONS_FILE),$(COREAPI_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(COREAPI_OPTIONS_FILE) @$(COREAPI_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(COREAPI_OPTIONS_FILE): $(COREAPI_OVERVIEW)
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ISO-8859-1)			; \
+	  $(call OptionPair,-tag,beaninfo:X)				; \
+	  $(call OptionPair,-tag,revised:X)				; \
+	  $(call OptionPair,-tag,since.unbundled:X)			; \
+	  $(call OptionPair,-tag,spec:X)				; \
+	  $(call OptionPair,-tag,specdefault:X)				; \
+	  $(call OptionPair,-tag,Note:X)				; \
+	  $(call OptionPair,-tag,ToDo:X)				; \
+          $(call OptionPair,-tag,$(TAG_JLS)) 				; \
+	  $(call OptionOnly,-splitIndex)				; \
+	  $(call OptionPair,-overview,$(COREAPI_OVERVIEW))		; \
+	  $(call OptionPair,-doctitle,$(COREAPI_DOCTITLE))		; \
+	  $(call OptionPair,-windowtitle,$(COREAPI_WINDOWTITLE) $(DRAFT_WINTITLE)) ;\
+	  $(call OptionPair,-header,$(COREAPI_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(COREAPI_BOTTOM)$(DRAFT_BOTTOM))	; \
+        ) >> $@
+ifdef COREAPI_TOP_EARLYACCESS
+	@$(call OptionPair,-top,$(COREAPI_TOP_EARLYACCESS)) >> $@
+endif
+
+# Create a file with the package names in it
+$(COREAPI_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(CORE_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(CORE_PKGS))
+
+#############################################################
+#
+# docletapidocs
+#
+
+ALL_OTHER_TARGETS += docletapidocs
+
+DOCLETAPI_DOCDIR       := $(JDK_API_DOCSDIR)/javadoc/doclet
+DOCLETAPI2COREAPI      := ../../$(JDKJRE2COREAPI)
+DOCLETAPI_DOCTITLE     := Doclet API
+DOCLETAPI_WINDOWTITLE  := Doclet API
+DOCLETAPI_HEADER       := <strong>Doclet API</strong>
+DOCLETAPI_BOTTOM       := $(call CommonTrademarkBottom,$(DOCLETAPI_FIRST_COPYRIGHT_YEAR))
+DOCLETAPI_GROUPNAME    := Packages
+DOCLETAPI_REGEXP       := com.sun.javadoc
+# DOCLETAPI_PKGS is located in NON_CORE_PKGS.gmk
+
+# The index.html, options, and packages files
+DOCLETAPI_INDEX_FILE    = $(DOCLETAPI_DOCDIR)/index.html
+DOCLETAPI_OPTIONS_FILE  = $(DOCSTMPDIR)/docletapi.options
+DOCLETAPI_PACKAGES_FILE = $(DOCSTMPDIR)/docletapi.packages
+
+docletapidocs: $(DOCLETAPI_INDEX_FILE)
+
+# Set relative location to core api document root
+$(DOCLETAPI_INDEX_FILE): GET2DOCSDIR=$(DOCLETAPI2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(DOCLETAPI_INDEX_FILE): $(DOCLETAPI_OPTIONS_FILE) $(DOCLETAPI_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(DOCLETAPI_OPTIONS_FILE),$(DOCLETAPI_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(DOCLETAPI_OPTIONS_FILE) @$(DOCLETAPI_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(DOCLETAPI_OPTIONS_FILE):
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-breakiterator)				; \
+	  $(call OptionPair,-doctitle,$(DOCLETAPI_DOCTITLE))		; \
+	  $(call OptionPair,-windowtitle,$(DOCLETAPI_WINDOWTITLE) $(DRAFT_WINTITLE));\
+	  $(call OptionPair,-header,$(DOCLETAPI_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(DOCLETAPI_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-group,$(DOCLETAPI_GROUPNAME),$(DOCLETAPI_REGEXP)); \
+	  $(call OptionTrip,-linkoffline,$(DOCLETAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(DOCLETAPI_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(DOCLETAPI_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(DOCLETAPI_PKGS))
+
+#############################################################
+#
+# tagletapidocs
+#
+
+ALL_OTHER_TARGETS += tagletapidocs
+TAGLETAPI_DOCDIR   := $(JDK_API_DOCSDIR)/javadoc/taglet
+TAGLETAPI2COREAPI  := ../../$(JDKJRE2COREAPI)
+TAGLETAPI_BOTTOM   := $(call CommonTrademarkBottom,$(TAGLETAPI_FIRST_COPYRIGHT_YEAR))
+# TAGLETAPI_FILE is located in NON_CORE_PKGS.gmk
+
+# Temporary directory (special generation rules)
+TAGLETAPI_TEMPDIR       = $(DOCSTMPDIR)/taglets_temp
+
+# The index.html, options, and packages files
+TAGLETAPI_INDEX_FILE    = $(TAGLETAPI_DOCDIR)/com/sun/tools/doclets/Taglet.html
+TAGLETAPI_OPTIONS_FILE  = $(DOCSTMPDIR)/tagletapi.options
+TAGLETAPI_PACKAGES_FILE = $(DOCSTMPDIR)/tagletapi.packages
+
+tagletapidocs: $(TAGLETAPI_INDEX_FILE)
+
+# Set relative location to core api document root
+$(TAGLETAPI_INDEX_FILE): GET2DOCSDIR=$(TAGLETAPI2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(TAGLETAPI_INDEX_FILE): $(TAGLETAPI_OPTIONS_FILE) $(TAGLETAPI_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(RM) -r $(TAGLETAPI_TEMPDIR)
+	$(MKDIR) -p $(TAGLETAPI_TEMPDIR)
+	$(call JavadocSummary,$(TAGLETAPI_OPTIONS_FILE),$(TAGLETAPI_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(TAGLETAPI_TEMPDIR) \
+	  @$(TAGLETAPI_OPTIONS_FILE) @$(TAGLETAPI_PACKAGES_FILE)
+	cp -r $(TAGLETAPI_TEMPDIR)/com $(@D)
+	cp $(TAGLETAPI_TEMPDIR)/stylesheet.css $(@D)
+	$(RM) -r $(TAGLETAPI_TEMPDIR)
+
+# Create file with javadoc options in it
+$(TAGLETAPI_OPTIONS_FILE):
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-nonavbar)					; \
+          $(call OptionOnly,-noindex)                                   ; \
+	  $(call OptionPair,-bottom,$(TAGLETAPI_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-linkoffline,$(TAGLETAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(TAGLETAPI_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(TAGLETAPI_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(TAGLETAPI_PKGS))
+	$(GREP) "$(TAGLETAPI_FILE)" $@ > $@.tmp
+	$(MV) $@.tmp $@
+
+#############################################################
+#
+# domapidocs
+#
+
+ALL_OTHER_TARGETS += domapidocs
+
+DOMAPI_DOCDIR       := $(JRE_API_DOCSDIR)/plugin/dom
+DOMAPI2COREAPI      := ../../$(JDKJRE2COREAPI)
+DOMAPI_DOCTITLE     := Common DOM API
+DOMAPI_WINDOWTITLE  := Common DOM API
+DOMAPI_HEADER       := <strong>Common DOM API</strong>
+DOMAPI_BOTTOM       := $(call CommonTrademarkBottom,$(DOMAPI_FIRST_COPYRIGHT_YEAR))
+DOMAPI_GROUPNAME    := Packages
+DOMAPI_REGEXP       := com.sun.java.browser.dom:org.w3c.dom*
+# DOMAPI_PKGS is located in NON_CORE_PKGS.gmk
+
+# The index.html, options, and packages files
+DOMAPI_INDEX_FILE    = $(DOMAPI_DOCDIR)/index.html
+DOMAPI_OPTIONS_FILE  = $(DOCSTMPDIR)/domapi.options
+DOMAPI_PACKAGES_FILE = $(DOCSTMPDIR)/domapi.packages
+
+domapidocs: $(DOMAPI_INDEX_FILE)
+
+# Set relative location to core api document root
+$(DOMAPI_INDEX_FILE): GET2DOCSDIR=$(DOMAPI2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(DOMAPI_INDEX_FILE): $(DOMAPI_OPTIONS_FILE) $(DOMAPI_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(DOMAPI_OPTIONS_FILE),$(DOMAPI_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(DOMAPI_OPTIONS_FILE) @$(DOMAPI_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(DOMAPI_OPTIONS_FILE):
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-splitIndex)				; \
+	  $(call OptionPair,-doctitle,$(DOMAPI_DOCTITLE))		; \
+	  $(call OptionPair,-windowtitle,$(DOMAPI_WINDOWTITLE) $(DRAFT_WINTITLE));\
+	  $(call OptionPair,-header,$(DOMAPI_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(DOMAPI_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-group,$(DOMAPI_GROUPNAME),$(DOMAPI_REGEXP)); \
+	  $(call OptionTrip,-linkoffline,$(DOMAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(DOMAPI_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(DOMAPI_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(DOMAPI_PKGS))
+
+#############################################################
+#
+# jpdadocs
+#
+
+ALL_OTHER_TARGETS += jpdadocs
+
+jpdadocs: jdidocs jdwpdocs jvmtidocs
+
+#############################################################
+#
+# jdidocs
+#
+
+ALL_OTHER_TARGETS += jdidocs
+
+JDI_DOCDIR      := $(JDK_API_DOCSDIR)/jpda/jdi
+JDI2COREAPI     := ../../$(JDKJRE2COREAPI)
+JDI_DOCTITLE    := Java$(TRADEMARK) Debug Interface
+JDI_WINDOWTITLE := Java Debug Interface
+JDI_HEADER      := <strong>Java Debug Interface</strong>
+JDI_BOTTOM      := $(call CommonBottom,$(JDI_FIRST_COPYRIGHT_YEAR))
+JDI_OVERVIEW    := $(JDK_SHARE_CLASSES)/jdi-overview.html
+# JDI_PKGS is located in NON_CORE_PKGS.gmk
+
+# The index.html, options, and packages files
+JDI_INDEX_FILE    = $(JDI_DOCDIR)/index.html
+JDI_OPTIONS_FILE  = $(DOCSTMPDIR)/jdi.options
+JDI_PACKAGES_FILE = $(DOCSTMPDIR)/jdi.packages
+
+jdidocs: $(JDI_INDEX_FILE)
+
+# Set relative location to core api document root
+$(JDI_INDEX_FILE): GET2DOCSDIR=$(JDI2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(JDI_INDEX_FILE): $(JDI_OPTIONS_FILE) $(JDI_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(JDI_OPTIONS_FILE),$(JDI_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(JDI_OPTIONS_FILE) @$(JDI_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(JDI_OPTIONS_FILE): $(JDI_OVERVIEW)
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionPair,-overview,$(JDI_OVERVIEW))			; \
+	  $(call OptionPair,-doctitle,$(JDI_DOCTITLE))			; \
+	  $(call OptionPair,-windowtitle,$(JDI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
+	  $(call OptionPair,-header,$(JDI_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(JDI_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-linkoffline,$(JDI2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(JDI_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(JDI_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(JDI_PKGS))
+
+#############################################################
+#
+# jdwpdocs
+#
+
+ALL_OTHER_TARGETS += jdwpdocs
+
+JDWP_DOCDIR     = $(PLATFORM_DOCSDIR)/jpda/jdwp
+
+jdwpdocs: $(JDWP_DOCDIR)/jdwp-protocol.html
+$(JDWP_DOCDIR)/jdwp-protocol.html : $(JDK_OUTPUTDIR)/gensrc_jdwp_doc/jdwp-protocol.html
+	$(MKDIR) -p $(@D)
+	$(RM) $@
+	$(CP) $< $@
+
+#############################################################
+#
+# jvmtidocs
+#
+
+ALL_OTHER_TARGETS += jvmtidocs
+
+JVMTI_DOCDIR      = $(PLATFORM_DOCSDIR)/jvmti
+JVMTI_HTML        = $(HOTSPOT_DIST)/docs/platform/jvmti/jvmti.html
+
+jvmtidocs:  $(JVMTI_DOCDIR)/jvmti.html
+$(JVMTI_DOCDIR)/jvmti.html:
+	@$(prep-javadoc)
+	@if [ -f $(JVMTI_HTML) ] ; then		                           \
+	  $(ECHO) "$(CP) $(JVMTI_HTML) $@";                 	           \
+	  $(CP) $(JVMTI_HTML) $@; 	                 	           \
+	else 						                   \
+	  $(ECHO) "WARNING: Generated file does not exist: $(JVMTI_HTML)"; \
+	fi
+
+#############################################################
+#
+# jaasdocs
+#
+
+ALL_OTHER_TARGETS += jaasdocs
+
+JAAS_DOCDIR	 := $(JRE_API_DOCSDIR)/security/jaas/spec
+JAAS2COREAPI     := ../../../$(JDKJRE2COREAPI)
+JAAS_DOCTITLE    := Java$(TRADEMARK) Authentication and Authorization Service
+JAAS_WINDOWTITLE := Java Authentication and Authorization Service
+JAAS_HEADER      := <strong>Java Authentication and Authorization Service</strong>
+JAAS_BOTTOM      := $(call CommonBottom,$(JAAS_FIRST_COPYRIGHT_YEAR))
+# JAAS_PKGS is located in NON_CORE_PKGS.gmk
+JAAS_OVERVIEW    := $(JDK_SHARE_CLASSES)/com/sun/security/auth/jaas-overview.html
+
+# The index.html, options, and packages files
+JAAS_INDEX_FILE    = $(JAAS_DOCDIR)/index.html
+JAAS_OPTIONS_FILE  = $(DOCSTMPDIR)/jaas.options
+JAAS_PACKAGES_FILE = $(DOCSTMPDIR)/jaas.packages
+
+jaasdocs: $(JAAS_INDEX_FILE)
+
+# Set relative location to core api document root
+$(JAAS_INDEX_FILE): GET2DOCSDIR=$(JAAS2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(JAAS_INDEX_FILE): $(JAAS_OPTIONS_FILE) $(JAAS_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(JAAS_OPTIONS_FILE),$(JAAS_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(JAAS_OPTIONS_FILE) @$(JAAS_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(JAAS_OPTIONS_FILE): $(JAAS_OVERVIEW)
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionPair,-overview,$(JAAS_OVERVIEW))			; \
+	  $(call OptionPair,-doctitle,$(JAAS_DOCTITLE))			; \
+	  $(call OptionPair,-windowtitle,$(JAAS_WINDOWTITLE) $(DRAFT_WINTITLE)); \
+	  $(call OptionPair,-header,$(JAAS_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(JAAS_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-linkoffline,$(JAAS2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(JAAS_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(JAAS_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(JAAS_PKGS))
+
+#############################################################
+#
+# jgssdocs
+#
+
+ALL_OTHER_TARGETS += jgssdocs
+
+JGSS_DOCDIR	 := $(JRE_API_DOCSDIR)/security/jgss/spec
+JGSS2COREAPI     := ../../../$(JDKJRE2COREAPI)
+JGSS_DOCTITLE    := Java$(TRADEMARK) GSS-API Utilities
+JGSS_WINDOWTITLE := Java GSS-API Utilities
+JGSS_HEADER      := <strong>Java GSS-API Utilities</strong>
+JGSS_BOTTOM      := $(call CommonBottom,$(JGSS_FIRST_COPYRIGHT_YEAR))
+JGSS_OVERVIEW    := $(JDK_SHARE_CLASSES)/com/sun/security/jgss/jgss-overview.html
+# JGSS_PKGS is located in NON_CORE_PKGS.gmk
+
+# The index.html, options, and packages files
+JGSS_INDEX_FILE    = $(JGSS_DOCDIR)/index.html
+JGSS_OPTIONS_FILE  = $(DOCSTMPDIR)/jgss.options
+JGSS_PACKAGES_FILE = $(DOCSTMPDIR)/jgss.packages
+
+jgssdocs: $(JGSS_INDEX_FILE)
+
+# Set relative location to core api document root
+$(JGSS_INDEX_FILE): GET2DOCSDIR=$(JGSS2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(JGSS_INDEX_FILE): $(JGSS_OPTIONS_FILE) $(JGSS_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(JGSS_OPTIONS_FILE),$(JGSS_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(JGSS_OPTIONS_FILE) @$(JGSS_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(JGSS_OPTIONS_FILE): $(JGSS_OVERVIEW)
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-nodeprecatedlist)				; \
+	  $(call OptionPair,-overview,$(JGSS_OVERVIEW))			; \
+	  $(call OptionPair,-doctitle,$(JGSS_DOCTITLE))			; \
+	  $(call OptionPair,-windowtitle,$(JGSS_WINDOWTITLE) $(DRAFT_WINTITLE)); \
+	  $(call OptionPair,-header,$(JGSS_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(JGSS_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-linkoffline,$(JGSS2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(JGSS_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(JGSS_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(JGSS_PKGS))
+
+#############################################################
+#
+# smartcardiodocs
+#
+
+ALL_OTHER_TARGETS += smartcardiodocs
+
+SMARTCARDIO_DOCDIR	:= $(JRE_API_DOCSDIR)/security/smartcardio/spec
+SMARTCARDIO2COREAPI     := ../../../$(JDKJRE2COREAPI)
+SMARTCARDIO_DOCTITLE    := Java$(TRADEMARK) Smart Card I/O
+SMARTCARDIO_WINDOWTITLE := Java Smart Card I/O
+SMARTCARDIO_HEADER      := <strong>Java Smart Card I/O</strong>
+SMARTCARDIO_BOTTOM      := $(call CommonBottom,$(SMARTCARDIO_FIRST_COPYRIGHT_YEAR))
+# SMARTCARDIO_PKGS is located in NON_CORE_PKGS.gmk
+
+# The index.html, options, and packages files
+SMARTCARDIO_INDEX_FILE    = $(SMARTCARDIO_DOCDIR)/index.html
+SMARTCARDIO_OPTIONS_FILE  = $(DOCSTMPDIR)/smartcardio.options
+SMARTCARDIO_PACKAGES_FILE = $(DOCSTMPDIR)/smartcardio.packages
+
+smartcardiodocs: $(SMARTCARDIO_INDEX_FILE)
+
+# Set relative location to core api document root
+$(SMARTCARDIO_INDEX_FILE): GET2DOCSDIR=$(SMARTCARDIO2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(SMARTCARDIO_INDEX_FILE): $(SMARTCARDIO_OPTIONS_FILE) $(SMARTCARDIO_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(SMARTCARDIO_OPTIONS_FILE),$(SMARTCARDIO_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(SMARTCARDIO_OPTIONS_FILE) @$(SMARTCARDIO_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(SMARTCARDIO_OPTIONS_FILE):
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-nodeprecatedlist)				; \
+	  $(call OptionPair,-doctitle,$(SMARTCARDIO_DOCTITLE))		; \
+	  $(call OptionPair,-windowtitle,$(SMARTCARDIO_WINDOWTITLE) $(DRAFT_WINTITLE));\
+	  $(call OptionPair,-header,$(SMARTCARDIO_HEADER)$(DRAFT_HEADER)); \
+	  $(call OptionPair,-bottom,$(SMARTCARDIO_BOTTOM)$(DRAFT_BOTTOM)); \
+	  $(call OptionTrip,-linkoffline,$(SMARTCARDIO2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(SMARTCARDIO_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(SMARTCARDIO_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(SMARTCARDIO_PKGS))
+
+#############################################################
+#
+# httpserverdocs
+#
+
+ALL_OTHER_TARGETS += httpserverdocs
+
+HTTPSERVER_DOCDIR      := $(JRE_API_DOCSDIR)/net/httpserver/spec
+HTTPSERVER2COREAPI     := ../../../$(JDKJRE2COREAPI)
+HTTPSERVER_DOCTITLE    := Java$(TRADEMARK) HTTP Server
+HTTPSERVER_WINDOWTITLE := Java HTTP Server
+HTTPSERVER_HEADER      := <strong>Java HTTP Server</strong>
+HTTPSERVER_BOTTOM      := $(call CommonBottom,$(HTTPSERVER_FIRST_COPYRIGHT_YEAR))
+# HTTPSERVER_PKGS is located in NON_CORE_PKGS.gmk
+
+HTTPSERVER_INDEX_HTML    = $(HTTPSERVER_DOCDIR)/index.html
+HTTPSERVER_OPTIONS_FILE  = $(DOCSTMPDIR)/httpserver.options
+HTTPSERVER_PACKAGES_FILE = $(DOCSTMPDIR)/httpserver.packages
+
+httpserverdocs: $(HTTPSERVER_INDEX_HTML)
+
+# Set relative location to core api document root
+$(HTTPSERVER_INDEX_HTML): GET2DOCSDIR=$(HTTPSERVER2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(HTTPSERVER_INDEX_HTML): $(HTTPSERVER_OPTIONS_FILE) $(HTTPSERVER_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(HTTPSERVER_OPTIONS_FILE),$(HTTPSERVER_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(HTTPSERVER_OPTIONS_FILE) @$(HTTPSERVER_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(HTTPSERVER_OPTIONS_FILE):
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-nodeprecatedlist)				; \
+	  $(call OptionPair,-doctitle,$(HTTPSERVER_DOCTITLE))		; \
+	  $(call OptionPair,-windowtitle,$(HTTPSERVER_WINDOWTITLE) $(DRAFT_WINTITLE));\
+	  $(call OptionPair,-header,$(HTTPSERVER_HEADER)$(DRAFT_HEADER)); \
+	  $(call OptionPair,-bottom,$(HTTPSERVER_BOTTOM)$(DRAFT_BOTTOM)); \
+	  $(call OptionTrip,-linkoffline,$(HTTPSERVER2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(HTTPSERVER_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(HTTPSERVER_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(HTTPSERVER_PKGS))
+
+#############################################################
+#
+# mgmtdocs
+#
+
+ALL_OTHER_TARGETS += mgmtdocs
+
+MGMT_DOCDIR	 := $(JRE_API_DOCSDIR)/management/extension
+MGMT2COREAPI     := ../../$(JDKJRE2COREAPI)
+JVM_MIB_NAME     := JVM-MANAGEMENT-MIB.mib
+JVM_MIB_SRC      := $(CLOSED_SRC)/share/classes/sun/management/snmp/$(JVM_MIB_NAME)
+MGMT_DOCTITLE    := Monitoring and Management Interface for the Java$(TRADEMARK) Platform
+MGMT_WINDOWTITLE := Monitoring and Management Interface for the Java Platform
+MGMT_HEADER      := <strong>Monitoring and Management Interface for the Java Platform</strong>
+MGMT_BOTTOM      := $(call CommonBottom,$(MGMT_FIRST_COPYRIGHT_YEAR))
+MGMT_OVERVIEW    := $(JDK_SHARE_CLASSES)/com/sun/management/mgmt-overview.html
+# MGMT_PKGS is located in NON_CORE_PKGS.gmk
+
+# The index.html, options, and packages files
+MGMT_INDEX_FILE    = $(MGMT_DOCDIR)/index.html
+MGMT_OPTIONS_FILE  = $(DOCSTMPDIR)/mgmt.options
+MGMT_PACKAGES_FILE = $(DOCSTMPDIR)/mgmt.packages
+
+mgmtdocs: $(MGMT_INDEX_FILE)
+
+# Set relative location to core api document root
+$(MGMT_INDEX_FILE): GET2DOCSDIR=$(MGMT2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(MGMT_INDEX_FILE): $(MGMT_OPTIONS_FILE) $(MGMT_PACKAGES_FILE)
+	$(prep-javadoc)
+	@if [ -f $(JVM_MIB_SRC) ] ; then 				\
+	  $(ECHO) "$(CP) $(JVM_MIB_SRC) $(@D)/.."; 			\
+	  $(CP) $(JVM_MIB_SRC) $(@D)/.. ; 				\
+	else 								\
+	  $(ECHO) "WARNING: File $(JVM_MIB_NAME) not available."; 	\
+	fi
+	$(call JavadocSummary,$(MGMT_OPTIONS_FILE),$(MGMT_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(MGMT_OPTIONS_FILE) @$(MGMT_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(MGMT_OPTIONS_FILE): $(MGMT_OVERVIEW)
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-nodeprecatedlist)				; \
+	  $(call OptionPair,-overview,$(MGMT_OVERVIEW))			; \
+	  $(call OptionPair,-doctitle,$(MGMT_DOCTITLE))			; \
+	  $(call OptionPair,-windowtitle,$(MGMT_WINDOWTITLE) $(DRAFT_WINTITLE)); \
+	  $(call OptionPair,-header,$(MGMT_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(MGMT_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-linkoffline,$(MGMT2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(MGMT_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(MGMT_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(MGMT_PKGS))
+
+#############################################################
+#
+# attachdocs
+#
+
+ALL_OTHER_TARGETS += attachdocs
+
+ATTACH_DOCDIR      := $(JDK_API_DOCSDIR)/attach/spec
+ATTACH2COREAPI     := ../../$(JDKJRE2COREAPI)
+ATTACH_DOCTITLE    := Attach API
+ATTACH_WINDOWTITLE := Attach API
+ATTACH_HEADER      := <strong>Attach API</strong>
+ATTACH_BOTTOM      := $(call CommonBottom,$(ATTACH_FIRST_COPYRIGHT_YEAR))
+# ATTACH_PKGS is located in NON_CORE_PKGS.gmk
+
+ATTACH_INDEX_HTML    = $(ATTACH_DOCDIR)/index.html
+ATTACH_OPTIONS_FILE  = $(DOCSTMPDIR)/attach.options
+ATTACH_PACKAGES_FILE = $(DOCSTMPDIR)/attach.packages
+
+attachdocs: $(ATTACH_INDEX_HTML)
+
+# Set relative location to core api document root
+$(ATTACH_INDEX_HTML): GET2DOCSDIR=$(ATTACH2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(ATTACH_INDEX_HTML): $(ATTACH_OPTIONS_FILE) $(ATTACH_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(ATTACH_OPTIONS_FILE),$(ATTACH_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(ATTACH_OPTIONS_FILE) @$(ATTACH_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(ATTACH_OPTIONS_FILE):
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-nodeprecatedlist)				; \
+	  $(call OptionPair,-doctitle,$(ATTACH_DOCTITLE))		; \
+	  $(call OptionPair,-windowtitle,$(ATTACH_WINDOWTITLE) $(DRAFT_WINTITLE));\
+	  $(call OptionPair,-header,$(ATTACH_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(ATTACH_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-linkoffline,$(ATTACH2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(ATTACH_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(ATTACH_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(ATTACH_PKGS))
+
+#############################################################
+#
+# jconsoledocs
+#
+
+ALL_OTHER_TARGETS += jconsoledocs
+
+JCONSOLE_DOCDIR      := $(JDK_API_DOCSDIR)/jconsole/spec
+JCONSOLE2COREAPI     := ../../$(JDKJRE2COREAPI)
+JCONSOLE_DOCTITLE    := JConsole API
+JCONSOLE_WINDOWTITLE := JConsole API
+JCONSOLE_HEADER      := <strong>JConsole API</strong>
+JCONSOLE_BOTTOM      := $(call CommonBottom,$(JCONSOLE_FIRST_COPYRIGHT_YEAR))
+# JCONSOLE_PKGS is located in NON_CORE_PKGS.gmk
+
+JCONSOLE_INDEX_HTML    = $(JCONSOLE_DOCDIR)/index.html
+JCONSOLE_OPTIONS_FILE  = $(DOCSTMPDIR)/jconsole.options
+JCONSOLE_PACKAGES_FILE = $(DOCSTMPDIR)/jconsole.packages
+
+jconsoledocs: $(JCONSOLE_INDEX_HTML)
+
+# Set relative location to core api document root
+$(JCONSOLE_INDEX_HTML): GET2DOCSDIR=$(JCONSOLE2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(JCONSOLE_INDEX_HTML): $(JCONSOLE_OPTIONS_FILE) $(JCONSOLE_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(JCONSOLE_OPTIONS_FILE),$(JCONSOLE_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(JCONSOLE_OPTIONS_FILE) @$(JCONSOLE_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(JCONSOLE_OPTIONS_FILE):
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-nodeprecatedlist)				; \
+	  $(call OptionPair,-doctitle,$(JCONSOLE_DOCTITLE))		; \
+	  $(call OptionPair,-windowtitle,$(JCONSOLE_WINDOWTITLE) $(DRAFT_WINTITLE));\
+	  $(call OptionPair,-header,$(JCONSOLE_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(JCONSOLE_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-linkoffline,$(JCONSOLE2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(JCONSOLE_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(JCONSOLE_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(JCONSOLE_PKGS))
+
+#############################################################
+#
+# treeapidocs
+#
+
+ALL_OTHER_TARGETS += treeapidocs
+
+TREEAPI_DOCDIR       := $(JDK_API_DOCSDIR)/javac/tree
+TREEAPI2COREAPI      := ../../$(JDKJRE2COREAPI)
+TREEAPI_DOCTITLE     := Compiler Tree API
+TREEAPI_WINDOWTITLE  := Compiler Tree API
+TREEAPI_HEADER       := <strong>Compiler Tree API</strong>
+TREEAPI_BOTTOM       := $(call CommonBottom,$(TREEAPI_FIRST_COPYRIGHT_YEAR))
+TREEAPI_GROUPNAME    := Packages
+TREEAPI_REGEXP       := com.sun.source.*
+# TREEAPI_PKGS is located in NON_CORE_PKGS.gmk
+
+TREEAPI_INDEX_HTML    = $(TREEAPI_DOCDIR)/index.html
+TREEAPI_OPTIONS_FILE  = $(DOCSTMPDIR)/treeapi.options
+TREEAPI_PACKAGES_FILE = $(DOCSTMPDIR)/treeapi.packages
+
+treeapidocs: $(TREEAPI_INDEX_HTML)
+
+# Set relative location to core api document root
+$(TREEAPI_INDEX_HTML): GET2DOCSDIR=$(TREEAPI2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(TREEAPI_INDEX_HTML): $(TREEAPI_OPTIONS_FILE) $(TREEAPI_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(TREEAPI_OPTIONS_FILE),$(TREEAPI_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(TREEAPI_OPTIONS_FILE) @$(TREEAPI_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(TREEAPI_OPTIONS_FILE):
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionPair,-doctitle,$(TREEAPI_DOCTITLE))		; \
+	  $(call OptionPair,-windowtitle,$(TREEAPI_WINDOWTITLE) $(DRAFT_WINTITLE));\
+	  $(call OptionPair,-header,$(TREEAPI_HEADER)$(DRAFT_HEADER))	; \
+          $(call OptionPair,-tag,$(TAG_JLS)) 				; \
+	  $(call OptionPair,-bottom,$(TREEAPI_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-group,$(TREEAPI_GROUPNAME),$(TREEAPI_REGEXP)); \
+	  $(call OptionTrip,-linkoffline,$(TREEAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(TREEAPI_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(TREEAPI_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(TREEAPI_PKGS))
+
+#############################################################
+#
+# sctpdocs
+#
+
+ALL_OTHER_TARGETS += sctpdocs
+
+SCTPAPI_DOCDIR      := $(JRE_API_DOCSDIR)/nio/sctp/spec
+SCTPAPI2COREAPI     := ../../../$(JDKJRE2COREAPI)
+SCTPAPI_DOCTITLE    := SCTP API
+SCTPAPI_WINDOWTITLE := SCTP API
+SCTPAPI_HEADER      := <strong>SCTP API</strong>
+SCTPAPI_BOTTOM      := $(call CommonBottom,$(SCTPAPI_FIRST_COPYRIGHT_YEAR))
+# SCTPAPI_PKGS is located in NON_CORE_PKGS.gmk
+
+SCTPAPI_INDEX_HTML    = $(SCTPAPI_DOCDIR)/index.html
+SCTPAPI_OPTIONS_FILE  = $(DOCSTMPDIR)/sctp.options
+SCTPAPI_PACKAGES_FILE = $(DOCSTMPDIR)/sctp.packages
+
+sctpdocs: $(SCTPAPI_INDEX_HTML)
+
+# Set relative location to core api document root
+$(SCTPAPI_INDEX_HTML): GET2DOCSDIR=$(SCTPAPI2COREAPI)/..
+
+# Run javadoc if the index file is out of date or missing
+$(SCTPAPI_INDEX_HTML): $(SCTPAPI_OPTIONS_FILE) $(SCTPAPI_PACKAGES_FILE)
+	$(prep-javadoc)
+	$(call JavadocSummary,$(SCTPAPI_OPTIONS_FILE),$(SCTPAPI_PACKAGES_FILE))
+	$(JAVADOC_CMD) -d $(@D) \
+	  @$(SCTPAPI_OPTIONS_FILE) @$(SCTPAPI_PACKAGES_FILE)
+
+# Create file with javadoc options in it
+$(SCTPAPI_OPTIONS_FILE):
+	$(prep-target)
+	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
+	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
+	  $(call OptionPair,-encoding,ascii)				; \
+	  $(call OptionOnly,-nodeprecatedlist)				; \
+	  $(call OptionPair,-doctitle,$(SCTPAPI_DOCTITLE))		; \
+	  $(call OptionPair,-windowtitle,$(SCTPAPI_WINDOWTITLE) $(DRAFT_WINTITLE));\
+	  $(call OptionPair,-header,$(SCTPAPI_HEADER)$(DRAFT_HEADER))	; \
+	  $(call OptionPair,-bottom,$(SCTPAPI_BOTTOM)$(DRAFT_BOTTOM))	; \
+	  $(call OptionTrip,-linkoffline,$(SCTPAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
+        ) >> $@
+
+# Create a file with the package names in it
+$(SCTPAPI_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(SCTPAPI_PKGS))
+	$(prep-target)
+	$(call PackageFilter,$(SCTPAPI_PKGS))
+
+#############################################################
+#
+# Get a cache of all the directories
+
+$(DIRECTORY_CACHE): $(ALL_EXISTING_SOURCE_DIRS)
+	$(prep-target)
+	@for cp in $(ALL_EXISTING_SOURCE_DIRS) ; do 	\
+	  $(ECHO) "$(FIND) $${cp} -type f >> $@"; 	\
+	  $(FIND) $${cp} -type f >> $@; 		\
+	done
+
+#############################################################
+#release version of core packages ########
+# Maximize performance and ensure that build number & milestone are set.
+
+rel-coredocs: sanitycheckcoredocs
+	$(MAKE) coredocs
+
+rel-docs: rel-coredocs $(ALL_OTHER_TARGETS)
+#
+# end of production targets
+
+otherdocs: $(ALL_OTHER_TARGETS)
+
+clean:
+	$(RM) -r $(DOCSDIR) $(DOCSTMPDIR)
+
+#############################################################
+# DEBUG TARGET
+# List the values defined in the makefile hierarchy, to make sure everything
+# is set properly, and to help identify values we can use instead of making new ones.
+# (Most of them come from common/shared/Defs.gmk)
+#
+#  Notes:
+#    * BUILD_NUMBER defaults to b00 if not set on command line with BUILD_NUMBER=<value>
+#    * MILESTONE defaults to internal unless set to beta, rc, or fcs on command line
+#
+
+#############################################################
+.PHONY: all docs coredocs rel-docs otherdocs rel-coredocs \
+        sanitycheckcoredocs $(ALL_OTHER_TARGETS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/makefiles/javadoc/NON_CORE_PKGS.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,106 @@
+#
+# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  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.
+#
+
+#
+# This file contains the package names of all the "non-core" 
+# API published in the Java 2 SDK documentation.  "Non-core" means
+# it includes all published API outside of the JDK API specification.
+#
+# These environment variables are used by javadoc in 
+# make/docs/Makefile and are referenced by the localization
+# team when determining which APIs to extract javadoc
+# comments from.
+
+DOMAPI_PKGS      = com.sun.java.browser.dom   \
+                   org.w3c.dom                \
+                   org.w3c.dom.bootstrap      \
+                   org.w3c.dom.ls             \
+                   org.w3c.dom.ranges         \
+                   org.w3c.dom.traversal      \
+                   org.w3c.dom.html           \
+                   org.w3c.dom.stylesheets    \
+                   org.w3c.dom.css            \
+                   org.w3c.dom.events         \
+                   org.w3c.dom.views
+
+JDI_PKGS         = com.sun.jdi                \
+                   com.sun.jdi.event          \
+                   com.sun.jdi.request        \
+                   com.sun.jdi.connect        \
+                   com.sun.jdi.connect.spi
+
+MGMT_PKGS        = com.sun.management
+
+JAAS_PKGS        = com.sun.security.auth          \
+                   com.sun.security.auth.callback \
+                   com.sun.security.auth.login    \
+                   com.sun.security.auth.module
+
+JGSS_PKGS        = com.sun.security.jgss
+
+OLD_JSSE_PKGS    = com.sun.net.ssl
+
+HTTPSERVER_PKGS  = com.sun.net.httpserver       \
+                   com.sun.net.httpserver.spi 
+
+NIO_PKGS         = com.sun.nio.file
+
+DOCLETAPI_PKGS   = com.sun.javadoc
+
+TAGLETAPI_FILE   = com/sun/tools/doclets/Taglet.java
+
+TAGLETAPI_PKGS   = com.sun.tools.doclets
+
+ATTACH_PKGS      = com.sun.tools.attach         \
+                   com.sun.tools.attach.spi
+
+JCONSOLE_PKGS    = com.sun.tools.jconsole
+
+TREEAPI_PKGS 	 = com.sun.source.tree \
+		   com.sun.source.util
+
+SMARTCARDIO_PKGS = javax.smartcardio
+
+SCTPAPI_PKGS     = com.sun.nio.sctp
+
+ifeq ($(PLATFORM), macosx)
+APPLE_EXT_PKGS   = com.apple.concurrent   \
+                   com.apple.eawt         \
+                   com.apple.eawt.event   \
+                   com.apple.eio
+endif
+
+# non-core packages in rt.jar
+NON_CORE_PKGS    = $(DOMAPI_PKGS) \
+                   $(MGMT_PKGS) \
+                   $(JAAS_PKGS) \
+                   $(JGSS_PKGS) \
+                   $(NIO_PKGS) \
+                   $(OLD_JSSE_PKGS) \
+                   $(HTTPSERVER_PKGS) \
+                   $(SMARTCARDIO_PKGS) \
+                   $(SCTPAPI_PKGS) \
+                   $(APPLE_EXT_PKGS)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/makefiles/javadoc/Notes.html	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Doc Process Notes</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+
+<body>
+<h3><a name="REGEXP"></a><br>
+REGEXP</h3>
+<p> REGEXP is a list of wildcard patterns that determines which packages listed 
+  in CORE_PKGS.gmk go into which summary-table on the main API index page. It 
+  was motivated by the need to divide the world into &quot;core packages&quot; 
+  (java.*) and &quot;extension packages&quot; (javax.*). In time, the distinction 
+  went away. The whole table is now called &quot;Platform Packages&quot;--which 
+  eliminated the need for this list of regular expressions. But it lingered on, 
+  accreting all of the packages in the JVM, one by one. I pruned it back to &quot;*&quot;, 
+  so it now covers every package in the Java platform API docs. If some separation 
+  is needed in the future, it can grow back into a colon-separated list, starting 
+  with this, which is in all respects equivalent to &quot;*&quot; at this point 
+  in time:</p>
+<blockquote> 
+  <pre>REGEXP = &quot;java.*:javax.*:org.ietf*:org.omg.</pre>
+</blockquote>
+<h3><a name="releaseTargets"></a><br>
+  Release Targets</h3>
+<p> (Thanks to Kelly O'Hair for this info.)</p>
+<p> The <tt>rel-coredocs</tt> and <tt>rel-docs</tt> targets were added by Eric 
+  Armstrong. <tt>rel-coredocs</tt> assumes the kind of large, 32-bit machine used 
+  in the javapubs group's docs-release process. It specifies memory settings accordingly 
+  to maximize performance.</p>
+<p> The performance settings, like the sanity check, are most important for the 
+  core docs--the platform APIs. Running javadoc on those APIs takes a significant 
+  amount of time and memory. Setting the initial heap size as large as possible 
+  is important to prevent thrashing as the heap grows. Setting the maximum as 
+  large as necessary is also important to keep the job from failing.</p>
+<blockquote>
+  <p> <tt>-J-Xmx512</tt> sets a maximum of 512, which became necessary in 6.0<br>
+    <tt>-J-Xms256</tt> sets starting size to 256 (default is 8)</p>
+</blockquote>
+<p> <tt>rel-coredocs</tt> also includes a sanity check to help ensure that <tt>BUILD_NUMBER</tt> 
+  and <tt>MILESTONE</tt> are specified properly when docs are built outside of 
+  the normal release engineering process, with the intention of releasing them 
+  on the web or in a downloaded docs bundle. (When invoked in release engineering's 
+  control build, the values are always set properly. But when the targets are 
+  run by themselves, they default to b00 and &quot;internal&quot;--which silently 
+  sabotage the result of a build that can take many hours to complete.</p>
+</body>
+</html>
--- a/corba/.hgtags	Mon Sep 24 17:00:40 2012 +0400
+++ b/corba/.hgtags	Tue Sep 25 11:48:00 2012 -0700
@@ -176,3 +176,5 @@
 80689ff9cb499837513f18a1136dac7f0686cd55 jdk8-b52
 63aeb7a2472fb299134ad7388e0a111a5340b02d jdk8-b53
 16c82fc74695bab9b9e0fb05c086a5a08ba0082f jdk8-b54
+e8a0e84383d6fbd303ce44bd355fb25972b13286 jdk8-b55
+bf1bb47414e178beff67dc255fc3b97bf401f679 jdk8-b56
--- a/corba/makefiles/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/corba/makefiles/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -48,10 +48,8 @@
      JVM:=$(JAVA),\
      JAVAC:=$(JAVAC_JARS),\
      FLAGS:=$(BOOT_JDK_SOURCETARGET) -bootclasspath $(BOOT_RTJAR) $(DISABLE_CORBA_WARNINGS),\
-     SERVER_DIR:=$(JAVAC_SERVERS),\
-     SERVER_JVM:=$(SERVER_JAVA),\
-     MODE:=$(JAVAC_USE_MODE),\
-     USE_DEPS:=$(JAVAC_USE_DEPS)))
+     SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+     SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
 
 # The "generate new bytecode" uses the new compiler to generate bytecode
 # for the new jdk that is being built. The code compiled by this setup
@@ -59,13 +57,9 @@
 $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE,\
      JVM:=$(JAVA),\
      JAVAC:=$(JAVAC_JARS),\
-     FLAGS:=-Xprefer:source -XDignore.symbol.file=true \
-		-cp $(BOOT_JDK)/lib/tools.jar \
-		$(DISABLE_CORBA_WARNINGS),\
-     SERVER_DIR:=$(JAVAC_SERVERS),\
-     SERVER_JVM:=$(SERVER_JAVA),\
-     MODE:=$(JAVAC_USE_MODE),\
-     USE_DEPS:=$(JAVAC_USE_DEPS)))
+     FLAGS:=-cp $(BOOT_TOOLSJAR) -XDignore.symbol.file=true $(DISABLE_CORBA_WARNINGS),\
+     SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+     SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
 
 $(eval $(call SetupJavaCompilation,BUILD_STRIPPROP,\
 		SETUP:=GENERATE_OLDBYTECODE,\
--- a/hotspot/.hgtags	Mon Sep 24 17:00:40 2012 +0400
+++ b/hotspot/.hgtags	Tue Sep 25 11:48:00 2012 -0700
@@ -274,3 +274,5 @@
 9e3ae661284dc04185b029d85440fe7811f1ed07 hs24-b21
 e8fb566b94667f88462164defa654203f0ab6820 jdk8-b54
 09ea7e0752b306b8ae74713aeb4eb6263e1c6836 hs24-b22
+af0c8a0808516317333dcf9af15567cdd52761ce jdk8-b55
+6124ff4218296c91e4a72f1a76c064892d39d61b jdk8-b56
--- a/jaxp/.hgtags	Mon Sep 24 17:00:40 2012 +0400
+++ b/jaxp/.hgtags	Tue Sep 25 11:48:00 2012 -0700
@@ -176,3 +176,5 @@
 bd3c00d5761408954cc29ffb82016a76cbc90b43 jdk8-b52
 2c566f25c39f0087464b73e3bcf1c1421d0f2a7e jdk8-b53
 7dd81ccb7c1134df70969b3068b1e98def701746 jdk8-b54
+7c2363666890c6675194948fbcd74d81ddb84298 jdk8-b55
+f19d63b2119a0092f016203981ffef5cc31bc3c5 jdk8-b56
--- a/jaxp/makefiles/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/jaxp/makefiles/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -40,11 +40,9 @@
 $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG,\
      JVM:=$(JAVA),\
      JAVAC:=$(JAVAC_JARS),\
-     FLAGS:=-Xprefer:source -XDignore.symbol.file=true $(DISABLE_JAXP_WARNINGS) -g,\
-     SERVER_DIR:=$(JAVAC_SERVERS),\
-     SERVER_JVM:=$(SERVER_JAVA),\
-     MODE:=$(JAVAC_USE_MODE),\
-     USE_DEPS:=$(JAVAC_USE_DEPS)))
+     FLAGS:=-XDignore.symbol.file=true $(DISABLE_JAXP_WARNINGS) -g,\
+     SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+     SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
 
 $(eval $(call SetupJavaCompilation,BUILD_JAXP,\
 		SETUP:=GENERATE_NEWBYTECODE_DEBUG,\
--- a/jaxws/.hgtags	Mon Sep 24 17:00:40 2012 +0400
+++ b/jaxws/.hgtags	Tue Sep 25 11:48:00 2012 -0700
@@ -176,3 +176,5 @@
 f62bc618122e87a8bea69865cc02074e9d850426 jdk8-b52
 8a35fd644d3c0b75813ff0236adef8a1c6f895c6 jdk8-b53
 91970935926a20f19a5cbbf20931745ac1975e91 jdk8-b54
+109c9e1f2d8546e9954e1b7be9a37a4396434544 jdk8-b55
+7813455ccdb08c3ee6051161176821325a5d44d7 jdk8-b56
--- a/jaxws/makefiles/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/jaxws/makefiles/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -40,12 +40,9 @@
 $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG,\
      JVM:=$(JAVA),\
      JAVAC:=$(JAVAC_JARS),\
-     FLAGS:=-Xprefer:source -XDignore.symbol.file=true -cp $(BOOT_JDK)/lib/tools.jar \
-		$(DISABLE_JAXWS_WARNINGS) -g,\
-     SERVER_DIR:=$(JAVAC_SERVERS),\
-     SERVER_JVM:=$(SERVER_JAVA),\
-     MODE:=$(JAVAC_USE_MODE),\
-     USE_DEPS:=$(JAVAC_USE_DEPS)))
+     FLAGS:=-XDignore.symbol.file=true $(DISABLE_JAXWS_WARNINGS) -g,\
+     SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+     SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
 
 # Dummy here is needed to trigger copying of META-INF
 $(eval $(call SetupJavaCompilation,BUILD_JAF,\
--- a/jdk/.hgtags	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/.hgtags	Tue Sep 25 11:48:00 2012 -0700
@@ -177,3 +177,5 @@
 2c6933c5106b81a8578b70996fe5b735fb3adb60 jdk8-b53
 70ad0ed1d6cef0e7712690d1bab21e4769708aad jdk8-b54
 1f3f4b333341873f00da3dee85e4879f0e89c9bb jdk8-b55
+2e9eeef2909b33c9224a024afddb61ccb0b77f14 jdk8-b56
+51594d095a4bcffac4a314bf6e148214501399e0 jdk8-b57
--- a/jdk/make/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 #
 
 BUILDDIR=.
+
 include $(BUILDDIR)/common/Defs.gmk
 
 #
@@ -273,6 +274,7 @@
 # Release engineering targets.
 #
 include $(BUILDDIR)/common/Release.gmk
+-include $(CUSTOM_MAKE_DIR)/Release.gmk
 
 #
 # Cscope targets.
--- a/jdk/make/com/sun/java/pack/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/com/sun/java/pack/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -159,7 +159,7 @@
 	$(prep-target)
 	$(RM) $(TEMPDIR)/mapfile-vers
 	$(CP) mapfile-vers-unpack200 $(TEMPDIR)/mapfile-vers
-	$(LINKER)  $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
+	$(LINKER)  $(LDDFLAGS) $(sort $(UNPACK_EXE_FILES_o)) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
 ifdef MT
 	$(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
 endif
--- a/jdk/make/common/Defs-embedded.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#
-# 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.
-#
-
-#
-# Variable definitions for SE Embedded builds.  This file should
-# not contain rules.
-#
-ifdef JAVASE_EMBEDDED
-
-# Compress jar files
-COMPRESS_JARS = true
-
-# Don't mmap zip files
-LIBZIP_CAN_USE_MMAP = false
-
-# Disable ALSA version check
-REQUIRED_ALSA_VERSION =
-
-# Compilation settings
-OTHER_CPPFLAGS += -DJAVASE_EMBEDDED
-
-# Product naming
-PRODUCT_SUFFIX = SE Embedded Runtime Environment
-RUNTIME_NAME = $(PRODUCT_NAME) $(PRODUCT_SUFFIX)
-
-# Reduced JRE locations
-JRE_REDUCED_HEADLESS_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2re-reduced-headless-image
-JRE_REDUCED_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2re-reduced-image
-
-# Override on linux to further reduce binary/lib sizes in product build
-ifeq ($(PLATFORM), linux)
-  ifeq ($(VARIANT), OPT)
-    ifneq ($(NO_STRIP), true)
-      ifneq ($(DEBUG_BINARIES), true)
-        POST_STRIP_PROCESS = $(STRIP) --strip-unneeded
-      endif
-    endif
-  endif
-endif
-
-# NIO Platform specific source file location
-ifdef CROSS_COMPILE_ARCH
-  NIO_PLATFORM_CLASSES_ROOT_DIR = $(CLOSED_PLATFORM_SRC)/classes/
-endif
-
-# For ARM sflt we need to link to a library with improved FP accuracy
-# and it must be linked after fdlibm - this places it at the end after libc
-# -z muldefs avoids linker errors for duplicate symbols.
-ifeq ($(CROSS_COMPILE_ARCH), arm)
-  EXTRA_LIBS +=  $(EXT_LIBS_PATH)/sflt_glibc_jdk.a -Xlinker -z -Xlinker muldefs
-endif
-
-endif # JAVASE_EMBEDDED
-
--- a/jdk/make/common/Defs.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/common/Defs.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -109,6 +109,21 @@
   endif
 endif
 
+# We allow for potential specialization of build files. This has to be
+# done on a file-by-file, case-by-case basis. Here we define the basic control
+# over where custom files are being used. Later we will -include the custom
+# Defs.gmk if present. This works best because all Makefiles include defs.gmk.
+# In other cases we can either have foo.gmk include custom/foo.gmk, or
+# a Makefile can do:
+#  include foo.gmk
+#  -include $CUSTOM_MAKE_DIR/foo.gmk
+#
+# For non-OpenJDK builds the default location is the make/closed repository.
+# For OpenJDK builds a real value has to be supplied externally.
+ifneq ($(OPENJDK),true)
+  CUSTOM_MAKE_DIR = $(BUILDDIR)/closed
+endif
+
 #
 # Get platform definitions
 #
@@ -116,12 +131,6 @@
 include $(JDK_TOPDIR)/make/common/Defs-$(PLATFORM).gmk
 
 #
-# SE-Embedded support, if enabled
-#
-
-include $(JDK_TOPDIR)/make/common/Defs-embedded.gmk
-
-#
 # Cross-compilation Settings
 #
 ifdef CROSS_COMPILE_ARCH
@@ -542,6 +551,21 @@
 CXXFLAGS_$(VARIANT)/BYFILE  = $(CXXFLAGS_$(VARIANT)/$(@F)) \
                               $(CXXFLAGS_$(VARIANT)$(CXXFLAGS_$(VARIANT)/$(@F)))
 
+# Command line define to provide basename of file being compiled to source.
+#   The C macro THIS_FILE can replace the use of __FILE__ in the source
+#   files for the current filename being compiled.
+#   The value of the __FILE__ macro is unpredictable and can be anything
+#   from a relative path to a full path, THIS_FILE will be more consistent..
+#   The THIS_FILE macro will always be just the basename of the file being
+#   compiled.
+#   Different string literals in the the object files makes it difficult to
+#   compare shared libraries from different builds.
+#
+#   NOTE: If the THIS_FILE macro is actually expanded while in an included
+#         source file, it will not return the name of the included file.
+#
+CPP_THIS_FILE = -DTHIS_FILE='"$(<F)"'
+
 #
 # Tool flags
 #
@@ -551,7 +575,7 @@
 CFLAGS          = $(CFLAGS_$(VARIANT)/BYFILE)   $(CFLAGS_COMMON) $(OTHER_CFLAGS) $(EXTRA_CFLAGS)
 CXXFLAGS        = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS) $(EXTRA_CFLAGS)
 CPPFLAGS        = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
-		  $(DEFINES) $(OPTIONS:%=-D%)
+		  $(DEFINES) $(OPTIONS:%=-D%) $(CPP_THIS_FILE)
 LDFLAGS         = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
 LDLIBS          = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
 LINTFLAGS       = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
@@ -596,4 +620,6 @@
 $(install-importonly-file)
 endef
 
+-include $(CUSTOM_MAKE_DIR)/Defs.gmk
+
 .PHONY: all build clean clobber
--- a/jdk/make/common/Demo.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/common/Demo.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -320,10 +320,10 @@
   ifeq ($(PLATFORM),windows)
 	$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(DEMO_VERSION_INFO) $(VERSIONINFO_RESOURCE)
 	$(LINK.demo) $(SHARED_LIBRARY_FLAG) -Fe$@ \
-	    $(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
+	    $(sort $(DEMO_FULL_OBJECTS)) $(LDLIBS.demo)
   else
 	$(LINK.demo) $(SHARED_LIBRARY_FLAG) -o $@ \
-	    $(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
+	    $(sort $(DEMO_FULL_OBJECTS)) $(LDLIBS.demo)
   endif
 	@$(call binary_file_verification,$@)
 
--- a/jdk/make/common/Library.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/common/Library.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -199,7 +199,7 @@
 $(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
 	@$(prep-target)
 	@$(MKDIR) -p $(TEMPDIR)
-	@$(ECHO) $(FILES_o) > $@ 
+	@$(ECHO) $(sort $(FILES_o)) > $@ 
 ifndef LOCAL_RESOURCE_FILE
 	@$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@
 endif
@@ -256,9 +256,9 @@
 	@$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)"
 	@$(ECHO) "Rebuilding $@ because of $?"
 ifeq ($(LIBRARY), fdlibm)
-	$(AR) $(ARFLAGS) $@ $(FILES_o)
+	$(AR) $(ARFLAGS) $@ $(sort $(FILES_o))
 else # LIBRARY
-	$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
+	$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(sort $(FILES_o)) $(LDLIBS)
 	@$(call binary_file_verification,$@)
 ifeq ($(WRITE_LIBVERSION),true)
 	$(MCS) -d -a "$(FULL_VERSION)" $@
--- a/jdk/make/common/Program.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/common/Program.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -262,7 +262,7 @@
 	$(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
 	@$(MKDIR) -p $(TEMPDIR)
 	$(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
-	$(FILES_o) $(THREADLIBS) $(LDLIBS)
+	$(sort $(FILES_o)) $(THREADLIBS) $(LDLIBS)
   ifeq ($(findstring privileged, $(INFO_PLIST_FILE)), privileged)
 	-codesign -s openjdk_codesign $@
   endif
@@ -392,8 +392,6 @@
 VERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
                    -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"'
 
-
-
 $(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c
 	@$(prep-target)
 	$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$(OBJDIR)/main.$(OBJECT_SUFFIX) \
--- a/jdk/make/common/Release-embedded.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,230 +0,0 @@
-#
-# 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.
-#
-
-#
-# SE-Embedded Reduced JRE targets
-#
-ifdef JAVASE_EMBEDDED
-
-reduced-image-jre reduced-headless-image-jre ::
-	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
-
-# Add the reduced-jre images as pre-reqs. These will be processed last
-images:: reduced-image-jre reduced-headless-image-jre
-
-
-######################################################
-# Create the headless rt.jar
-######################################################
-
-NOT_HEADLESS_RT_JAR_LIST = $(ABS_TEMPDIR)/not_hl_rt_jar.list
-HEADLESS_RT_JAR_FILELIST=$(JARFILELISTS_TEMPDIR)/hl_rt_jar_list
-TOTAL_HEADLESS_JAR_FILELIST=$(REORDER_TEMPDIR)/hl_file_list
-HEADLESS_CLASSLIST=$(ABS_TEMPDIR)/headless_classlist
-
-# Add the jar file directories that we don't want in the
-# headless JRE.  If you want to remove most classes in a
-# directory, put the directory in the NOT_HEADLESS_RT_JAR_LIST
-# and put the individual classes you want to keep in the 
-# HEADLESS_CLASSLIST file. 
-$(NOT_HEADLESS_RT_JAR_LIST): $(NOT_RT_JAR_LIST)
-	$(RM) $(HEADLESS_CLASSLIST)
-	$(RM) $(NOT_HEADLESS_RT_JAR_LIST)
-	$(CP) $(NOT_RT_JAR_LIST) $(NOT_HEADLESS_RT_JAR_LIST)
-# List all the packages to be excluded
-	$(ECHO) "sun/awt/motif/" >> $@
-	$(ECHO) "sun/awt/X11/" >> $@
-	$(ECHO) "sun/applet/" >> $@
-	$(ECHO) "sun/java2d/opengl/" >> $@
-	$(ECHO) "com/sun/java/swing/plaf/" >> $@
-# List all the individual classes to be included
-	$(ECHO) "sun/awt/motif/MFontConfiguration.class" >$(HEADLESS_CLASSLIST)
-	$(ECHO) "sun/applet/AppContextCreator.class" >>$(HEADLESS_CLASSLIST)
-	$(ECHO) "sun/applet/AppletAudioClip.class" >>$(HEADLESS_CLASSLIST)
-	$(ECHO) "sun/java2d/opengl/GLXSurfaceData.class" >>$(HEADLESS_CLASSLIST)
-	$(ECHO) "sun/java2d/opengl/GLXSurfaceData"\$$"GLXOffScreenSurfaceData.class" >>$(HEADLESS_CLASSLIST)
-	$(ECHO) "sun/java2d/opengl/GLXVolatileSurfaceManager.class" >>$(HEADLESS_CLASSLIST)
-	$(ECHO) "sun/java2d/opengl/OGLSurfaceData.class" >>$(HEADLESS_CLASSLIST)
-
-
-$(TOTAL_HEADLESS_JAR_FILELIST): $(JARREORDER_JARFILE) $(NOT_HEADLESS_RT_JAR_LIST)
-	$(prep-target)
-	$(RM) $@.temp
-	$(CD) $(CLASSBINDIR) ; \
-		$(BOOT_JAVA_CMD) -jar $(JARREORDER_JARFILE) \
-		-o  $@.temp - $(NOT_HEADLESS_RT_JAR_LIST)  .
-# Add on the explicitly included class files from the otherwise excluded packages
-	$(CAT) $(HEADLESS_CLASSLIST) >> $@.temp
-	$(MV) $@.temp $@
-	@$(CD) $(CLASSBINDIR); $(java-vm-cleanup)
-
-# Create the headless rt.jar file list & non-class files list
-MakeHeadlessJarFileList: $(TOTAL_HEADLESS_JAR_FILELIST) $(JARSPLIT_JARFILE)
-	@$(RM) $(HEADLESS_RT_JAR_FILELIST) $(RES_JAR_FILELIST)
-	$(BOOT_JAVA_CMD) -jar $(JARSPLIT_JARFILE) $(TOTAL_HEADLESS_JAR_FILELIST) \
-		-o  $(HEADLESS_RT_JAR_FILELIST) $(RES_JAR_FILELIST)
-	@$(java-vm-cleanup)
-
-# Create headless rt.jar
-HL_RT_JAR=$(ABS_TEMPDIR)/rt-hl-orig.jar
-$(HL_RT_JAR): MakeHeadlessJarFileList $(RT_JAR_MANIFEST_FILE)
-	$(prep-target)
-	$(CD) $(CLASSBINDIR) ; \
-		$(BOOT_JAR_CMD) $(CREATE_JAR_OPTS) $(RT_JAR_MANIFEST_FILE) $@ @$(HEADLESS_RT_JAR_FILELIST) \
-		 $(JAR_JFLAGS)
-	@$(CD) $(CLASSBINDIR); $(java-vm-cleanup)
-
-
-#
-# Produce a reduced Headful JRE for Embedded Devices
-#
-# The deployment binaries are added during the deployment build process
-#
-
-# Binaries that don't get included in reduced jre image bin directory
-NOT_REDUCEDJRE_BIN = \
- java_vm \
- kinit \
- klist \
- ktab \
- orbd \
- policytool \
- rmid \
- rmiregistry \
- servertool \
- tnameserv \
- pack200 \
- unpack200
-
-# jars/resources/libs that don't get included in reduced jre image lib directory
-NOT_REDUCEDJRE_LIB = \
- charsets.jar \
- ext/dnsns.jar \
- ext/localedata.jar \
- $(LIBARCH)/client/classes.jsa \
- $(LIBARCH)/libjavaplugin_jni.so \
- $(LIBARCH)/libjavaplugin_nscp_gcc29.so \
- $(LIBARCH)/libjavaplugin_nscp.so \
- $(LIBARCH)/libjavaplugin_oji.so
-
-# JRE docs that don't get included in reduced jre image top directory
-NOT_REDUCEDJRE_DOC = \
- Welcome.html
-
-reduced-image-jre::
-	@$(ECHO) Starting to Produce Reduced JRE
-	@#
-	@# First make a copy of the full JRE
-	@#
-	$(RM) -r $(JRE_REDUCED_IMAGE_DIR)
-	$(MKDIR) -p $(JRE_REDUCED_IMAGE_DIR)
-	$(CD) $(JRE_IMAGE_DIR); \
-	    $(TAR) cf - . | ($(CD) $(JRE_REDUCED_IMAGE_DIR); $(TAR) xf - ); 
-
-	@#
-	@# Remove all of the files that are not needed for the
-	@# reduced JRE
-	@#
-	for l in $(NOT_REDUCEDJRE_BIN) ; do \
-	    $(RM) $(JRE_REDUCED_IMAGE_DIR)/bin/$$l ; \
-	done
-	for l in $(NOT_REDUCEDJRE_LIB) ; do \
-	    $(RM) $(JRE_REDUCED_IMAGE_DIR)/lib/$$l ; \
-	done
-	for l in $(NOT_REDUCEDJRE_DOC) ; do \
-	    $(RM) $(JRE_REDUCED_IMAGE_DIR)/$$l ; \
-	done
-
-	@# Remove misc. other files
-	$(RM) -r $(JRE_REDUCED_IMAGE_DIR)/man
-	$(RM) -f $(JRE_REDUCED_IMAGE_DIR)/CHANGES
-
-	@$(ECHO) Done Creating Reduced JRE
-
-#
-# Produce a reduced Headless JRE
-#
-reduced-headless-image-jre:: $(RT_JAR) $(RESOURCES_JAR) $(BUILD_META_INDEX) $(HL_RT_JAR)
-	@$(ECHO) Starting to Produce Reduced Headless JRE
-	@#
-	@# First make a copy of the reduced JRE we just built
-	@#
-	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)
-	$(MKDIR) -p $(JRE_REDUCED_HEADLESS_IMAGE_DIR)
-	$(CD) $(JRE_REDUCED_IMAGE_DIR); \
-	    $(TAR) cf - . | ($(CD) $(JRE_REDUCED_HEADLESS_IMAGE_DIR); $(TAR) xf - ); 
-
-	@# Replace the full rt.jar with the headless rt.jar
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/rt.jar
-	$(CP) $(HL_RT_JAR) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/rt.jar
-
-	@#
-	@# Remove all of the files that are not needed for the
-	@# reduced Headless JRE
-	@#
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/gtkhelper
-	$(RM)  $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libjsoundalsa.so
-	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/audio
-	$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/applet
-	$(RM)  $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/awt_robot
-	$(RM)  $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libawt_xawt.so
-	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libsplashscreen.so
-	@# Remove oblique fonts and reduce font support to LucidaSansRegular only
-	$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/oblique-fonts
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightDemiBold.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightDemiItalic.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightItalic.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightRegular.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaSansDemiBold.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaTypewriterBold.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaTypewriterRegular.ttf
-
-ifeq ($(PLATFORM), linux)
-# put out minimal fonts.dir file for the remaining font
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
-	$(ECHO) 6>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
-	$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-1">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
-	$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-2">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
-	$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-4">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
-	$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-5">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
-	$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-7">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
-	$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-9">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
-
-endif # Linux
-
-	@#
-	@# all done with JRE reduced headless image
-	@#
-
-	@$(ECHO) Done Creating Reduced Headless JRE
-
-images-clobber::
-	$(RM) -r $(JRE_REDUCED_IMAGE_DIR)
-	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)
-
-.PHONY: reduced-image-jre reduced-headless-image-jre 
-
-endif # JAVASE_EMBEDDED
-
--- a/jdk/make/common/Release.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/common/Release.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -750,10 +750,6 @@
 
 BUILDMETAINDEX_JARFILE = $(ABS_BUILDTOOLJARDIR)/buildmetaindex.jar
 
-# SE-Embedded targets if enabled
-include $(JDK_TOPDIR)/make/common/Release-embedded.gmk
-
-
 ######################################################
 # JRE Image
 ######################################################
--- a/jdk/make/docs/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/docs/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -73,7 +73,7 @@
 else ifeq ($(ARCH),universal)
   MAX_VM_MEMORY = 1024
 else
-  MAX_VM_MEMORY = 612
+  MAX_VM_MEMORY = 768
 endif
 
 # List of all possible directories for javadoc to look for sources
--- a/jdk/make/java/jli/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/java/jli/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -190,7 +190,7 @@
 
   $(STATIC_LIBRARY): $(FILES_o)
 	@$(prep-target)
-	$(LIBEXE) -nologo -out:$@ $(FILES_o)
+	$(LIBEXE) -nologo -out:$@ $(sort $(FILES_o))
 
   library:: $(STATIC_LIBRARY)
 endif # PLATFORM
@@ -216,7 +216,7 @@
 
 $(STATIC_LIBRARY): $(STATIC_LIBRARY_DIR)
 	@$(prep-target)
-	$(AR) $(ARFLAGS) $@ $(FILES_o)
+	$(AR) $(ARFLAGS) $@ $(sort $(FILES_o))
 
 library:: $(STATIC_LIBRARY)
 
--- a/jdk/make/sun/security/ec/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/sun/security/ec/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -128,7 +128,6 @@
 # Exclude the sources that get built by ../other/Makefile
 #
 AUTO_JAVA_PRUNE = \
-    ECKeyFactory.java \
     ECParameters.java \
     ECPrivateKeyImpl.java \
     ECPublicKeyImpl.java \
--- a/jdk/make/sun/security/other/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/make/sun/security/other/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -53,7 +53,6 @@
 # EC classes used by the packages above
 #
 FILES_java += \
-    sun/security/ec/ECKeyFactory.java \
     sun/security/ec/ECParameters.java \
     sun/security/ec/ECPrivateKeyImpl.java \
     sun/security/ec/ECPublicKeyImpl.java \
--- a/jdk/makefiles/CompileDemos.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/CompileDemos.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -44,10 +44,11 @@
 
 define SetupAppletDemo
      $$(eval $$(call SetupJavaCompilation,BUILD_DEMO_APPLET_$1,\
-                SETUP:=GENERATE_USINGJDKBYTECODE$2,\
+                SETUP:=GENERATE_USINGJDKBYTECODE,\
 		SRC:=$(JDK_TOPDIR)/src/$3share/demo/applets/$1,\
-		BIN:=$(JDK_OUTPUTDIR)/newdemo/applets/$1,\
-		COPY:=.html .java .xyz .obj .au .gif))
+		BIN:=$(JDK_OUTPUTDIR)/demo/applets/$1,\
+		COPY:=.html .java .xyz .obj .au .gif,\
+		DISABLE_SJAVAC:=$2))
      BUILD_DEMOS += $$(BUILD_DEMO_APPLET_$1)
 endef
 
@@ -67,11 +68,11 @@
 $(eval $(call SetupAppletDemo,SpreadSheet))
 # Build WireFrame without a server since it
 # has a class Matrix3D that also exists in MoleculeViewer.
-$(eval $(call SetupAppletDemo,WireFrame,_NOSERV))
+$(eval $(call SetupAppletDemo,WireFrame,true))
 
 ifndef OPENJDK
     $(eval $(call SetupAppletDemo,Animator,,closed/))
-    $(eval $(call SetupAppletDemo,GraphLayout,_NOSERV,closed/))
+    $(eval $(call SetupAppletDemo,GraphLayout,true,closed/))
     $(eval $(call SetupAppletDemo,JumpingBox,,closed/))
     $(eval $(call SetupAppletDemo,TicTacToe,,closed/))
 endif
@@ -111,29 +112,30 @@
 
     ifneq ($$($1_JAVA_FILES_EXIST),)
         $$(eval $$(call SetupJavaCompilation,BUILD_DEMO_$1,\
-                SETUP:=GENERATE_USINGJDKBYTECODE$(12),\
+                SETUP:=GENERATE_USINGJDKBYTECODE,\
                 ADD_JAVAC_FLAGS:=$3,\
 		SRC:=$$($1_MAIN_SRC) $5,\
-		BIN:=$(JDK_OUTPUTDIR)/newdemoclasses/$2/$1,\
+		BIN:=$(JDK_OUTPUTDIR)/democlasses/$2/$1,\
 		COPY:=$(PATTERNS_TO_COPY) $(10),\
-		JAR:=$(JDK_OUTPUTDIR)/newdemo/$2/$1/$$($1_JARFILE),\
+		JAR:=$(JDK_OUTPUTDIR)/demo/$2/$1/$$($1_JARFILE),\
 		JARMAIN:=$4,\
 		MANIFEST:=$(JDK_TOPDIR)/make/tools/manifest.mf,\
 		EXTRA_MANIFEST_ATTR:=$(11),\
-		SRCZIP:=$(JDK_OUTPUTDIR)/newdemo/$2/$1/src.zip,\
-		EXCLUDE_FILES:=$9))
+		SRCZIP:=$(JDK_OUTPUTDIR)/demo/$2/$1/src.zip,\
+		EXCLUDE_FILES:=$9,\
+		DISABLE_SJAVAC:=$(12)))
 
         BUILD_DEMOS +=  $$(BUILD_DEMO_$1) \
-			$(JDK_OUTPUTDIR)/newdemo/$2/$1/$$($1_JARFILE) \
-			$(JDK_OUTPUTDIR)/newdemo/$2/$1/src.zip 
+			$(JDK_OUTPUTDIR)/demo/$2/$1/$$($1_JARFILE) \
+			$(JDK_OUTPUTDIR)/demo/$2/$1/src.zip 
     endif
 
     # Copy files.
     $1_COPY_TARGETS :=  $$(patsubst $(JDK_TOPDIR)/src/$6share/demo/$2/$1/%,\
-			$(JDK_OUTPUTDIR)/newdemo/$2/$1/%,\
+			$(JDK_OUTPUTDIR)/demo/$2/$1/%,\
 			$$(wildcard $$(addprefix $(JDK_TOPDIR)/src/$6share/demo/$2/$1/,$7)))
     ifneq ($7,)
-        $(JDK_OUTPUTDIR)/newdemo/$2/$1/% : $(JDK_TOPDIR)/src/$6share/demo/$2/$1/%
+        $(JDK_OUTPUTDIR)/demo/$2/$1/% : $(JDK_TOPDIR)/src/$6share/demo/$2/$1/%
 		$(MKDIR) -p $$(@D)
 		$(CP) $$< $$@
 		$(CHMOD) -f ug+w $$@
@@ -144,20 +146,20 @@
 endef
 
 $(eval $(call SetupDemo,CodePointIM,jfc,,CodePointIM,,,*.html))
-$(JDK_OUTPUTDIR)/newdemo/jfc/CodePointIM/_the.services : \
-			$(JDK_OUTPUTDIR)/newdemo/jfc/CodePointIM/CodePointIM.jar \
+$(JDK_OUTPUTDIR)/demo/jfc/CodePointIM/_the.services : \
+			$(JDK_OUTPUTDIR)/demo/jfc/CodePointIM/CodePointIM.jar \
 			$(JDK_TOPDIR)/src/share/demo/jfc/CodePointIM/java.awt.im.spi.InputMethodDescriptor
-	(cd $(JDK_OUTPUTDIR)/newdemo/jfc/CodePointIM && \
+	(cd $(JDK_OUTPUTDIR)/demo/jfc/CodePointIM && \
 		$(MKDIR) -p _the.tmp/META-INF/services && \
 		$(CP) $(JDK_TOPDIR)/src/share/demo/jfc/CodePointIM/java.awt.im.spi.InputMethodDescriptor _the.tmp/META-INF/services && \
 		cd _the.tmp && \
-		$(JAR) uf $(JDK_OUTPUTDIR)/newdemo/jfc/CodePointIM/CodePointIM.jar META-INF/services/java.awt.im.spi.InputMethodDescriptor && \
+		$(JAR) uf $(JDK_OUTPUTDIR)/demo/jfc/CodePointIM/CodePointIM.jar META-INF/services/java.awt.im.spi.InputMethodDescriptor && \
 		cd META-INF/services && \
-		$(JAR) uf $(JDK_OUTPUTDIR)/newdemo/jfc/CodePointIM/CodePointIM.jar java.awt.im.spi.InputMethodDescriptor)
-	$(RM) -r $(JDK_OUTPUTDIR)/newdemo/jfc/CodePointIM/_the.tmp
+		$(JAR) uf $(JDK_OUTPUTDIR)/demo/jfc/CodePointIM/CodePointIM.jar java.awt.im.spi.InputMethodDescriptor)
+	$(RM) -r $(JDK_OUTPUTDIR)/demo/jfc/CodePointIM/_the.tmp
 	$(TOUCH) $@
 
-BUILD_DEMOS+=$(JDK_OUTPUTDIR)/newdemo/jfc/CodePointIM/_the.services
+BUILD_DEMOS+=$(JDK_OUTPUTDIR)/demo/jfc/CodePointIM/_the.services
 
 $(eval $(call SetupDemo,FileChooserDemo,jfc,,FileChooserDemo,,,README*))
 $(eval $(call SetupDemo,Font2DTest,jfc,,Font2DTest,,,*.html *.txt))
@@ -182,12 +184,12 @@
     $(eval $(call SetupDemo,Stylepad,jfc,,Stylepad,\
 		$(JDK_TOPDIR)/src/share/demo/jfc/Notepad,closed/,*.txt,,$(JDK_TOPDIR)/src/share/demo/jfc/Notepad/README.txt))
     $(eval $(call SetupDemo,SwingSet2,jfc,,SwingSet2,,closed/,README* *.html,,,.java COPYRIGHT,\
-		SplashScreen-Image: resources/images/splash.png,_NOSERV))
+		SplashScreen-Image: resources/images/splash.png,true))
 
     BUILD_DEMOS += $(patsubst $(JDK_TOPDIR)/src/closed/share/demo/nbproject/%,\
-			$(JDK_OUTPUTDIR)/newdemo/nbproject/%,\
+			$(JDK_OUTPUTDIR)/demo/nbproject/%,\
 			$(shell $(FIND) $(JDK_TOPDIR)/src/closed/share/demo/nbproject/ -type f))
-    $(JDK_OUTPUTDIR)/newdemo/nbproject/% : $(JDK_TOPDIR)/src/closed/share/demo/nbproject/%
+    $(JDK_OUTPUTDIR)/demo/nbproject/% : $(JDK_TOPDIR)/src/closed/share/demo/nbproject/%
 		$(MKDIR) -p $(@D)
 		$(CP) $< $@
 		$(CHMOD) -f ug+w $@
@@ -196,7 +198,7 @@
 ##################################################################################################
 
 # Why do we install a demo jar into the main jre/lib/ext????????????????
-$(JDK_OUTPUTDIR)/lib/ext/zipfs.jar : $(JDK_OUTPUTDIR)/newdemo/nio/zipfs/zipfs.jar
+$(JDK_OUTPUTDIR)/lib/ext/zipfs.jar : $(JDK_OUTPUTDIR)/demo/nio/zipfs/zipfs.jar
 		$(MKDIR) -p $(@D)
 		$(CP) $< $@
 
@@ -207,52 +209,74 @@
 # In the old makefiles, j2dbench was not compiled. 
 #$(eval $(call SetupDemo,J2DBench,java2d,/src,,j2dbench/J2DBench))
 
+# JVMTI demos are a bit strange and share some files, but be careful the
+#    shared files are just the *.c and *.h files, not the README or sample
+#    makefiles. So we always exclude the README.txt and sample.makefile.txt
+#    from the extra sources.
 define SetupJVMTIDemo
      # Param 1 = Name of the demo
      # Param 2 = add these directories to the includes, default is agent_util
      # Param 3 = extra CFLAGS
      # Param 4 = C or C++ (defaults to C)
      # Param 5 = libs for posix
-     # Param 6 = libs for winapi
+     # Param 6 = libs for windows
      # Param 7 = libs for solaris
-     BUILD_DEMO_JVMTI_$1_EXTRA_SRC:=	$$(wildcard $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/demo/jvmti/$1) \
-					$$(wildcard $$(addprefix $(JDK_TOPDIR)/src/share/demo/jvmti/,$2))
+     BUILD_DEMO_JVMTI_$1_EXTRA_SRC:= \
+        $$(wildcard $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/demo/jvmti/$1) \
+	$$(wildcard $$(addprefix $(JDK_TOPDIR)/src/share/demo/jvmti/,$2))
+     BUILD_DEMO_JVMTI_$1_EXTRA_SRC_EXCLUDE:= \
+	$$(wildcard $$(addprefix $(JDK_TOPDIR)/src/share/demo/jvmti/,$2)/README.txt) \
+	$$(wildcard $$(addprefix $(JDK_TOPDIR)/src/share/demo/jvmti/,$2)/sample.makefile.txt)
      BUILD_DEMO_JVMTI_$1_EXTRA_INC:=$$(addprefix -I,$$(BUILD_DEMO_JVMTI_$1_EXTRA_SRC))
      BUILD_DEMO_JVMTI_$1_LANG:=C
-     BUILD_DEMO_JVMTI_$1_O_FLAG:=$(C_O_FLAG_NORM)
      ifneq (,$4)
          BUILD_DEMO_JVMTI_$1_LANG:=$4
      endif
      ifeq (C++,$4)
-         $1_EXTRA_CXX:=$(LIBCXX)
-         BUILD_DEMO_JVMTI_$1_O_FLAG:=$(CXX_O_FLAG_NORM)
+         $1_EXTRA_CXX:=$(LDFLAGS_CXX_JDK) $(LIBCXX)
      endif
 
-     $1_CXXFLAGS:=$(CXXFLAGS_JDKLIB) $$(BUILD_DEMO_JVMTI_$1_O_FLAG) -I$(JDK_TOPDIR)/src/share/demo/jvmti/$1 $$(BUILD_DEMO_JVMTI_$1_EXTRA_INC) $3
+     $1_CXXFLAGS:=$(CXXFLAGS_JDKLIB) -I$(JDK_TOPDIR)/src/share/demo/jvmti/$1 \
+		  $$(BUILD_DEMO_JVMTI_$1_EXTRA_INC) $3 \
+		  $(CXXFLAGS_DEBUG_SYMBOLS)
      ifeq ($1-$(OPENJDK_TARGET_CPU_ARCH),waiters-sparc)
-       $1_FILTER:=-xregs=no%appl
-       $1_CXXFLAGS:=$$(filter-out $$($1_FILTER),$$($1_CXXFLAGS))
+         $1_FILTER:=-xregs=no%appl
+         $1_CXXFLAGS:=$$(filter-out $$($1_FILTER),$$($1_CXXFLAGS))
      endif
 
+     # Workaround for CFLAGS_JDKLIB containing ',' on solaris. If this is added as 'CFLAGS' to the
+     # eval call below, the comma gets expanded too early.
+     BUILD_DEMO_JVMTI_$1_CFLAGS:=$(CFLAGS_JDKLIB) $(CFLAGS_DEBUG_SYMBOLS) \
+		-I$(JDK_TOPDIR)/src/share/demo/jvmti/$1 $$(BUILD_DEMO_JVMTI_$1_EXTRA_INC) $3
+
+     # Remove the -incremental:no setting to get .ilk-files like in the old build.
      $$(eval $$(call SetupNativeCompilation,BUILD_DEMO_JVMTI_$1,\
 		SRC:=$(JDK_TOPDIR)/src/share/demo/jvmti/$1 $$(BUILD_DEMO_JVMTI_$1_EXTRA_SRC),\
 		LANG:=$$(BUILD_DEMO_JVMTI_$1_LANG),\
-		CFLAGS:=$(CFLAGS_JDKLIB) $$(BUILD_DEMO_JVMTI_$1_O_FLAG) -I$(JDK_TOPDIR)/src/share/demo/jvmti/$1 $$(BUILD_DEMO_JVMTI_$1_EXTRA_INC) $3,\
+		OPTIMIZATION:=LOW,\
 		CXXFLAGS:=$$($1_CXXFLAGS),\
-		LDFLAGS:=$(LDFLAGS_JDKLIB),\
+		LDFLAGS:=$(filter-out -incremental:no -opt:ref,$(LDFLAGS_JDKLIB)),\
+		LDFLAGS_macosx:=$(call SET_EXECUTABLE_ORIGIN),\
 		LDFLAGS_SUFFIX:=$$($1_EXTRA_CXX),\
 		LDFLAGS_SUFFIX_posix:=$5,\
-		LDFLAGS_SUFFIX_winapi:=$6,\
-		LDFLAGS_SUFFIX_solaris:=-lc $7,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/newdemoobjs/jvmti/$1,\
-		OUTPUT_DIR:=$(JDK_OUTPUTDIR)/newdemo/jvmti/$1/lib,\
+		LDFLAGS_SUFFIX_windows:=$6,\
+		LDFLAGS_SUFFIX_solaris:=$7 -lc,\
+		LDFLAGS_SUFFIX_linux:=$8,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$$(RC_FLAGS) \
+			  /D "JDK_FNAME=$1.dll" \
+			  /D "JDK_INTERNAL_NAME=$1" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/demoobjs/jvmti/$1,\
+		OUTPUT_DIR:=$(JDK_OUTPUTDIR)/demo/jvmti/$1/lib,\
 		LIBRARY:=$1))
 
     $$(eval $$(call SetupZipArchive,BUILD_DEMO_JVMTI_SRC_$1,\
 		SRC:=$(JDK_TOPDIR)/src/share/demo/jvmti/$1 $$(BUILD_DEMO_JVMTI_$1_EXTRA_SRC),\
-		ZIP:=$(JDK_OUTPUTDIR)/newdemo/jvmti/$1/src.zip))
+		EXCLUDE_FILES:=$$(BUILD_DEMO_JVMTI_$1_EXTRA_SRC_EXCLUDE), \
+		ZIP:=$(JDK_OUTPUTDIR)/demo/jvmti/$1/src.zip))
 
-     $(JDK_OUTPUTDIR)/newdemo/jvmti/$1/README.txt : $(JDK_TOPDIR)/src/share/demo/jvmti/$1/README.txt
+     $(JDK_OUTPUTDIR)/demo/jvmti/$1/README.txt : $(JDK_TOPDIR)/src/share/demo/jvmti/$1/README.txt
 		$(MKDIR) -p $$(@D)
 		$(CP) $$< $$@
 		$(CHMOD) -f ug+w $$@
@@ -261,29 +285,40 @@
          $$(eval $$(call SetupJavaCompilation,BUILD_DEMO_JVMTI_$1_JAVA,\
                 SETUP:=GENERATE_USINGJDKBYTECODE,\
 		SRC:=$(JDK_TOPDIR)/src/share/demo/jvmti/$1,\
-		BIN:=$(JDK_OUTPUTDIR)/newdemoclasses/jvmti/$1,\
+		BIN:=$(JDK_OUTPUTDIR)/democlasses/jvmti/$1,\
 		COPY:=$(PATTERNS_TO_COPY),\
-		JAR:=$(JDK_OUTPUTDIR)/newdemo/jvmti/$1/$1.jar,\
+		JAR:=$(JDK_OUTPUTDIR)/demo/jvmti/$1/$1.jar,\
 		EXTRA_MANIFEST_ATTR:=Main-Class: \n,\
 		MANIFEST:=$(JDK_TOPDIR)/make/tools/manifest.mf))
 
-         BUILD_DEMOS += $(JDK_OUTPUTDIR)/newdemo/jvmti/$1/$1.jar
+         BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jvmti/$1/$1.jar
      endif
 
      BUILD_DEMOS += 	$$(BUILD_DEMO_JVMTI_$1) \
-			$(JDK_OUTPUTDIR)/newdemo/jvmti/$1/src.zip \
-			$(JDK_OUTPUTDIR)/newdemo/jvmti/$1/README.txt
+			$(JDK_OUTPUTDIR)/demo/jvmti/$1/src.zip \
+			$(JDK_OUTPUTDIR)/demo/jvmti/$1/README.txt
+
+     ifeq ($(OPENJDK_TARGET_OS),windows)
+         # These files normally end up in OBJECT_DIR but for demos they
+         # are supposed to be included in the distro.
+         $(JDK_OUTPUTDIR)/demo/jvmti/$1/lib/$1.lib: $$(BUILD_DEMO_JVMTI_$1)
+		$(CP) $(JDK_OUTPUTDIR)/demoobjs/jvmti/$1/$1.lib $$@
+
+         $(JDK_OUTPUTDIR)/demo/jvmti/$1/lib/$1.exp: $$(BUILD_DEMO_JVMTI_$1)
+		$(CP) $(JDK_OUTPUTDIR)/demoobjs/jvmti/$1/$1.exp $$@
+
+         BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jvmti/$1/lib/$1.lib \
+			$(JDK_OUTPUTDIR)/demo/jvmti/$1/lib/$1.exp
+     endif
 endef
 
 $(eval $(call SetupJVMTIDemo,compiledMethodLoad,	agent_util))
 $(eval $(call SetupJVMTIDemo,gctest,			agent_util))
 $(eval $(call SetupJVMTIDemo,heapTracker,		agent_util java_crw_demo))
 $(eval $(call SetupJVMTIDemo,heapViewer,		agent_util))
-# hprof contains error messages using __FILE__ macro. These expand to the absolute path
-# in the new build system and relative in the old, causing the binaries to differ.
 $(eval $(call SetupJVMTIDemo,hprof,			java_crw_demo,\
-		-I$(JDK_TOPDIR)/src/share/npt -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/npt,C,\
-		-ldl,ws2_32.lib winmm.lib,-lsocket -lnsl))
+		-I$(JDK_TOPDIR)/src/share/npt -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt,C,\
+		-ldl,ws2_32.lib winmm.lib,-lsocket -lnsl,-lpthread))
 
 $(eval $(call SetupJVMTIDemo,minst,			agent_util java_crw_demo))
 $(eval $(call SetupJVMTIDemo,mtrace,			agent_util java_crw_demo))
@@ -298,11 +333,11 @@
 # The number of files are few enough so that we can use echo safely below to list them.
 JPDA_FILES:=$(subst $(JDK_TOPDIR)/src/share/classes/,,$(JPDA_SOURCES))
 
-$(JDK_OUTPUTDIR)/newdemo/jpda/src.zip : $(JPDA_SOURCES)
+$(JDK_OUTPUTDIR)/demo/jpda/src.zip : $(JPDA_SOURCES)
 		$(MKDIR) -p $(@D)
 		(cd $(JDK_TOPDIR)/src/share/classes && $(ZIP) -qru $@ com -i "com/sun/tools/example/*")
 
-$(JDK_OUTPUTDIR)/newdemo/jpda/examples.jar : $(JPDA_SOURCES)
+$(JDK_OUTPUTDIR)/demo/jpda/examples.jar : $(JPDA_SOURCES)
 		$(MKDIR) -p $(@D)
 		$(RM) $(@D)/_the.sources
 		$(call ListPathsSafely,JPDA_FILES,\n, >> $(@D)/_the.sources)
@@ -312,103 +347,104 @@
 		(cd $(JDK_TOPDIR)/src/share/classes && $(JAR) cfm  $@ $(@D)/_the.manifest @$(@D)/_the.sources)
 		(cd $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example && $(JAR) uf $@ README)
 
-$(JDK_OUTPUTDIR)/newdemo/jpda/com/sun/tools/example/README : $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example/README
+$(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README : $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example/README
 		$(MKDIR) -p $(@D)
 		$(CP) $< $@
 		$(CHMOD) -f ug+w $@
 
-BUILD_DEMOS += $(JDK_OUTPUTDIR)/newdemo/jpda/src.zip $(JDK_OUTPUTDIR)/newdemo/jpda/examples.jar \
-		$(JDK_OUTPUTDIR)/newdemo/jpda/com/sun/tools/example/README
+BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jpda/src.zip $(JDK_OUTPUTDIR)/demo/jpda/examples.jar \
+		$(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README
 
 ##################################################################################################
 
-$(JDK_OUTPUTDIR)/newdemo/management/index.html : $(JDK_TOPDIR)/src/share/demo/management/index.html
+$(JDK_OUTPUTDIR)/demo/management/index.html : $(JDK_TOPDIR)/src/share/demo/management/index.html
 		$(MKDIR) -p $(@D)
 		$(CP) $< $@
 		$(CHMOD) -f ug+w $@
 
-$(JDK_OUTPUTDIR)/newdemo/jvmti/index.html : $(JDK_TOPDIR)/src/share/demo/jvmti/index.html
+$(JDK_OUTPUTDIR)/demo/jvmti/index.html : $(JDK_TOPDIR)/src/share/demo/jvmti/index.html
 		$(MKDIR) -p $(@D)
 		$(CP) $< $@
 		$(CHMOD) -f ug+w $@
 
-BUILD_DEMOS += $(JDK_OUTPUTDIR)/newdemo/management/index.html \
-		$(JDK_OUTPUTDIR)/newdemo/jvmti/index.html
+BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/management/index.html \
+		$(JDK_OUTPUTDIR)/demo/jvmti/index.html
 
 ##################################################################################################
 
 # The netbeans project files are copied into the demo directory.
 BUILD_DEMOS += $(patsubst $(JDK_TOPDIR)/src/share/demo/nbproject/%,\
-		$(JDK_OUTPUTDIR)/newdemo/nbproject/%,\
+		$(JDK_OUTPUTDIR)/demo/nbproject/%,\
 		$(shell $(FIND) $(JDK_TOPDIR)/src/share/demo/nbproject/ -type f))
 
-$(JDK_OUTPUTDIR)/newdemo/nbproject/% : $(JDK_TOPDIR)/src/share/demo/nbproject/%
+$(JDK_OUTPUTDIR)/demo/nbproject/% : $(JDK_TOPDIR)/src/share/demo/nbproject/%
 	$(MKDIR) -p $(@D)
 	$(CP) $< $@
 	$(CHMOD) -f ug+w $@
 
 ##################################################################################################
 
-$(JDK_OUTPUTDIR)/newdemo/README: $(JDK_TOPDIR)/src/share/demo/README
+$(JDK_OUTPUTDIR)/demo/README: $(JDK_TOPDIR)/src/share/demo/README
 	$(MKDIR) -p $(@D)
 	$(CP) $< $@
 
-BUILD_DEMOS += $(JDK_OUTPUTDIR)/newdemo/README
+BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/README
 
 ##################################################################################################
 
 ifeq ($(OPENJDK_TARGET_OS), solaris)
 
-$(JDK_OUTPUTDIR)/newdemoclasses/jni/Poller/% : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/%
+$(JDK_OUTPUTDIR)/democlasses/jni/Poller/% : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/%
 		$(MKDIR) -p $(@D)
 		$(CP) $< $@
 		$(CHMOD) -f ug+w $@
 
-$(JDK_OUTPUTDIR)/newdemo/jni/Poller/README.txt : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/README.txt
+$(JDK_OUTPUTDIR)/demo/jni/Poller/README.txt : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/README.txt
 		$(MKDIR) -p $(@D)
 		$(CP) $< $@
 		$(CHMOD) -f ug+w $@
 
-$(JDK_OUTPUTDIR)/newdemo/jni/Poller/Poller.jar : \
-  $(JDK_OUTPUTDIR)/newdemoclasses/jni/Poller/README.txt $(JDK_OUTPUTDIR)/newdemoclasses/jni/Poller/Poller.c
+$(JDK_OUTPUTDIR)/demo/jni/Poller/Poller.jar : \
+  $(JDK_OUTPUTDIR)/democlasses/jni/Poller/README.txt $(JDK_OUTPUTDIR)/democlasses/jni/Poller/Poller.c
 
 $(eval $(call SetupJavaCompilation,BUILD_DEMO_POLLER_JAR,\
 		SETUP:=GENERATE_USINGJDKBYTECODE, \
 		SRC:=$(JDK_TOPDIR)/src/solaris/demo/jni/Poller, \
-		BIN:=$(JDK_OUTPUTDIR)/newdemoclasses/jni/Poller, \
-		HEADERS:=$(JDK_OUTPUTDIR)/newdemoclasses/jni/Poller, \
-		JAR:=$(JDK_OUTPUTDIR)/newdemo/jni/Poller/Poller.jar, \
+		BIN:=$(JDK_OUTPUTDIR)/democlasses/jni/Poller, \
+		HEADERS:=$(JDK_OUTPUTDIR)/democlasses/jni/Poller, \
+		JAR:=$(JDK_OUTPUTDIR)/demo/jni/Poller/Poller.jar, \
 		MANIFEST:=$(JDK_TOPDIR)/make/tools/manifest.mf, \
-		SRCZIP:=$(JDK_OUTPUTDIR)/newdemo/jni/Poller/src.zip, \
-		COPY := README.txt Poller.c, \
-		JARMAIN := Client))
+		SRCZIP:=$(JDK_OUTPUTDIR)/demo/jni/Poller/src.zip, \
+		COPY:=README.txt Poller.c, \
+		JARMAIN:=Client))
 
 
 
-BUILD_DEMOS += $(JDK_OUTPUTDIR)/newdemo/jni/Poller/Poller.jar $(JDK_OUTPUTDIR)/newdemo/jni/Poller/src.zip \
-               $(JDK_OUTPUTDIR)/newdemo/jni/Poller/README.txt
+BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jni/Poller/Poller.jar $(JDK_OUTPUTDIR)/demo/jni/Poller/src.zip \
+               $(JDK_OUTPUTDIR)/demo/jni/Poller/README.txt
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBPOLLER,\
 		SRC:=$(JDK_TOPDIR)/src/solaris/demo/jni/Poller, \
-		LANG := C, \
-		CFLAGS:=$(CFLAGS_JDKLIB) $(C_O_FLAG_NORM) $(SHARED_LIBRARY_FLAGS) \
-                        -I$(JDK_OUTPUTDIR)/newdemoclasses/jni/Poller, \
+		LANG:=C,\
+		OPTIMIZATION:=LOW,\
+		CFLAGS:=$(CFLAGS_JDKLIB) $(SHARED_LIBRARY_FLAGS) \
+                        -I$(JDK_OUTPUTDIR)/democlasses/jni/Poller, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB), \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/newdemoobjs/jni/Poller,\
-                OUTPUT_DIR:=$(JDK_OUTPUTDIR)/newdemoobjs, \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/demoobjs/jni/Poller,\
+                OUTPUT_DIR:=$(JDK_OUTPUTDIR)/demoobjs, \
 		LIBRARY:=Poller))
 
 #
 # We can only compile native code after jar has been build (since we depend on generated .h files)
 #
-$(JDK_OUTPUTDIR)/newdemoobjs/jni/Poller/Poller.o : $(JDK_OUTPUTDIR)/newdemo/jni/Poller/Poller.jar
+$(JDK_OUTPUTDIR)/demoobjs/jni/Poller/Poller.o : $(JDK_OUTPUTDIR)/demo/jni/Poller/Poller.jar
 
-$(JDK_OUTPUTDIR)/newdemo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX) : \
-  $(JDK_OUTPUTDIR)/newdemoobjs/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX)
+$(JDK_OUTPUTDIR)/demo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX) : \
+  $(JDK_OUTPUTDIR)/demoobjs/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX)
 	$(MKDIR) -p $(@D)
 	$(CP) $< $@
 
-BUILD_DEMOS += $(JDK_OUTPUTDIR)/newdemo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX)
+BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX)
 
 endif
 
@@ -417,20 +453,20 @@
 ifndef OPENJDK
     DB_DEMO_ZIPFILE := $(shell $(FIND) $(JDK_TOPDIR)/src/closed/share/db -name "*demo*.zip")
 
-    $(JDK_OUTPUTDIR)/newdemo/_the.db.unzipped: $(DB_DEMO_ZIPFILE)
+    $(JDK_OUTPUTDIR)/demo/_the.db.unzipped: $(DB_DEMO_ZIPFILE)
 	$(MKDIR) -p $(@D)
-	$(RM) -rf $(JDK_OUTPUTDIR)/newdemo/db $(JDK_OUTPUTDIR)/newdemo/demo
-	$(CD) $(JDK_OUTPUTDIR)/newdemo && $(UNZIP) -o $<
-	$(MV) $(JDK_OUTPUTDIR)/newdemo/demo $(JDK_OUTPUTDIR)/newdemo/db
+	$(RM) -r $(JDK_OUTPUTDIR)/demo/db $(JDK_OUTPUTDIR)/demo/demo
+	$(CD) $(JDK_OUTPUTDIR)/demo && $(UNZIP) -o $<
+	$(MV) $(JDK_OUTPUTDIR)/demo/demo $(JDK_OUTPUTDIR)/demo/db
 	$(TOUCH) $@
 
 #    Copy this after the unzip above to avoid race with directory creation and mv command.
-     $(JDK_OUTPUTDIR)/newdemo/db/README-JDK-DEMOS.html: \
+     $(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html: \
 		$(JDK_TOPDIR)/src/closed/share/db/README-JDK-DEMOS.html \
-		| $(JDK_OUTPUTDIR)/newdemo/_the.db.unzipped
+		| $(JDK_OUTPUTDIR)/demo/_the.db.unzipped
 	$(MKDIR) -p $(@D)
 	$(CP) '$<' '$@'
-     BUILD_DEMOS += $(JDK_OUTPUTDIR)/newdemo/_the.db.unzipped $(JDK_OUTPUTDIR)/newdemo/db/README-JDK-DEMOS.html
+     BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/_the.db.unzipped $(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html
 endif
 
 ##################################################################################################
--- a/jdk/makefiles/CompileJavaClasses.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/CompileJavaClasses.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -45,10 +45,6 @@
 		com/sun/tools/example/debug/gui \
 		com/oracle/security
 
-ifeq ($(OPENJDK_TARGET_OS)-$(ARCH_DATA_MODEL),windows-64)
-     EXCLUDES += sun/security/pkcs11
-endif
-
 ifdef OPENJDK
     EXCLUDES+=	sun/dc \
 		com/sun/jmx/snmp \
@@ -59,6 +55,13 @@
 ifndef OPENJDK
    # There exists two versions of this file...
    EXFILES := $(JDK_TOPDIR)/src/share/classes/javax/crypto/JarVerifier.java
+
+   ifeq ($(OPENJDK_TARGET_OS),windows)
+      # This gets built on unix platforms implicitly in the old build even though
+      # it's excluded in the closed build.
+      EXCLUDES+=sun/java2d/pisces
+   endif
+
 endif
 
 ifneq ($(OPENJDK_TARGET_OS),solaris)
@@ -90,12 +93,14 @@
     # Exclude Window security related files in src/share/classes
     EXFILES+=NTLoginModule.java \
              NTSystem.java
-
+else
+    EXFILES+=UnixLoginModule.java \
+	     UnixSystem.java
 endif
 
 ifeq ($(OPENJDK_TARGET_OS),windows)
     # Don't build GTK L&F on Windows
-    EXCLUDES+=	com/sun/java/swing/plaf/gtk
+    EXCLUDES+=com/sun/java/swing/plaf/gtk
 endif
 
 ifneq ($(OPENJDK_TARGET_OS),linux)
@@ -115,6 +120,9 @@
 	     sun/nio/fs/BsdFileSystem.java \
              sun/nio/fs/BsdFileSystemProvider.java \
              sun/nio/fs/BsdNativeDispatcher.java \
+             sun/nio/fs/MacOSXFileSystemProvider.java \
+             sun/nio/fs/MacOSXFileSystem.java \
+             sun/nio/fs/MacOSXNativeDispatcher.java \
              sun/tools/attach/BsdAttachProvider.java \
              sun/tools/attach/BsdVirtualMachine.java
 endif
@@ -122,7 +130,7 @@
 # Exclude BreakIterator classes that are just used in compile process to generate
 # data files and shouldn't go in the product
 EXFILES+=sun/text/resources/BreakIteratorRules.java \
-	sun/text/resources/BreakIteratorRules_th.java
+	 sun/text/resources/BreakIteratorRules_th.java
 
 # TODO: Add BUILD_HEADLESS_ONLY to configure?
 ifdef BUILD_HEADLESS_ONLY
@@ -245,7 +253,7 @@
 
 ifndef OPENJDK
     CLOSED_SRC_DIRS:=$(JDK_TOPDIR)/src/closed/share/classes \
-		     $(JDK_TOPDIR)/src/closed/$(LEGACY_OPENJDK_TARGET_OS_API)/classes
+		     $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS_API_DIR)/classes
 endif
 
 MACOSX_SRC_DIRS :=
@@ -257,7 +265,8 @@
                $(JDK_TOPDIR)/src/solaris/classes/sun/java2d/BackBufferCapsProvider.java \
                $(JDK_TOPDIR)/src/solaris/classes/java/net/DefaultInterface.java \
                $(JDK_TOPDIR)/src/solaris/classes/java/lang/ClassLoaderHelper.java \
-               $(JDK_TOPDIR)/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
+               $(JDK_TOPDIR)/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java \
+               $(JDK_TOPDIR)/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java
 
      # JObjC.jar contains 1.5 byte-code...so skip it here :-(
      # MACOSX_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/native/jobjc/src
@@ -273,14 +282,21 @@
 	$(MKDIR) -p $(@D)
 	$(CP) $< $@
 
+# The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying
+# JDK_FILTER at the make command line, only a subset of the JDK java files will
+# be recompiled. If multiple paths are separated by comma, convert that into a
+# space separated list.
+JDK_USER_DEFINED_FILTER:=$(strip $(subst $(COMMA),$(SPACE),$(JDK_FILTER)))
+
 $(eval $(call SetupJavaCompilation,BUILD_JDK,\
                 SETUP:=GENERATE_JDKBYTECODE,\
 		SRC:=$(JDK_TOPDIR)/src/share/classes \
-		     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes \
+		     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes \
 		     $(MACOSX_SRC_DIRS) \
 		     $(JDK_OUTPUTDIR)/gensrc \
 		     $(JDK_OUTPUTDIR)/gensrc_swing/javax/swing/beaninfo \
 		     $(CLOSED_SRC_DIRS),\
+		INCLUDES:=$(JDK_USER_DEFINED_FILTER),\
 		EXCLUDES:=$(EXCLUDES),\
 		EXCLUDE_FILES:=$(EXFILES),\
 		BIN:=$(JDK_OUTPUTDIR)/classes,\
@@ -360,13 +376,12 @@
 $(eval $(call SetupJavaCompiler,GENERATE_15BYTECODE,\
      JAVAC:=$(JAVAC),\
      FLAGS:=-source 1.5 -target 1.5 -g -bootclasspath $(BOOT_RTJAR) -cp $(JDK_OUTPUTDIR)/../langtools/dist/lib/classes.jar $(DISABLE_WARNINGS),\
-     SERVER_DIR:=$(JAVAC_SERVERS),\
-     SERVER_JVM:=$(SERVER_JAVA),\
-     MODE:=$(JAVAC_USE_MODE),\
-     USE_DEPS:=$(JAVAC_USE_DEPS)))
+     SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+     SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
 
 $(eval $(call SetupJavaCompilation,BUILD_JOBJC_JAR,\
 		SETUP:=GENERATE_15BYTECODE,\
+		DISABLE_SJAVAC:=true,\
 		SRC:=$(JDK_TOPDIR)/src/macosx/native/jobjc/src/core/java \
 		     $(JDK_TOPDIR)/src/macosx/native/jobjc/src/runtime-additions/java \
 		     $(JDK_OUTPUTDIR)/gensrc, \
--- a/jdk/makefiles/CompileLaunchers.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/CompileLaunchers.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -1,511 +1,557 @@
-#
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  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.
-#
-
-defalt: all
-
-include $(SPEC)
-include MakeBase.gmk
-include NativeCompilation.gmk
-
-# Setup the java compilers for the JDK build.
-include Setup.gmk
-
-# Build tools
-include Tools.gmk
-
-BUILD_LAUNCHERS=
-
-define SetupLauncher
-    # TODO: Fix mapfile on solaris. Won't work with ld as linker.
-    # Parameter 1 is the name of the launcher (java,javac,jar...)
-    # Parameter 2 is extra CFLAGS
-    # Parameter 3 is extra LDFLAGS
-    # Parameter 4 is extra LDFLAGS_SUFFIX_posix
-    # Parameter 5 is extra LDFLAGS_SUFFIX_winapi
-    # Parameter 6 is optional Windows JLI library (full path)
-    # Parameter 7 is optional Windows resource (RC) flags
-    # Parameter 8 is optional Windows version resource file (.rc)
-    # Parameter 9  is different output dir
-    # Parameter 10 is FULL DEBUG SYMBOLS (set value to turn OFF, since most(all) seems to have it)
-
-    $1_WINDOWS_JLI_LIB:=$(JDK_OUTPUTDIR)/objs/libjli/jli.lib
-    ifneq ($6,)
-        $1_WINDOWS_JLI_LIB:=$6
-    endif
-    $1_VERSION_INFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc
-    ifneq ($8,)
-        $1_VERSION_INFO_RESOURCE:=$8
-    endif
-
-    $1_LDFLAGS := $3
-    ifeq ($(OPENJDK_TARGET_OS), macosx)
-        $1_LDFLAGS += -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-                       -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks
-    endif
-
-    $1_LDFLAGS_SUFFIX :=
-    ifeq ($(USE_EXTERNAL_LIBZ), true)
-        $1_LDFLAGS_SUFFIX += -lz
-    endif
-
-    ifeq ($(OPENJDK_TARGET_OS), macosx)
-        $1_LDFLAGS_SUFFIX += -Wl,-all_load $(JDK_OUTPUTDIR)/objs/libjli_static.a \
-                             -framework Cocoa -framework Security -framework ApplicationServices \
-                             -sectcreate __TEXT __info_plist $(JDK_TOPDIR)/src/macosx/lib/Info-cmdline.plist
-    endif
-
-
-    $1_OUTPUT_DIR_ARG:=$9
-    ifeq (,$$($1_OUTPUT_DIR_ARG))
-        $1_OUTPUT_DIR_ARG:=$(JDK_OUTPUTDIR)/bin
-    endif
-
-    $1_DEBUG_SYMBOLS:=yes
-    ifneq (,$(10))
-      $1_DEBUG_SYMBOLS:=
-    endif
-
-    $1_OPTIMIZATION:= LOW
-
-    # TODO: maybe it's better to move this if-statement out of this function
-    ifeq ($(1),java)
-      $1_OPTIMIZATION:=HIGH
-    endif
-
-    $(call SetupNativeCompilation,BUILD_LAUNCHER_$1,\
-	SRC:=$(JDK_TOPDIR)/src/share/bin,\
-	INCLUDE_FILES:=main.c,\
-	LANG:=C,\
-	OPTIMIZATION :=$$($1_OPTIMIZATION), \
-	CFLAGS:=$(CFLAGS_JDKEXE) \
-		-I$(JDK_TOPDIR)/src/share/bin \
-		-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/bin \
-		-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS)/bin \
-                -DFULL_VERSION='"$(FULL_VERSION)"' \
-                -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
-                -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' \
-		-DLIBARCHNAME='"$(ARCH)"' \
-		-DLAUNCHER_NAME='"java"' \
-		-DPROGNAME='"$1"' $(DPACKAGEPATH) \
-		$2,\
-	CFLAGS_linux:=-fPIC,\
-        CFLAGS_solaris:=-KPIC -DHAVE_GETHRTIME,\
-	LDFLAGS:=$(LDFLAGS_JDKEXE) \
-                 $(call SET_SHARED_LIBRARY_ORIGIN,../lib/$(LIBARCH)/jli) \
-                 $(call SET_SHARED_LIBRARY_ORIGIN,../jre/lib/$(LIBARCH)/jli) \
-		 $$($1_LDFLAGS),\
-	MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/launchers/mapfile-$(ARCH), \
-        LDFLAGS_SUFFIX:=$(LDFLAGS_JDKEXE_SUFFIX) $$($1_LDFLAGS_SUFFIX),\
-	LDFLAGS_SUFFIX_posix:=$4 -lc,\
-	LDFLAGS_SUFFIX_winapi:=$$($1_WINDOWS_JLI_LIB) \
-			       $(JDK_OUTPUTDIR)/objs/libjava/java.lib advapi32.lib $5,\
-	LDFLAGS_SUFFIX_solaris := -lthread $(LIBDL), \
-	OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/$1_objs,\
-	OUTPUT_DIR:=$$($1_OUTPUT_DIR_ARG),\
-	PROGRAM:=$1,\
-	DEBUG_SYMBOLS:=$$($1_DEBUG_SYMBOLS),\
-	VERSIONINFO_RESOURCE:=$$($1_VERSION_INFO_RESOURCE),\
-	RC_FLAGS:=$(RC_FLAGS)\
-		  /D "JDK_FNAME=$1$(EXE_SUFFIX)" \
-		  /D "JDK_INTERNAL_NAME=$1" \
-		  /D "JDK_FTYPE=0x1L" \
-		  $7,\
-	MANIFEST:=$(JDK_TOPDIR)/src/windows/resource/java.manifest)
-
-    BUILD_LAUNCHERS += $$(BUILD_LAUNCHER_$1)
-
-    ifeq ($(OPENJDK_TARGET_OS),macosx)
-        $$(BUILD_LAUNCHER_$1) : $(JDK_OUTPUTDIR)/objs/libjli_static.a
-    endif
-
-    ifeq ($(OPENJDK_TARGET_OS),windows)
-        $$(BUILD_LAUNCHER_$1) : $(JDK_OUTPUTDIR)/objs/libjava/java.lib \
-				$$($1_WINDOWS_JLI_LIB)
-    endif    	 
-endef
-
-##########################################################################################
-
-XLIBS:=$(X_LIBS) -lX11
-ifeq ($(OPENJDK_TARGET_OS),macosx)
-    DPACKAGEPATH:=-DPACKAGE_PATH='"$(PACKAGE_PATH)"'
-    XLIBS:=
-endif
-
-ifdef OPENJDK
-    JAVA_RC_FLAGS += -i "$(JDK_TOPDIR)/src/windows/resource/icons"
-else
-    JAVA_RC_FLAGS += -i "$(JDK_TOPDIR)/src/closed/windows/native/sun/windows"
-endif
-
-$(eval $(call SetupLauncher,java,\
-    -DEXPAND_CLASSPATH_WILDCARDS,,,user32.lib comctl32.lib,\
-    $(JDK_OUTPUTDIR)/objs/jli_static.lib,$(JAVA_RC_FLAGS),\
-    $(JDK_TOPDIR)/src/windows/resource/java.rc))
-
-ifeq ($(OPENJDK_TARGET_OS),windows)
-    $(eval $(call SetupLauncher,javaw,\
-        -DEXPAND_CLASSPATH_WILDCARDS,,,user32.lib comctl32.lib,\
-        $(JDK_OUTPUTDIR)/objs/jli_static.lib,$(JAVA_RC_FLAGS),\
-        $(JDK_TOPDIR)/src/windows/resource/java.rc))
-endif
-
-ifeq ($(OPENJDK_TARGET_OS),solaris)
-    THREAD_LIB:=-lthread
-endif
-ifeq ($(OPENJDK_TARGET_OS),linux)
-    THREAD_LIB:=-lpthread
-endif
-
-ifndef BUILD_HEADLESS_ONLY
-$(eval $(call SetupLauncher,appletviewer,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.applet.Main"$(COMMA) }',,\
-    $(THREAD_LIB) $(XLIBS) -ldl))
-endif
-
-$(eval $(call SetupLauncher,extcheck,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.extcheck.Main"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,idlj,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.corba.se.idl.toJavaPortable.Compile"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,jar,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jar.Main"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,jarsigner,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.JarSigner"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,javac,\
-    -DEXPAND_CLASSPATH_WILDCARDS \
-    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javac.Main"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,javadoc,\
-    -DEXPAND_CLASSPATH_WILDCARDS \
-    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javadoc.Main"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,javah,\
-    -DEXPAND_CLASSPATH_WILDCARDS \
-    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javah.Main"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,javap,\
-    -DEXPAND_CLASSPATH_WILDCARDS \
-    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javap.Main"$(COMMA) }'))
-
-BUILD_LAUNCHER_jconsole_CPPFLAGS_windows:=-DJAVAW
-BUILD_LAUNCHER_jconsole_LDFLAGS_windows:=user32.lib
-
-$(eval $(call SetupLauncher,jconsole,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "-J-Djconsole.showOutputViewer"$(COMMA) "sun.tools.jconsole.JConsole"$(COMMA) }' \
-    -DAPP_CLASSPATH='{ "/lib/jconsole.jar"$(COMMA) "/lib/tools.jar"$(COMMA) "/classes" }'))
-
-$(eval $(call SetupLauncher,jdb,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.example.debug.tty.TTY"$(COMMA) }' \
-    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }'))
-
-$(eval $(call SetupLauncher,jhat,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.hat.Main"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,jinfo,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) \
-		   "-J-Dsun.jvm.hotspot.debugger.useProcDebugger"$(COMMA) \
-		   "-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger"$(COMMA) \
-		   "sun.tools.jinfo.JInfo"$(COMMA) }' \
-    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }'))
-
-$(eval $(call SetupLauncher,jmap,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) \
-		   "-J-Dsun.jvm.hotspot.debugger.useProcDebugger"$(COMMA) \
-		   "-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger"$(COMMA) \
-		   "sun.tools.jmap.JMap"$(COMMA) }' \
-    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }'))
-
-$(eval $(call SetupLauncher,jps,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jps.Jps"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,jrunscript,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.script.shell.Main"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,jsadebugd,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.jvm.hotspot.jdi.SADebugServer"$(COMMA) }' \
-    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }'))
-
-$(eval $(call SetupLauncher,jstack,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) \
-		   "-J-Dsun.jvm.hotspot.debugger.useProcDebugger"$(COMMA) \
-		   "-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger"$(COMMA) \
-		   "sun.tools.jstack.JStack"$(COMMA) }' \
-    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }'))
-
-$(eval $(call SetupLauncher,jstat,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jstat.Jstat"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,jstatd,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jstatd.Jstatd"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,keytool,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.KeyTool"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,native2ascii,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.native2ascii.Main"$(COMMA) }'))
-
-ifndef BUILD_HEADLESS_ONLY
-$(eval $(call SetupLauncher,policytool,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.policytool.PolicyTool"$(COMMA) }'))
-endif
-
-$(eval $(call SetupLauncher,rmic,\
-    -DEXPAND_CLASSPATH_WILDCARDS \
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.rmi.rmic.Main"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,schemagen,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.jxc.SchemaGenerator"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,serialver,\
-    -DEXPAND_CLASSPATH_WILDCARDS \
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.serialver.SerialVer"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,xjc,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.xjc.Driver"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,wsgen,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.ws.WsGen"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,wsimport,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.ws.WsImport"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,orbd,\
-    -DJAVA_ARGS='{ 	"-J-ms8m"$(COMMA) \
-			"-J-Dcom.sun.CORBA.activation.DbDir=./orb.db"$(COMMA) \
-			"-J-Dcom.sun.CORBA.activation.Port=1049"$(COMMA) \
-			"-J-Dcom.sun.CORBA.POA.ORBServerId=1"$(COMMA) \
-			"com.sun.corba.se.impl.activation.ORBD"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,servertool,\
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.corba.se.impl.activation.ServerTool"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,tnameserv,\
-    -DJAVA_ARGS='{ 	"-J-ms8m"$(COMMA) \
-			"-J-Dcom.sun.CORBA.activation.DbDir=./orb.db"$(COMMA) \
-			"-J-Djava.util.logging.LoggingPermission=contol"$(COMMA) \
-			"-J-Dcom.sun.CORBA.POA.ORBServerId=1"$(COMMA) \
-			"com.sun.corba.se.impl.naming.cosnaming.TransientNameServer"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,pack200,\
-    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "com.sun.java.util.jar.pack.Driver"$(COMMA) "--pack" }'))
-
-$(eval $(call SetupLauncher,rmid,\
-    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.rmi.server.Activation"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,rmiregistry,\
-    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.rmi.registry.RegistryImpl"$(COMMA) }'))
-
-$(eval $(call SetupLauncher,jcmd,\
-    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.tools.jcmd.JCmd"$(COMMA) }'))
-
-ifeq ($(OPENJDK_TARGET_OS),windows)
-    $(eval $(call SetupLauncher,kinit,\
-        -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.security.krb5.internal.tools.Kinit"$(COMMA) }'))
-
-    $(eval $(call SetupLauncher,klist,\
-        -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.security.krb5.internal.tools.Klist"$(COMMA) }'))
-
-    $(eval $(call SetupLauncher,ktab,\
-        -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.security.krb5.internal.tools.Ktab"$(COMMA) }'))
-endif
-
-##########################################################################################
-# The order of the object files on the link command line affects the size of the resulting
-# binary (at least on linux) which causes the size to differ between old and new build.
-ifeq ($(USE_EXTERNAL_LIBZ), true)
-UNPACKEXE_CFLAGS := -DSYSTEM_ZLIB
-UNPACKEXE_ZIPOBJS := -lz
-else
-UNPACKEXE_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
-UNPACKEXE_ZIPOBJS := 	$(JDK_OUTPUTDIR)/objs/libzip/zcrc32$(OBJ_SUFFIX) \
-		     	$(JDK_OUTPUTDIR)/objs/libzip/deflate$(OBJ_SUFFIX) \
-			$(JDK_OUTPUTDIR)/objs/libzip/trees$(OBJ_SUFFIX) \
-			$(JDK_OUTPUTDIR)/objs/libzip/zadler32$(OBJ_SUFFIX) \
-			$(JDK_OUTPUTDIR)/objs/libzip/compress$(OBJ_SUFFIX) \
-			$(JDK_OUTPUTDIR)/objs/libzip/zutil$(OBJ_SUFFIX) \
-			$(JDK_OUTPUTDIR)/objs/libzip/inflate$(OBJ_SUFFIX) \
-			$(JDK_OUTPUTDIR)/objs/libzip/infback$(OBJ_SUFFIX) \
-			$(JDK_OUTPUTDIR)/objs/libzip/inftrees$(OBJ_SUFFIX) \
-			$(JDK_OUTPUTDIR)/objs/libzip/inffast$(OBJ_SUFFIX)
-
-endif
-
-ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
-     UNPACKEXE_CFLAGS += -xregs=no%appl
-endif
-
-$(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE,\
-                SRC:=$(JDK_TOPDIR)/src/share/native/com/sun/java/util/jar/pack,\
-		EXCLUDE_FILES:=jni.cpp,\
-		LANG:=C,\
-		OPTIMIZATION := LOW, \
-		CFLAGS:=$(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE)\
-			 -DFULL, \
-		CFLAGS_release:=-DPRODUCT,\
-		CFLAGS_linux:=-fPIC,\
-		CFLAGS_solaris := -KPIC, \
-		CFLAGS_macosx := -fPIC, \
-		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libunpack/mapfile-vers-unpack200, \
-		LDFLAGS:=$(LDFLAGS_JDKEXE) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX:=$(UNPACKEXE_ZIPOBJS) $(LIBCXX),\
-		LDFLAGS_SUFFIX_solaris:=-lc,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/unpackexe,\
-		OUTPUT_DIR:=$(JDK_OUTPUTDIR)/bin,\
-		PROGRAM:=unpack200,\
-		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
-		RC_FLAGS:=$(RC_FLAGS)\
-			  /D "JDK_FNAME=unpack200.exe" \
-			  /D "JDK_INTERNAL_NAME=unpack200" \
-			  /D "JDK_FTYPE=0x1L",\
-		MANIFEST:=$(JDK_TOPDIR)/src/windows/resource/unpack200_proto.exe.manifest))
-
-ifneq ($(USE_EXTERNAL_LIBZ), true)
-
-$(BUILD_UNPACKEXE) : $(UNPACKEXE_ZIPOBJS)
-
-endif
-
-BUILD_LAUNCHERS += $(BUILD_UNPACKEXE)
-
-##########################################################################################
-
-
-BUILD_JEXEC := 
-BUILD_JEXEC_SRC :=
-BUILD_JEXEC_INC :=
-BUILD_JEXEC_DST_DIR := $(JDK_OUTPUTDIR)/lib/$(LIBARCH)
-
-#
-# UNHANDLED:
-# - COMPILE_APPROACH = normal
-#
-
-#
-# jdk/make/java/Makefile
-#
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-	ifeq ($(ARCH_DATA_MODEL), 32)
-		BUILD_JEXEC := 1
-	endif
-endif
-
-ifeq ($(OPENJDK_TARGET_OS), linux)
-	BUILD_JEXEC := 1
-endif # OPENJDK_TARGET_OS
-
-#
-# jdk/make/java/jexec/Makefile
-#
-ifeq ($(BUILD_JEXEC), 1)
-
-	ifeq ($(OPENJDK_TARGET_OS),windows)
-	else ifeq ($(OPENJDK_TARGET_OS),macosx)
-		BUILD_JEXEC_SRC := $(JDK_TOPDIR)/src/macosx/bin
-	else
-		BUILD_JEXEC_SRC := $(JDK_TOPDIR)/src/solaris/bin
-	endif
-
-	ifeq ($(OPENJDK_TARGET_OS), linux)
-                BUILD_JEXEC_DST_DIR := $(JDK_OUTPUTDIR)/lib
-		BUILD_JEXEC_INC += -I$(JDK_TOPDIR)/src/share/bin
-	endif
-endif
-
-#
-# Note that the two Makefile's seems to contradict each other,
-#   and that src/macosx/bin/jexec.c seems unused
-#
-ifneq ($(BUILD_JEXEC_SRC),)
-        $(eval $(call SetupNativeCompilation,BUILD_JEXEC,\
-		SRC:=$(BUILD_JEXEC_SRC),\
-		INCLUDE_FILES:=jexec.c,\
-		LANG:=C,\
-		OPTIMIZATION := LOW, \
-		CFLAGS:=$(CFLAGS_JDKEXE)\
-                        $(BUILD_JEXEC_INC), \
-		LDFLAGS:=$(LDFLAGS_JDKEXE), \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/jexec_obj,\
-		OUTPUT_DIR:=$(BUILD_JEXEC_DST_DIR),\
-		PROGRAM:=jexec))
-
-	BUILD_LAUNCHERS += $(BUILD_JEXEC)
-endif
-
-##########################################################################################
-
-#
-# The java-rmi.cgi script in bin/ only gets delivered in certain situations
-#
-JAVA_RMI_CGI:=$(JDK_OUTPUTDIR)/bin/java-rmi.cgi
-ifeq ($(OPENJDK_TARGET_OS), linux)
-  BUILD_LAUNCHERS += $(JAVA_RMI_CGI)
-endif
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    BUILD_LAUNCHERS += $(JAVA_RMI_CGI)
-  endif
-endif
-
-# TODO: 
-# On windows java-rmi.cgi shouldn't be bundled since Java 1.2, but has been built all
-# this time anyway. Since jdk6, it has been built from the wrong source and resulted
-# in a copy of the standard java launcher named "java-rmi.exe" ending up in the final
-# images bin dir. This weird behavior is mimicked here in the converted makefiles for
-# now. Should probably just be deleted.
-# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6512052
-ifeq ($(OPENJDK_TARGET_OS_API),winapi)
-    $(eval $(call SetupLauncher,java-rmi,\
-        -DEXPAND_CLASSPATH_WILDCARDS,\
-        $(call SET_SHARED_LIBRARY_MAPFILE,$(JDK_TOPDIR)/makefiles/java/main/java/mapfile-$(ARCH)),\
-        ,,,,,$(JDK_OUTPUTDIR)/objs))
-
-    $(JAVA_RMI_CGI): $(BUILD_LAUNCHER_java-rmi)
-	$(MKDIR) -p $(@D)
-	$(CP) $< $@
-
-    BUILD_LAUNCHERS += $(JAVA_RMI_CGI)
-else
-    $(JAVA_RMI_CGI): $(JDK_TOPDIR)/src/solaris/bin/java-rmi.cgi.sh
-	$(MKDIR) -p $(@D)
-	$(CP) $< $@
-	$(CHMOD) a+x $@
-endif
-
-##########################################################################################
-
-$(BUILD_LAUNCHERS) : $(JDK_TOPDIR)/makefiles/CompileLaunchers.gmk
-
-all: $(BUILD_LAUNCHERS)
-
-.PHONY: all
+#
+# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  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.
+#
+
+defalt: all
+
+include $(SPEC)
+include MakeBase.gmk
+include NativeCompilation.gmk
+
+# Setup the java compilers for the JDK build.
+include Setup.gmk
+
+# Build tools
+include Tools.gmk
+
+BUILD_LAUNCHERS=
+
+# When building a legacy overlay image (on solaris 64 bit), the launchers 
+# need to be built with a different rpath and a different output dir.
+ifeq ($(OVERLAY_IMAGES),true)
+    ORIGIN_ROOT:=/../..
+    OUTPUT_SUBDIR:=$(OPENJDK_TARGET_CPU_ISADIR)
+else
+    ORIGIN_ROOT:=/..
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+    ORIGIN_ARG:=$(call SET_EXECUTABLE_ORIGIN)
+else
+    ORIGIN_ARG:=$(call SET_EXECUTABLE_ORIGIN,$(ORIGIN_ROOT)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli) \
+                $(call SET_EXECUTABLE_ORIGIN,$(ORIGIN_ROOT)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli)
+endif
+
+#
+# Applications expect to be able to link against libjawt without invoking
+# System.loadLibrary("jawt") first. This was the behaviour described in the
+# devloper documentation of JAWT and what worked with OpenJDK6.
+#
+ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris),)
+    ORIGIN_ARG+=$(call SET_EXECUTABLE_ORIGIN,$(ORIGIN_ROOT)/lib$(OPENJDK_TARGET_CPU_LIBDIR)) \
+                $(call SET_EXECUTABLE_ORIGIN,$(ORIGIN_ROOT)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)) 
+endif
+
+define SetupLauncher
+    # TODO: Fix mapfile on solaris. Won't work with ld as linker.
+    # Parameter 1 is the name of the launcher (java,javac,jar...)
+    # Parameter 2 is extra CFLAGS
+    # Parameter 3 is extra LDFLAGS
+    # Parameter 4 is extra LDFLAGS_SUFFIX_posix
+    # Parameter 5 is extra LDFLAGS_SUFFIX_windows
+    # Parameter 6 is optional Windows JLI library (full path)
+    # Parameter 7 is optional Windows resource (RC) flags
+    # Parameter 8 is optional Windows version resource file (.rc)
+    # Parameter 9  is different output dir
+    # Parameter 10 if set, link statically with c runtime on windows.
+    # Parameter 11 if set, override plist file on macosx.
+
+    $1_WINDOWS_JLI_LIB:=$(JDK_OUTPUTDIR)/objs/libjli/jli.lib
+    ifneq ($6,)
+        $1_WINDOWS_JLI_LIB:=$6
+    endif
+    $1_VERSION_INFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc
+    ifneq ($8,)
+        $1_VERSION_INFO_RESOURCE:=$8
+    endif
+
+    $1_LDFLAGS := $3
+    $1_LDFLAGS_SUFFIX :=
+    ifeq ($(OPENJDK_TARGET_OS), macosx)
+        $1_PLIST_FILE:=Info-cmdline.plist
+        ifneq ($(11),)
+            $1_PLIST_FILE:=$(11)
+        endif
+
+        $1_LDFLAGS += -Wl,-all_load $(JDK_OUTPUTDIR)/objs/libjli_static.a \
+                      -framework Cocoa -framework Security -framework ApplicationServices \
+                      -sectcreate __TEXT __info_plist $(JDK_TOPDIR)/src/macosx/lib/$$($1_PLIST_FILE)
+        $1_LDFLAGS_SUFFIX += -pthread
+    endif
+
+    ifeq ($(USE_EXTERNAL_LIBZ), true)
+        $1_LDFLAGS_SUFFIX += -lz
+    endif
+
+    $1_OUTPUT_DIR_ARG:=$9
+    ifeq (,$$($1_OUTPUT_DIR_ARG))
+        $1_OUTPUT_DIR_ARG:=$(JDK_OUTPUTDIR)/bin
+    endif
+
+    # TODO: maybe it's better to move this if-statement out of this function
+    ifeq ($1,java)
+        $1_OPTIMIZATION_ARG:=HIGH
+	$1_LDFLAGS_solaris:=-R$(OPENWIN_HOME)/lib$(OPENJDK_TARGET_CPU_ISADIR)
+    else
+        $1_OPTIMIZATION_ARG:=LOW
+    endif
+
+    $1_CFLAGS:=$(CFLAGS_JDKEXE)
+    ifeq ($(10),true)
+        $1_CFLAGS:=$(filter-out -MD,$(CFLAGS_JDKEXE))
+    endif
+
+    $(call SetupNativeCompilation,BUILD_LAUNCHER_$1,\
+	SRC:=$(JDK_TOPDIR)/src/share/bin,\
+	INCLUDE_FILES:=main.c,\
+	LANG:=C,\
+	OPTIMIZATION:=$$($1_OPTIMIZATION_ARG), \
+	CFLAGS:=$$($1_CFLAGS) \
+		-I$(JDK_TOPDIR)/src/share/bin \
+		-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin \
+		-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS)/bin \
+                -DFULL_VERSION='"$(FULL_VERSION)"' \
+                -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
+                -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' \
+		-DLIBARCHNAME='"$(OPENJDK_TARGET_CPU_LEGACY)"' \
+		-DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \
+		-DPROGNAME='"$1"' $(DPACKAGEPATH) \
+		$2,\
+	CFLAGS_linux:=-fPIC,\
+        CFLAGS_solaris:=-KPIC -DHAVE_GETHRTIME,\
+	LDFLAGS:=$(LDFLAGS_JDKEXE) \
+                 $(ORIGIN_ARG) \
+		 $$($1_LDFLAGS),\
+	LDFLAGS_macosx:=$(call SET_SHARED_LIBRARY_NAME,$1),\
+	LDFLAGS_linux:=-lpthread \
+                       $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)),\
+	LDFLAGS_solaris:=$$($1_LDFLAGS_solaris) \
+                       $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)),\
+	MAPFILE := $(JDK_TOPDIR)/makefiles/mapfiles/launchers/mapfile-$(OPENJDK_TARGET_CPU), \
+        LDFLAGS_SUFFIX:=$(LDFLAGS_JDKEXE_SUFFIX) $$($1_LDFLAGS_SUFFIX),\
+	LDFLAGS_SUFFIX_posix:=$4,\
+	LDFLAGS_SUFFIX_windows:=$$($1_WINDOWS_JLI_LIB) \
+			       $(JDK_OUTPUTDIR)/objs/libjava/java.lib advapi32.lib $5,\
+	LDFLAGS_SUFFIX_linux:=-L$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli -ljli $(LIBDL) -lc, \
+	LDFLAGS_SUFFIX_solaris:=-L$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli -ljli -lthread $(LIBDL) -lc, \
+	OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/$1_objs$(OUTPUT_SUBDIR),\
+	OUTPUT_DIR:=$$($1_OUTPUT_DIR_ARG)$(OUTPUT_SUBDIR),\
+	PROGRAM:=$1,\
+	DEBUG_SYMBOLS:=true,\
+	VERSIONINFO_RESOURCE:=$$($1_VERSION_INFO_RESOURCE),\
+	RC_FLAGS:=$(RC_FLAGS)\
+		  /D "JDK_FNAME=$1$(EXE_SUFFIX)" \
+		  /D "JDK_INTERNAL_NAME=$1" \
+		  /D "JDK_FTYPE=0x1L" \
+		  $7,\
+	MANIFEST:=$(JDK_TOPDIR)/src/windows/resource/java.manifest)
+
+    BUILD_LAUNCHERS += $$(BUILD_LAUNCHER_$1)
+
+    ifeq ($(OPENJDK_TARGET_OS),macosx)
+        $$(BUILD_LAUNCHER_$1) : $(JDK_OUTPUTDIR)/objs/libjli_static.a
+    endif
+
+    ifeq ($(OPENJDK_TARGET_OS),windows)
+        $$(BUILD_LAUNCHER_$1) : $(JDK_OUTPUTDIR)/objs/libjava/java.lib \
+				$$($1_WINDOWS_JLI_LIB)
+    endif    	 
+endef
+
+##########################################################################################
+
+XLIBS:=$(X_LIBS) -lX11
+ifeq ($(OPENJDK_TARGET_OS),macosx)
+    DPACKAGEPATH:=-DPACKAGE_PATH='"$(PACKAGE_PATH)"'
+    XLIBS:=
+endif
+
+ifdef OPENJDK
+    JAVA_RC_FLAGS += -i "$(JDK_TOPDIR)/src/windows/resource/icons"
+else
+    JAVA_RC_FLAGS += -i "$(JDK_TOPDIR)/src/closed/windows/native/sun/windows"
+endif
+
+# On windows, the debuginfo files get the same name as for java.dll. Build
+# into another dir and copy selectively so debuginfo for java.dll isn't
+# overwritten.
+$(eval $(call SetupLauncher,java,\
+    -DEXPAND_CLASSPATH_WILDCARDS,,,user32.lib comctl32.lib,\
+    $(JDK_OUTPUTDIR)/objs/jli_static.lib,$(JAVA_RC_FLAGS),\
+    $(JDK_TOPDIR)/src/windows/resource/java.rc,$(JDK_OUTPUTDIR)/objs/java_objs,true))
+
+$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/java$(EXE_SUFFIX): $(BUILD_LAUNCHER_java)
+	$(MKDIR) -p $(@D)
+	$(RM) $@
+	$(CP) $(JDK_OUTPUTDIR)/objs/java_objs$(OUTPUT_SUBDIR)/java$(EXE_SUFFIX) $@
+
+BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/java$(EXE_SUFFIX)
+
+ifeq ($(OPENJDK_TARGET_OS),windows)
+    $(eval $(call SetupLauncher,javaw,\
+        -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS,,,user32.lib comctl32.lib,\
+        $(JDK_OUTPUTDIR)/objs/jli_static.lib,$(JAVA_RC_FLAGS),\
+        $(JDK_TOPDIR)/src/windows/resource/java.rc,,true))
+endif
+
+
+ifndef BUILD_HEADLESS_ONLY
+$(eval $(call SetupLauncher,appletviewer,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.applet.Main"$(COMMA) }',,\
+    $(XLIBS)))
+endif
+
+$(eval $(call SetupLauncher,extcheck,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.extcheck.Main"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,idlj,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.corba.se.idl.toJavaPortable.Compile"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,jar,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jar.Main"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,jarsigner,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.JarSigner"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,javac,\
+    -DEXPAND_CLASSPATH_WILDCARDS \
+    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javac.Main"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,javadoc,\
+    -DEXPAND_CLASSPATH_WILDCARDS \
+    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javadoc.Main"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,javah,\
+    -DEXPAND_CLASSPATH_WILDCARDS \
+    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javah.Main"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,javap,\
+    -DEXPAND_CLASSPATH_WILDCARDS \
+    -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.javap.Main"$(COMMA) }'))
+
+BUILD_LAUNCHER_jconsole_CFLAGS_windows:=-DJAVAW
+BUILD_LAUNCHER_jconsole_LDFLAGS_windows:=user32.lib
+
+$(eval $(call SetupLauncher,jconsole,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "-J-Djconsole.showOutputViewer"$(COMMA) "sun.tools.jconsole.JConsole"$(COMMA) }' \
+    -DAPP_CLASSPATH='{ "/lib/jconsole.jar"$(COMMA) "/lib/tools.jar"$(COMMA) "/classes" }'))
+
+$(eval $(call SetupLauncher,jdb,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.example.debug.tty.TTY"$(COMMA) }' \
+    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }'))
+
+$(eval $(call SetupLauncher,jhat,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.hat.Main"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,jinfo,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) \
+		   "-J-Dsun.jvm.hotspot.debugger.useProcDebugger"$(COMMA) \
+		   "-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger"$(COMMA) \
+		   "sun.tools.jinfo.JInfo"$(COMMA) }' \
+    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }' \
+    ,,,,,,,,,Info-privileged.plist))
+
+$(eval $(call SetupLauncher,jmap,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) \
+		   "-J-Dsun.jvm.hotspot.debugger.useProcDebugger"$(COMMA) \
+		   "-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger"$(COMMA) \
+		   "sun.tools.jmap.JMap"$(COMMA) }' \
+    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }' \
+    ,,,,,,,,,Info-privileged.plist))
+
+$(eval $(call SetupLauncher,jps,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jps.Jps"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,jrunscript,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.script.shell.Main"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,jsadebugd,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.jvm.hotspot.jdi.SADebugServer"$(COMMA) }' \
+    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }' \
+    ,,,,,,,,,Info-privileged.plist))
+
+$(eval $(call SetupLauncher,jstack,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) \
+		   "-J-Dsun.jvm.hotspot.debugger.useProcDebugger"$(COMMA) \
+		   "-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger"$(COMMA) \
+		   "sun.tools.jstack.JStack"$(COMMA) }' \
+    -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }' \
+    ,,,,,,,,,Info-privileged.plist))
+
+$(eval $(call SetupLauncher,jstat,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jstat.Jstat"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,jstatd,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jstatd.Jstatd"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,keytool,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.KeyTool"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,native2ascii,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.native2ascii.Main"$(COMMA) }'))
+
+ifndef BUILD_HEADLESS_ONLY
+$(eval $(call SetupLauncher,policytool,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.policytool.PolicyTool"$(COMMA) }',,\
+    $(XLIBS)))
+endif
+
+$(eval $(call SetupLauncher,rmic,\
+    -DEXPAND_CLASSPATH_WILDCARDS \
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.rmi.rmic.Main"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,schemagen,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.jxc.SchemaGenerator"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,serialver,\
+    -DEXPAND_CLASSPATH_WILDCARDS \
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.serialver.SerialVer"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,xjc,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.xjc.Driver"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,wsgen,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.ws.WsGen"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,wsimport,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.internal.ws.WsImport"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,orbd,\
+    -DJAVA_ARGS='{ 	"-J-ms8m"$(COMMA) \
+			"-J-Dcom.sun.CORBA.activation.DbDir=./orb.db"$(COMMA) \
+			"-J-Dcom.sun.CORBA.activation.Port=1049"$(COMMA) \
+			"-J-Dcom.sun.CORBA.POA.ORBServerId=1"$(COMMA) \
+			"com.sun.corba.se.impl.activation.ORBD"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,servertool,\
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.corba.se.impl.activation.ServerTool"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,tnameserv,\
+    -DJAVA_ARGS='{ 	"-J-ms8m"$(COMMA) \
+			"-J-Dcom.sun.CORBA.activation.DbDir=./orb.db"$(COMMA) \
+			"-J-Djava.util.logging.LoggingPermission=contol"$(COMMA) \
+			"-J-Dcom.sun.CORBA.POA.ORBServerId=1"$(COMMA) \
+			"com.sun.corba.se.impl.naming.cosnaming.TransientNameServer"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,pack200,\
+    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "com.sun.java.util.jar.pack.Driver"$(COMMA) "--pack" }'))
+
+$(eval $(call SetupLauncher,rmid,\
+    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.rmi.server.Activation"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,rmiregistry,\
+    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.rmi.registry.RegistryImpl"$(COMMA) }'))
+
+$(eval $(call SetupLauncher,jcmd,\
+    -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.tools.jcmd.JCmd"$(COMMA) }'))
+
+ifeq ($(OPENJDK_TARGET_OS),windows)
+    $(eval $(call SetupLauncher,kinit,\
+        -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.security.krb5.internal.tools.Kinit"$(COMMA) }'))
+
+    $(eval $(call SetupLauncher,klist,\
+        -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.security.krb5.internal.tools.Klist"$(COMMA) }'))
+
+    $(eval $(call SetupLauncher,ktab,\
+        -DJAVA_ARGS='{	"-J-ms8m"$(COMMA) "sun.security.krb5.internal.tools.Ktab"$(COMMA) }'))
+endif
+
+##########################################################################################
+# The order of the object files on the link command line affects the size of the resulting
+# binary (at least on linux) which causes the size to differ between old and new build.
+ifeq ($(USE_EXTERNAL_LIBZ), true)
+UNPACKEXE_CFLAGS := -DSYSTEM_ZLIB
+UNPACKEXE_ZIPOBJS := -lz
+else
+UNPACKEXE_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
+UNPACKEXE_ZIPOBJS := 	$(JDK_OUTPUTDIR)/objs/libzip/zcrc32$(OBJ_SUFFIX) \
+		     	$(JDK_OUTPUTDIR)/objs/libzip/deflate$(OBJ_SUFFIX) \
+			$(JDK_OUTPUTDIR)/objs/libzip/trees$(OBJ_SUFFIX) \
+			$(JDK_OUTPUTDIR)/objs/libzip/zadler32$(OBJ_SUFFIX) \
+			$(JDK_OUTPUTDIR)/objs/libzip/compress$(OBJ_SUFFIX) \
+			$(JDK_OUTPUTDIR)/objs/libzip/zutil$(OBJ_SUFFIX) \
+			$(JDK_OUTPUTDIR)/objs/libzip/inflate$(OBJ_SUFFIX) \
+			$(JDK_OUTPUTDIR)/objs/libzip/infback$(OBJ_SUFFIX) \
+			$(JDK_OUTPUTDIR)/objs/libzip/inftrees$(OBJ_SUFFIX) \
+			$(JDK_OUTPUTDIR)/objs/libzip/inffast$(OBJ_SUFFIX)
+
+endif
+
+ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
+    UNPACKEXE_CFLAGS += -xregs=no%appl
+endif
+
+UNPACKEXE_LANG:=C
+ifeq ($(OPENJDK_TARGET_OS),solaris)
+    UNPACKEXE_LANG:=C++
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE,\
+                SRC:=$(JDK_TOPDIR)/src/share/native/com/sun/java/util/jar/pack,\
+		EXCLUDE_FILES:=jni.cpp,\
+		LANG:=$(UNPACKEXE_LANG),\
+		OPTIMIZATION := LOW, \
+		CFLAGS:=$(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE)\
+                        -DFULL, \
+		CFLAGS_release:=-DPRODUCT,\
+		CFLAGS_linux:=-fPIC,\
+		CFLAGS_solaris := -KPIC, \
+		CFLAGS_macosx := -fPIC, \
+		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libunpack/mapfile-vers-unpack200, \
+		LDFLAGS:=$(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
+			 $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN) \
+			 $(UNPACKEXE_ZIPOBJS),\
+		LDFLAGS_linux:=-lc,\
+		LDFLAGS_SUFFIX:=$(LIBCXX),\
+		LDFLAGS_SUFFIX_solaris:=-lc,\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/unpackexe$(OUTPUT_SUBDIR),\
+		OUTPUT_DIR:=$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR),\
+		PROGRAM:=unpack200,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=unpack200.exe" \
+			  /D "JDK_INTERNAL_NAME=unpack200" \
+			  /D "JDK_FTYPE=0x1L",\
+		MANIFEST:=$(JDK_TOPDIR)/src/windows/resource/unpack200_proto.exe.manifest))
+
+ifneq ($(USE_EXTERNAL_LIBZ), true)
+
+$(BUILD_UNPACKEXE) : $(UNPACKEXE_ZIPOBJS)
+
+endif
+
+BUILD_LAUNCHERS += $(BUILD_UNPACKEXE)
+
+##########################################################################################
+
+
+BUILD_JEXEC := 
+BUILD_JEXEC_SRC :=
+BUILD_JEXEC_INC :=
+BUILD_JEXEC_DST_DIR := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)
+
+#
+# UNHANDLED:
+# - COMPILE_APPROACH = normal
+#
+
+#
+# jdk/make/java/Makefile
+#
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+	ifeq ($(OPENJDK_TARGET_CPU_BITS), 32)
+		BUILD_JEXEC := 1
+	endif
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), linux)
+	BUILD_JEXEC := 1
+endif # OPENJDK_TARGET_OS
+
+#
+# jdk/make/java/jexec/Makefile
+#
+ifeq ($(BUILD_JEXEC), 1)
+
+	ifeq ($(OPENJDK_TARGET_OS),windows)
+	else ifeq ($(OPENJDK_TARGET_OS),macosx)
+		BUILD_JEXEC_SRC := $(JDK_TOPDIR)/src/macosx/bin
+	else
+		BUILD_JEXEC_SRC := $(JDK_TOPDIR)/src/solaris/bin
+	endif
+
+	ifeq ($(OPENJDK_TARGET_OS), linux)
+                BUILD_JEXEC_DST_DIR := $(JDK_OUTPUTDIR)/lib
+		BUILD_JEXEC_INC += -I$(JDK_TOPDIR)/src/share/bin
+	endif
+endif
+
+#
+# Note that the two Makefile's seems to contradict each other,
+#   and that src/macosx/bin/jexec.c seems unused
+#
+ifneq ($(BUILD_JEXEC_SRC),)
+        $(eval $(call SetupNativeCompilation,BUILD_JEXEC,\
+		SRC:=$(BUILD_JEXEC_SRC),\
+		INCLUDE_FILES:=jexec.c,\
+		LANG:=C,\
+		OPTIMIZATION := LOW, \
+		CFLAGS:=$(CFLAGS_JDKEXE)\
+                        $(BUILD_JEXEC_INC), \
+		CFLAGS_linux:=-fPIC,\
+		CFLAGS_solaris:=-KPIC,\
+		LDFLAGS:=$(LDFLAGS_JDKEXE) \
+			 $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)), \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/jexec_obj,\
+		OUTPUT_DIR:=$(BUILD_JEXEC_DST_DIR),\
+		PROGRAM:=jexec))
+
+	BUILD_LAUNCHERS += $(BUILD_JEXEC)
+endif
+
+##########################################################################################
+
+#
+# The java-rmi.cgi script in bin/ only gets delivered in certain situations
+#
+JAVA_RMI_CGI:=$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/java-rmi.cgi
+ifeq ($(OPENJDK_TARGET_OS), linux)
+  BUILD_LAUNCHERS += $(JAVA_RMI_CGI)
+endif
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+  ifeq ($(OPENJDK_TARGET_CPU_BITS), 32)
+    BUILD_LAUNCHERS += $(JAVA_RMI_CGI)
+  endif
+endif
+
+# TODO: 
+# On windows java-rmi.cgi shouldn't be bundled since Java 1.2, but has been built all
+# this time anyway. Since jdk6, it has been built from the wrong source and resulted
+# in a copy of the standard java launcher named "java-rmi.exe" ending up in the final
+# images bin dir. This weird behavior is mimicked here in the converted makefiles for
+# now. Should probably just be deleted.
+# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6512052
+ifeq ($(OPENJDK_TARGET_OS),windows)
+    $(eval $(call SetupLauncher,java-rmi,\
+        -DEXPAND_CLASSPATH_WILDCARDS,\
+        $(call SET_SHARED_LIBRARY_MAPFILE,$(JDK_TOPDIR)/makefiles/java/main/java/mapfile-$(OPENJDK_TARGET_CPU))))
+else
+    $(JAVA_RMI_CGI): $(JDK_TOPDIR)/src/solaris/bin/java-rmi.cgi.sh
+	$(MKDIR) -p $(@D)
+	$(CP) $< $@
+	$(CHMOD) a+x $@
+endif
+
+##########################################################################################
+
+$(BUILD_LAUNCHERS) : $(JDK_TOPDIR)/makefiles/CompileLaunchers.gmk
+
+all: $(BUILD_LAUNCHERS)
+
+.PHONY: all
--- a/jdk/makefiles/CompileNativeLibraries.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/CompileNativeLibraries.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -44,13 +44,7 @@
 
 # Put the libraries here. Different locations for different target apis.
 ifeq ($(OPENJDK_TARGET_OS_API),posix)
-    ifneq ($(OPENJDK_TARGET_OS),macosx)
-        INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/lib/$(LIBARCH)
-        LIBARCHDIR=$(LIBARCH)/
-    else
-        INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/lib
-        LIBARCHDIR=/
-    endif
+    INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)
 else
     INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/bin
 endif
@@ -63,6 +57,18 @@
 WIN_JAVA_LIB := $(JDK_OUTPUTDIR)/objs/libjava/java.lib
 WIN_AWT_LIB := $(JDK_OUTPUTDIR)/objs/libawt/awt.lib
 
+# Use this variable to set DEBUG_SYMBOLS true on windows for all libraries, but
+# not on other platforms.
+ifeq ($(OPENJDK_TARGET_OS), windows)
+    WINDOWS_ONLY := true
+endif
+
+#
+# TODO replace with X_FLAGS / X_LIBS
+#   and add them to configure
+#
+OPENWIN_LIB:=$(OPENWIN_HOME)/lib
+
 ##########################################################################################
 
 BUILD_LIBFDLIBM_OPTIMIZATION:=HIGH
@@ -80,7 +86,7 @@
 		OPTIMIZATION:=$(BUILD_LIBFDLIBM_OPTIMIZATION), \
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
-		CFLAGS_winapi_debug:=-DLOGGING,\
+		CFLAGS_windows_debug:=-DLOGGING,\
 		ARFLAGS:=$(ARFLAGS),\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm))
 
@@ -98,7 +104,7 @@
 		LANG:=C,\
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
-		LDFLAGS:=-nostdlib -r,\
+		LDFLAGS:=-nostdlib -r -arch i386 -arch x86_64,\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm))
 
 $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) : $(BUILD_LIBFDLIBM)
@@ -112,11 +118,18 @@
 BUILD_LIBVERIFY_SRC:=check_code.c check_format.c
 
 ifeq ($(OPENJDK_TARGET_OS), solaris)
-	ifneq ($(ARCH), amd64)
-		BUILD_LIBVERIFY_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libverify/reorder-$(ARCH)
+	ifneq ($(OPENJDK_TARGET_CPU), x86_64)
+		BUILD_LIBVERIFY_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libverify/reorder-$(OPENJDK_TARGET_CPU)
 	endif
 endif
 
+LIBVERIFY_OPTIMIZATION:=HIGH
+ifneq ($(findstring $(OPENJDK_TARGET_OS),solaris linux),)
+    ifeq ($(ENABLE_DEBUG_SYMBOLS), yes)
+        LIBVERIFY_OPTIMIZATION:=LOW
+    endif
+endif
+
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBVERIFY,\
 		LIBRARY:=verify, \
@@ -124,13 +137,18 @@
 		SRC:=$(JDK_TOPDIR)/src/share/native/common,\
 		INCLUDE_FILES:=$(BUILD_LIBVERIFY_SRC),\
 		LANG:=C,\
-		OPTIMIZATION:=HIGH, \
+		OPTIMIZATION:=$(LIBVERIFY_OPTIMIZATION), \
 		CFLAGS:=$(CFLAGS_JDKLIB),\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libverify/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
 		LDFLAGS_SUFFIX_posix:=-ljvm -lc,\
 		LDFLAGS_SUFFIX_windows:=jvm.lib,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS) \
+			  /D "JDK_FNAME=verify.dll" \
+			  /D "JDK_INTERNAL_NAME=verify" \
+			  /D "JDK_FTYPE=0x2L",\
 		REORDER:=$(BUILD_LIBVERIFY_REORDER),\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libverify,\
 		DEBUG_SYMBOLS:=true))
@@ -139,40 +157,32 @@
 
 ##########################################################################################
 
-LIBJAVA_SRC_DIRS:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/lang \
+LIBJAVA_SRC_DIRS:=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/lang \
 		$(JDK_TOPDIR)/src/share/native/java/lang \
 		$(JDK_TOPDIR)/src/share/native/java/lang/ref \
 		$(JDK_TOPDIR)/src/share/native/java/lang/reflect \
 		$(JDK_TOPDIR)/src/share/native/java/io \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/io \
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/io \
 		$(JDK_TOPDIR)/src/share/native/java/nio \
 		$(JDK_TOPDIR)/src/share/native/java/security \
 		$(JDK_TOPDIR)/src/share/native/common \
 		$(JDK_TOPDIR)/src/share/native/sun/misc \
 		$(JDK_TOPDIR)/src/share/native/sun/reflect \
-		$(JDK_TOPDIR)/src/share/native/java/sql \
 		$(JDK_TOPDIR)/src/share/native/java/util \
 		$(JDK_TOPDIR)/src/share/native/java/util/concurrent/atomic \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/common \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/util \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/provider \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/io
-
-#
-# TODO
-#
-ARCHPROPNAME:=$(LIBARCH)
-ifeq ($(OPENJDK_TARGET_OS)-$(ARCH), solaris-i586)
-     ARCHPROPNAME:=x86
-else ifeq ($(OPENJDK_TARGET_OS)-$(ARCH_DATA_MODEL), windows-32)
-     ARCHPROPNAME:=x86
-else ifeq ($(OPENJDK_TARGET_OS), macosx)
-     ARCHPROPNAME:=$(ARCH)
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/util \
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/provider \
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/io
+ifneq ($(OPENJDK_TARGET_OS),macosx)
+    LIBJAVA_SRC_DIRS+=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/util/locale/provider
+else
+    LIBJAVA_SRC_DIRS+=$(JDK_TOPDIR)/src/macosx/native/sun/util/locale/provider
 endif
 
 LIBJAVA_CFLAGS:=$(foreach dir,$(LIBJAVA_SRC_DIRS),-I$(dir)) \
 		  -I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include \
-                  -DARCHPROPNAME='"$(ARCHPROPNAME)"'
+                  -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"'
 
 LIBJAVA_CFLAGS += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
                   -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' \
@@ -208,8 +218,8 @@
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), solaris)
-    ifneq ($(ARCH), amd64)
-        LIBJAVA_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libjava/reorder-$(ARCH)
+    ifneq ($(OPENJDK_TARGET_CPU), x86_64)
+        LIBJAVA_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libjava/reorder-$(OPENJDK_TARGET_CPU)
     endif
 endif
 
@@ -233,11 +243,17 @@
 		LDFLAGS_SUFFIX_posix:=-ljvm -lverify, \
 		LDFLAGS_SUFFIX_solaris:=-lnsl -lsocket -lscf $(LIBDL) $(BUILD_LIBFDLIBM) -lc,\
 		LDFLAGS_SUFFIX_linux:=$(LIBDL) $(BUILD_LIBFDLIBM),\
-		LDFLAGS_SUFFIX_macosx:=$(BUILD_LIBFDLIBM) \
+		LDFLAGS_SUFFIX_macosx:=-L$(JDK_OUTPUTDIR)/objs/ -lfdlibm \
                                          -framework CoreFoundation \
                                          -framework Security -framework SystemConfiguration, \
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=java.dll" \
+			  /D "JDK_INTERNAL_NAME=java" \
+			  /D "JDK_FTYPE=0x2L",\
 		REORDER:=$(LIBJAVA_REORDER), \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjava))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjava,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJAVA)
 
@@ -252,20 +268,14 @@
 BUILD_LIBMLIB_SRC:=$(JDK_TOPDIR)/src/share/native/sun/awt/medialib
 BUILD_LIBMLIB_CFLAGS:=-D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES \
 			-I$(BUILD_LIBMLIB_SRC) \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt/medialib 
+			-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt/medialib 
 
 BUILD_LIBMLIB_LDLIBS:=
 BUILD_LIBMLIB_IMAGE_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libmlib_image/mapfile-vers
 
-ifneq ($(OPENJDK_TARGET_OS), sparc)
-#
-# Yes, this will always be true (until someone makes an OS called sparc)
-#   but this is how it was writtin in old system...keep it like this for now
-#
-	BUILD_LIBMLIB_CFLAGS += -DMLIB_NO_LIBSUNMATH
-endif
-
-ifeq ($(ARCH_DATA_MODEL), 64)
+BUILD_LIBMLIB_CFLAGS += -DMLIB_NO_LIBSUNMATH
+
+ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
 	BUILD_LIBMLIB_CFLAGS += -DMLIB_OS64BIT
 endif
 
@@ -284,11 +294,16 @@
                         $(BUILD_LIBMLIB_CFLAGS),\
 		MAPFILE:=$(BUILD_LIBMLIB_IMAGE_MAPFILE), \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-                         $(BUILD_LIBMLIB_LDLIBS) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-                LDFLAGS_SUFFIX_posix:=-lm,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image))
+		LDFLAGS_SUFFIX:=$(BUILD_LIBMLIB_LDLIBS) \
+				$(LDFLAGS_JDKLIB_SUFFIX),\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=mlib_image.dll" \
+			  /D "JDK_INTERNAL_NAME=mlib_image" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBMLIB_IMAGE) : $(BUILD_LIBJAVA)
 
@@ -296,15 +311,7 @@
 
 ##########################################################################################
 
-ifeq ($(OPENJDK_TARGET_OS),solaris)
-ifeq ($(ARCH),sparc)
-	BUILD_LIBMLIB_IMAGE_V:=1
-else ifeq ($(ARCH), sparcv9)
-	BUILD_LIBMLIB_IMAGE_V:=1
-endif
-endif
-
-ifeq ($(BUILD_LIBMLIB_IMAGE_V), 1)
+ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH),solaris-sparc)
 
 BUILD_LIBMLIB_IMAGE_V_FILES:=\
         mlib_v_ImageLookUp.c \
@@ -411,7 +418,7 @@
 		INCLUDE_FILES:=$(BUILD_LIBMLIB_IMAGE_V_FILES),\
 		OPTIMIZATION:=HIGHEST, \
 		CFLAGS:=-xarch=sparcvis \
-                      $(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib/vis_$(ARCH_DATA_MODEL).il\
+                      $(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib/vis_$(OPENJDK_TARGET_CPU_BITS).il\
                       $(BUILD_LIBMLIB_V_CFLAGS) \
                       $(CFLAGS_JDKLIB), \
 		MAPFILE:=$(BUILD_LIBMLIB_IMAGE_MAPFILE), \
@@ -428,7 +435,7 @@
 
 LIBAWT_DIRS:=\
 	$(JDK_TOPDIR)/src/share/native/sun/awt \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt \
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/image \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/image/gif \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
@@ -437,17 +444,17 @@
 	$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/utility \
 	$(JDK_TOPDIR)/src/share/native/sun/java2d \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
 	$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
 	$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/image \
 	$(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/opengl \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/x11 \
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/opengl \
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/x11 \
 	$(JDK_TOPDIR)/src/share/native/sun/font \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/windows \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/windows \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/d3d
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/windows \
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/windows \
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/d3d
 
 
 LIBAWT_CFLAGS:=-D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES \
@@ -524,11 +531,12 @@
 	debug_trace.c \
 	debug_util.c
 
-ifneq (,$(filter $(OPENJDK_TARGET_OS), solaris linux macosx))
+ifneq (,$(filter $(OPENJDK_TARGET_OS), solaris linux))
 	LIBAWT_FILES += awt_LoadLibrary.c initIDs.c img_colors.c
 endif
 
 ifeq ($(OPENJDK_TARGET_OS),macosx)
+	LIBAWT_FILES += awt_LoadLibrary.c img_colors.c
 	LIBAWT_DIRS += $(JDK_TOPDIR)/src/macosx/native/com/apple/resources
 	LIBAWT_FILES += awt_LoadLibrary.c MacOSXResourceBundle.m
 	LIBAWT_CFLAGS += -F/System/Library/Frameworks/JavaVM.framework/Frameworks
@@ -539,7 +547,7 @@
 ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc)
         LIBAWT_CFLAGS += -DMLIB_ADD_SUFF
         LIBAWT_CFLAGS += -xarch=sparcvis
-	LIBAWT_CFLAGS += $(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib/vis_$(ARCH_DATA_MODEL).il
+	LIBAWT_CFLAGS += $(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib/vis_$(OPENJDK_TARGET_CPU_BITS).il
         LIBAWT_CFLAGS += \
             -I$(JDK_TOPDIR)/src/solaris/native/sun/awt/medialib \
             -I$(JDK_TOPDIR)/src/solaris/native/sun/java2d/medialib \
@@ -591,7 +599,7 @@
                 vis_XorBlit.c             \
                 mlib_v_ImageCopy_blk.s
 
-	ifeq ($(OPENJDK_TARGET_CPU_BITS),64)
+	ifeq ($(OPENJDK_TARGET_CPU),sparcv9)
 		LIBAWT_ASFLAGS=-P -xarch=v9a
 	else
 		LIBAWT_ASFLAGS=-P -xarch=v8plusa
@@ -644,8 +652,8 @@
 			MouseInfo.cpp \
 			rect.c
 	LIBAWT_LANG:=C++
-	LIBAWT_CFLAGS += $(GX_OPTION) -DUNICODE -D_UNICODE
-	ifeq ($(ARCH_DATA_MODEL), 64)
+	LIBAWT_CFLAGS += -EHsc -DUNICODE -D_UNICODE
+	ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
 		LIBAWT_CFLAGS += -DMLIB_OS64BIT
 	endif
 
@@ -686,22 +694,25 @@
 				 /DELAYLOAD:winspool.drv /DELAYLOAD:imm32.dll \
 				 /DELAYLOAD:ole32.dll /DELAYLOAD:comdlg32.dll \
 				 /DELAYLOAD:comctl32.dll /DELAYLOAD:shlwapi.dll,\
-		LDFLAGS_macosx:=-lmlib_image \
-                                 -framework Cocoa \
-				 -framework OpenGL \
-				 -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-				 -framework JavaNativeFoundation \
-				 -framework JavaRuntimeSupport \
-				 -framework ApplicationServices \
-				 -framework AudioToolbox,\
-		LDFLAGS_solaris:=-R/usr/dt/lib$(ISA_DIR) -R$(OPENWIN_LIB)$(ISA_DIR),\
-		LDFLAGS_SUFFIX_posix:=-ljvm $(LIBM) -ljava $(LIBDL),\
+		LDFLAGS_solaris:=-R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR),\
+		LDFLAGS_SUFFIX_linux:=-ljvm $(LIBM) $(LIBDL) -ljava,\
+		LDFLAGS_SUFFIX_solaris:=-ljvm $(LIBM) $(LIBDL) -ljava,\
+		LDFLAGS_SUFFIX_macosx:=-lmlib_image -ljvm $(LIBM) \
+				       -framework Cocoa \
+				       -framework OpenGL \
+				       -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
+				       -framework JavaNativeFoundation \
+				       -framework JavaRuntimeSupport \
+				       -framework ApplicationServices \
+				       -framework AudioToolbox \
+				       -ljava,\
 		VERSIONINFO_RESOURCE:=$(LIBAWT_VERSIONINFO_RESOURCE),\
 		RC_FLAGS:=$(RC_FLAGS) $(LIBAWT_RC_FLAGS) \
 			  /D "JDK_FNAME=awt.dll" \
 			  /D "JDK_INTERNAL_NAME=awt" \
 			  /D "JDK_FTYPE=0x2L",\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBAWT) : $(BUILD_LIBJAVA)
 
@@ -728,25 +739,25 @@
 		$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
 		$(JDK_TOPDIR)/src/share/native/sun/awt/utility \
 		$(JDK_TOPDIR)/src/share/native/sun/font \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/font \
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/font \
 		$(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/opengl \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/x11 \
-		$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/xawt \
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt \
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/opengl \
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/x11 \
+		$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/xawt \
 
 LIBAWT_XAWT_CFLAGS:=-DXAWT -DXAWT_HACK \
         -DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
 	$(CUPS_CFLAGS) \
 	$(foreach dir,$(LIBAWT_XAWT_DIRS),-I$(dir)) \
 	-I$(JDK_TOPDIR)/src/share/native/sun/java2d \
-	-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
+	-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
 	-I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
 	-I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
 	-I$(JDK_TOPDIR)/src/share/native/sun/awt/image \
 	-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
 	-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
-	-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/jdga
+	-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/jdga
 
 ifeq ($(OPENJDK_TARGET_OS),solaris)
 	LIBAWT_XAWT_CFLAGS += -DFUNCPROTO=15
@@ -816,13 +827,15 @@
 LIBAWT_XAWT_LDFLAGS_SUFFIX:=$(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi  -ljava -ljvm -lc
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
-	LIBAWT_XAWT_LDFLAGS_SUFFIX += -lpthread
+        # To match old build, add this to LDFLAGS instead of suffix.
+	LIBAWT_XAWT_LDFLAGS += -lpthread
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
 	LIBAWT_XAWT_LDFLAGS_SUFFIX += -lpthread
 endif
 
+# On macosx, the shared library origin is set twice for this lib.
 $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_XAWT,\
 		LIBRARY:=awt_xawt,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
@@ -834,12 +847,26 @@
                         $(X_CFLAGS),\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libawt_xawt/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN) \
-			 $(X_LIBS),\
-		LDFLAGS_solaris:=-L$(OPENWIN_HOME)/sfw/lib$(ISA_DIR) -L$(OPENWIN_HOME)/lib$(ISA_DIR) \
-				 -R$(OPENWIN_HOME)/sfw/lib$(ISA_DIR) -R$(OPENWIN_HOME)/lib$(ISA_DIR) \
-				 -R/usr/dt/lib$(ISA_DIR),\
+			 $(X_LIBS) $(LIBAWT_XAWT_LDFLAGS),\
+		LDFLAGS_linux:=$(call SET_SHARED_LIBRARY_ORIGIN) \
+			       $(call SET_SHARED_LIBRARY_ORIGIN,/..),\
+		LDFLAGS_solaris:=-L$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) \
+				 -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) \
+				 -R$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) \
+				 -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) \
+				 -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
+			 	 $(call SET_SHARED_LIBRARY_ORIGIN) \
+			 	 $(call SET_SHARED_LIBRARY_ORIGIN,/..),\
+		LDFLAGS_macosx:=$(call SET_SHARED_LIBRARY_ORIGIN) \
+				$(call SET_SHARED_LIBRARY_ORIGIN). \
+				$(call SET_SHARED_LIBRARY_ORIGIN) \
+				$(call SET_SHARED_LIBRARY_ORIGIN).,\
 		LDFLAGS_SUFFIX:=$(LIBAWT_XAWT_LDFLAGS_SUFFIX),\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=xawt.dll" \
+			  /D "JDK_INTERNAL_NAME=xawt" \
+			  /D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_xawt))
 
 $(BUILD_LIBAWT_XAWT) : $(BUILD_LIBJAVA)
@@ -885,8 +912,8 @@
 
 BUILD_LIBZIP_REORDER:=
 ifeq ($(OPENJDK_TARGET_OS), solaris)
-    ifneq ($(ARCH), amd64)
-        BUILD_LIBZIP_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libzip/reorder-$(ARCH)
+    ifneq ($(OPENJDK_TARGET_CPU), x86_64)
+        BUILD_LIBZIP_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libzip/reorder-$(OPENJDK_TARGET_CPU)
     endif
 endif
 
@@ -905,17 +932,26 @@
 		CFLAGS:=$(CFLAGS_JDKLIB) \
                         $(LIBZ_INCLUDE) \
 		        -I$(JDK_TOPDIR)/src/share/native/java/io \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/io,\
+                        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/io,\
 		CFLAGS_posix:=$(BUILD_LIBZIP_MMAP) -UDEBUG,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libzip/mapfile-vers, \
 		REORDER:=$(BUILD_LIBZIP_REORDER), \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN) \
 			 $(EXPORT_ZIP_FUNCS), \
-		LDFLAGS_winapi:=-export:ZIP_Open -export:ZIP_Close -export:ZIP_FindEntry \
+		LDFLAGS_windows:=-export:ZIP_Open -export:ZIP_Close -export:ZIP_FindEntry \
                                 -export:ZIP_ReadEntry -export:ZIP_GetNextEntry jvm.lib \
                                 $(WIN_JAVA_LIB),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBZ),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libzip))
+		LDFLAGS_SUFFIX_linux:=-ljvm -ljava $(LIBZ),\
+		LDFLAGS_SUFFIX_solaris:=-ljvm -ljava $(LIBZ),\
+		LDFLAGS_SUFFIX_macosx:=$(LIBZ) -ljava -ljvm,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=zip.dll" \
+			  /D "JDK_INTERNAL_NAME=zip" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libzip,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBZIP) : $(BUILD_LIBJAVA)
 
@@ -934,24 +970,24 @@
 			 -DNO_ZLIB -DUNPACK_JNI -DFULL,\
 		CFLAGS_release:=-DPRODUCT,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libunpack/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB)\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_winapi:=-map:$(JDK_OUTPUTDIR)/objs/unpack.map /debug \
+		LDFLAGS_windows:=-map:$(JDK_OUTPUTDIR)/objs/unpack.map /debug \
 				jvm.lib $(WIN_JAVA_LIB),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		LDFLAGS_SUFFIX_posix:=$(LIBCXX),\
+		LDFLAGS_SUFFIX_posix:=-ljvm $(LIBCXX) -ljava -lc,\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libunpack,\
 		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
 		RC_FLAGS:=$(RC_FLAGS)\
 			  /D "JDK_FNAME=unpack.dll" \
 			  /D "JDK_INTERNAL_NAME=unpack" \
-			  /D "JDK_FTYPE=0x2L"))
+			  /D "JDK_FTYPE=0x2L",\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBUNPACK) : $(BUILD_LIBJAVA)
 
 BUILD_LIBRARIES += $(BUILD_LIBUNPACK)
 
-ifeq ($(OPENJDK_TARGET_OS_API),winapi)
+ifeq ($(OPENJDK_TARGET_OS),windows)
     $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)unpack.map: $(BUILD_LIBUNPACK)
 	$(ECHO) Copying $(@F)
 	$(CP) $(patsubst %$(SHARED_LIBRARY_SUFFIX),%.map,$<) $@
@@ -977,16 +1013,21 @@
 $(eval $(call SetupNativeCompilation,BUILD_LIBATTACH,\
 		LIBRARY:=attach, \
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/tools/attach,\
+                SRC:=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/tools/attach,\
 		EXCLUDE_FILES:=$(LIBATTACH_EXCLUDE_FILES),\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB),\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libattach/mapfile-$(OPENJDK_TARGET_OS), \
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS) \
+			  /D "JDK_FNAME=attach.dll" \
+			  /D "JDK_INTERNAL_NAME=attach" \
+			  /D "JDK_FTYPE=0x2L",\
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_solaris:=-ldoor,\
-		LDFLAGS_winapi:=psapi.lib advapi32.lib $(WIN_JAVA_LIB) jvm.lib,\
+		LDFLAGS_windows:=psapi.lib advapi32.lib $(WIN_JAVA_LIB) jvm.lib,\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libattach,\
 		DEBUG_SYMBOLS:=true))
@@ -1001,21 +1042,26 @@
 		LIBRARY:=dt_socket,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
                 SRC:=$(JDK_TOPDIR)/src/share/transport/socket \
-			$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/transport/socket,\
+			$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/socket,\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) -DUSE_MMAP \
                         -I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
                         -I$(JDK_TOPDIR)/src/share/transport/socket \
-		        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/transport/socket \
+		        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/socket \
                         -I$(JDK_TOPDIR)/src/share/back/export \
                         -I$(JDK_TOPDIR)/src/share/back,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libdt_socket/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB), \
-		LDFLAGS_SUFFIX_linux:=$(LDFLAGS_JDKLIB_SUFFIX) -lpthread,\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN), \
+		LDFLAGS_SUFFIX_linux:=-lpthread,\
 		LDFLAGS_SUFFIX_solaris:=-lnsl -lsocket,\
-		LDFLAGS_SUFFIX_winapi:=$(LDFLAGS_JDKLIB_SUFFIX) -export:jdwpTransport_OnLoad ws2_32.lib,\
-		LDFLAGS_SUFFIX:=,\
+		LDFLAGS_SUFFIX_windows:=$(LDFLAGS_JDKLIB_SUFFIX) -export:jdwpTransport_OnLoad ws2_32.lib,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=dt_socket.dll" \
+			  /D "JDK_INTERNAL_NAME=dt_socket" \
+			  /D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdt_socket,\
 		DEBUG_SYMBOLS:=true))
 
@@ -1025,55 +1071,66 @@
 
 ##########################################################################################
 
-ifeq ($(OPENJDK_TARGET_OS_API),winapi)
+ifeq ($(OPENJDK_TARGET_OS),windows)
 
   $(eval $(call SetupNativeCompilation,BUILD_LIBDT_SHMEM,\
 		LIBRARY:=dt_shmem,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
                 SRC:=$(JDK_TOPDIR)/src/share/native/com/sun/tools/jdi \
 			$(JDK_TOPDIR)/src/share/transport/shmem \
-			$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/transport/shmem,\
+			$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/shmem,\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) -DUSE_MMAP\
                         -I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
                         -I$(JDK_TOPDIR)/src/share/transport/shmem \
-		        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/transport/shmem \
+		        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/shmem \
                         -I$(JDK_TOPDIR)/src/share/back/export, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB),\
-		LDFLAGS_winapi:=-export:jdwpTransport_OnLoad,\
+		LDFLAGS_windows:=-export:jdwpTransport_OnLoad,\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdt_shmem))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=dt_shmem.dll" \
+			  /D "JDK_INTERNAL_NAME=dt_shmem" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdt_shmem,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
   BUILD_LIBRARIES += $(BUILD_LIBDT_SHMEM)
 
 endif # OPENJDK_TARGET_OS
 
 ##########################################################################################
-# JDWP_LOGGING causes log messages to be compiled into the library. These reference the 
-# __FILE__ macro which here expands to the absolute path of the file while the old build 
-# system used a relative path. This causes the binaries to differ in size.
+# JDWP_LOGGING causes log messages to be compiled into the library.
 $(eval $(call SetupNativeCompilation,BUILD_LIBJDWP,\
 		LIBRARY:=jdwp, \
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
-                SRC:=$(JDK_TOPDIR)/src/share/back $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/back,\
+                SRC:=$(JDK_TOPDIR)/src/share/back $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/back,\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) -DJDWP_LOGGING\
 		 -I$(JDK_TOPDIR)/src/share/transport/export \
                  -I$(JDK_TOPDIR)/src/share/back/export \
                  -I$(JDK_TOPDIR)/src/share/npt \
-                 -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/npt \
+                 -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt \
                  -I$(JDK_TOPDIR)/src/share/back \
-                 -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/back \
+                 -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/back \
 		 -I$(JDK_OUTPUTDIR)/gensrc_jdwp_headers,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjdwp/mapfile-vers, \
-		LDFLAGS:=$(filter-out -ljava,$(LDFLAGS_JDKLIB)), \
-		LDFLAGS_SUFFIX_linux:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBDL),\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_SUFFIX_linux:=$(LIBDL),\
 		LDFLAGS_SUFFIX_solaris:=$(LIBDL),\
 		LDFLAGS_SUFFIX_windows:=$(LDFLAGS_JDKLIB_SUFFIX),\
 		LDFLAGS_SUFFIX:=,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjdwp))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=jdwp.dll" \
+			  /D "JDK_INTERNAL_NAME=jdwp" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjdwp,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBJDWP) : $(BUILD_LIBJAVA)
 
@@ -1097,19 +1154,24 @@
 $(eval $(call SetupNativeCompilation,BUILD_LIBJAAS,\
 		LIBRARY:=$(LIBJAAS_NAME),\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/com/sun/security/auth/module,\
+                SRC:=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/com/sun/security/auth/module,\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB),\
 		MAPFILE:=$(LIBJAAS_MAPFILE),\
 		LDFLAGS:=$(filter-out -ljava,$(LDFLAGS_JDKLIB)) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_winapi:=netapi32.lib user32.lib mpr.lib advapi32.lib,\
-		LDFLAGS_SUFFIX_linux:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_windows:=netapi32.lib user32.lib mpr.lib advapi32.lib,\
 		LDFLAGS_SUFFIX_windows:=$(LDFLAGS_JDKLIB_SUFFIX),\
 		LDFLAGS_SUFFIX:=,\
 		EXCLUDE_FILES:=$(LIBJAAS_EXCLUDE_FILES),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjaas))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS) \
+			  /D "JDK_FNAME=$(LIBJAAS_NAME).dll" \
+			  /D "JDK_INTERNAL_NAME=$(LIBJAAS_NAME)" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjaas,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBJAAS) : $(BUILD_LIBJAVA)
 
@@ -1121,7 +1183,7 @@
 		LIBRARY:=jsdt,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
                 SRC:=$(JDK_TOPDIR)/src/share/native/sun/tracing/dtrace\
-			$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/tracing/dtrace,\
+			$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/tracing/dtrace,\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB)\
@@ -1129,12 +1191,17 @@
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjsdt/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX_linux:=$(LDFLAGS_JDKLIB_SUFFIX)  $(LIBDL),\
-		LDFLAGS_SUFFIX_winapi:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBDL),\
+		LDFLAGS_SUFFIX_linux:=$(LIBDL),\
+		LDFLAGS_SUFFIX_windows:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBDL),\
 		LDFLAGS_SUFFIX_macosx:=                         $(LIBDL),\
 		LDFLAGS_SUFFIX:=,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=jsdt.dll" \
+			  /D "JDK_INTERNAL_NAME=jsdt" \
+			  /D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsdt, \
-                DEBUG_SYMBOLS:= yes))
+                DEBUG_SYMBOLS:=true))
 
 $(BUILD_LIBJSDT) : $(BUILD_LIBJAVA)
 
@@ -1163,14 +1230,20 @@
 			-I$(JDK_TOPDIR)/src/share/native/sun/java2d \
 			-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug,\
 		CFLAGS_solaris:=-xc99=no_lib,\
-		CFLAGS_winapi:=-DCMS_IS_WINDOWS_,\
+		CFLAGS_windows:=-DCMS_IS_WINDOWS_,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/liblcms/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB), \
-		LDFLAGS_solaris:=/usr/lib$(ISA_DIR)/libm.so.2,\
-		LDFLAGS_winapi:=$(WIN_AWT_LIB) $(WIN_JAVA_LIB),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		LDFLAGS_SUFFIX_posix:=-lawt,\
-		LDFLAGS_SUFFIX_linux:=-lm,\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+                         $(call SET_SHARED_LIBRARY_ORIGIN), \
+		LDFLAGS_solaris:=/usr/lib$(OPENJDK_TARGET_CPU_ISADIR)/libm.so.2,\
+		LDFLAGS_windows:=$(WIN_AWT_LIB) $(WIN_JAVA_LIB),\
+		LDFLAGS_SUFFIX_solaris:=-lawt -ljava -ljvm,\
+		LDFLAGS_SUFFIX_macosx:=$(LIBM) -lawt -ljava -ljvm,\
+		LDFLAGS_SUFFIX_linux:=-lm -lawt -ljava -ljvm,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=lcms.dll" \
+			  /D "JDK_INTERNAL_NAME=lcms" \
+			  /D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/liblcms))
 
     BUILD_LIBRARIES += $(BUILD_LIBLCMS)
@@ -1190,8 +1263,8 @@
 
 BUILD_LIBJPEG_REORDER:=
 ifeq ($(OPENJDK_TARGET_OS), solaris)
-    ifneq ($(ARCH), amd64)
-        BUILD_LIBJPEG_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libjpeg/reorder-$(ARCH)
+    ifneq ($(OPENJDK_TARGET_CPU), x86_64)
+        BUILD_LIBJPEG_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libjpeg/reorder-$(OPENJDK_TARGET_CPU)
     endif
 endif
 
@@ -1223,11 +1296,16 @@
 		MAPFILE:=$(BUILD_LIBJPEG_MAPFILE), \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_linux:=$(LIBDL),\
-		LDFLAGS_winapi:=$(WIN_JAVA_LIB) jvm.lib,\
+		LDFLAGS_windows:=$(WIN_JAVA_LIB) jvm.lib,\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=jpeg.dll" \
+			  /D "JDK_INTERNAL_NAME=jpeg" \
+			  /D "JDK_FTYPE=0x2L",\
 		REORDER:=$(BUILD_LIBJPEG_REORDER),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjpeg))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjpeg,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBJPEG) : $(BUILD_LIBJAVA)
 
@@ -1263,11 +1341,11 @@
 			-I$(JDK_TOPDIR)/src/share/native/sun/font \
 			-I$(JDK_TOPDIR)/src/share/native/sun/font/layout \
 			-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt \
+			-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt \
 			-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
 			-I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
 			-I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
+			-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
 			-I$(JDK_TOPDIR)/src/share/native/sun/java2d
 
 # Turn off aliasing with GCC for ExtensionSubtables.cpp
@@ -1279,25 +1357,30 @@
 		LIBRARY:=fontmanager, \
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
                 SRC:=$(JDK_TOPDIR)/src/share/native/sun/font\
-		     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/font,\
+		     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/font,\
 		EXCLUDE_FILES:=$(LIBFONTMANAGER_EXCLUDE_FILES) \
 			       AccelGlyphCache.c,\
 		LANG:=C++,\
 		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBFONTMANAGER_CFLAGS_COMMON),\
 		CXXFLAGS:=$(CXXFLAGS_JDKLIB) $(BUILD_LIBFONTMANAGER_CFLAGS_COMMON),\
 		OPTIMIZATION:=$(LIBFONTMANAGER_OPTIMIZATION), \
-		CFLAGS_windows= -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/windows \
+		CFLAGS_windows= -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/windows \
 				-DCC_NOEX, \
 		MAPFILE:=$(BUILD_LIBFONTMANAGER_MAPFILE), \
-		LDFLAGS:=$(subst -Xlinker -z -Xlinker defs,,$(LDFLAGS_JDKLIB)) \
+		LDFLAGS:=$(subst -Xlinker -z -Xlinker defs,,$(LDFLAGS_JDKLIB)) $(LDFLAGS_CXX_JDK) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_windows:=advapi32.lib user32.lib gdi32.lib $(WIN_AWT_LIB) $(WIN_JAVA_LIB),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) \
-				$(BUILD_LIBFONTMANAGER_FONTLIB),\
-		LDFLAGS_SUFFIX_linux:=-lawt $(LIBM) $(LIBCXX),\
-		LDFLAGS_SUFFIX_solaris:=-lawt -lawt_xawt -lc $(LIBM) $(LIBCXX),\
-		LDFLAGS_SUFFIX_macosx:=-lawt $(LIBM) $(LIBCXX) -undefined dynamic_lookup,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfontmanager))
+		LDFLAGS_SUFFIX:=$(BUILD_LIBFONTMANAGER_FONTLIB),\
+		LDFLAGS_SUFFIX_linux:=-lawt $(LIBM) $(LIBCXX) -ljava -ljvm -lc,\
+		LDFLAGS_SUFFIX_solaris:=-lawt -lawt_xawt -lc $(LIBM) $(LIBCXX) -ljava -ljvm,\
+		LDFLAGS_SUFFIX_macosx:=-lawt $(LIBM) $(LIBCXX) -undefined dynamic_lookup -ljava -ljvm,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=fontmanager.dll" \
+			  /D "JDK_INTERNAL_NAME=fontmanager" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfontmanager,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBFONTMANAGER) : $(BUILD_LIBAWT)
 
@@ -1323,10 +1406,10 @@
 		            -I$(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k \
 		            -I$(JDK_TOPDIR)/src/closed/share/native/sun/font \
 		            -I$(JDK_TOPDIR)/src/share/share/native/sun/font \
-		            -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/font \
+		            -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/font \
 		            -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
 		            -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
-		            -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
+		            -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
 		            -I$(JDK_TOPDIR)/src/share/native/sun/java2d
 
     $(eval $(call SetupNativeCompilation,BUILD_LIBT2K,\
@@ -1343,15 +1426,18 @@
 		CFLAGS_windows=-DCC_NOEX, \
 		CXXFLAGS_windows=-DCC_NOEX, \
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libt2k/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_windows:=user32.lib $(JDK_OUTPUTDIR)/objs/libfontmanager/fontmanager.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		LDFLAGS_SUFFIX_macosx:=$(LIBCXX) $(LIBM) -lfontmanager,\
-		LDFLAGS_SUFFIX_linux:=$(LIBCXX) $(LIBM) -lfontmanager,\
-		LDFLAGS_SUFFIX_solaris:=$(LIBCXX) $(LIBM) -lfontmanager -lawt \
-					-lawt_xawt,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libt2k))
+		LDFLAGS_SUFFIX_posix:=$(LIBM) $(LIBCXX) -lfontmanager -ljava -ljvm -lc,\
+		LDFLAGS_SUFFIX_solaris:=-lawt -lawt_xawt,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=t2k.dll" \
+			  /D "JDK_INTERNAL_NAME=t2k" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libt2k,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
     # t2k is linked against fontmanager
     $(BUILD_LIBT2K) : $(BUILD_LIBFONTMANAGER)
@@ -1361,40 +1447,40 @@
 
 ##########################################################################################
 
-#
-# TODO replace with X_FLAGS / X_LIBS
-#   and add them to configure
-#
-OPENWIN_LIB:=$(OPENWIN_HOME)/lib
-
 ifeq ($(OPENJDK_TARGET_OS), windows)
-    ifeq ($(ARCH_DATA_MODEL), 32)
+    ifeq ($(OPENJDK_TARGET_CPU), x86)
         KERNEL32_LIB:=kernel32.lib
     endif
     $(eval $(call SetupNativeCompilation,BUILD_LIBJAWT,\
                 LIBRARY:=jawt, \
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/windows,\
+                SRC:=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/windows,\
 		INCLUDE_FILES:=jawt.cpp,\
 		LANG:=C++,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CXXFLAGS_JDKLIB) \
 			-EHsc -DUNICODE -D_UNICODE \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/windows \
+			-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/windows \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
 			-I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d/windows, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) $(KERNEL32_LIB) \
+			-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/windows, \
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(KERNEL32_LIB) $(LDFLAGS_CXX_JDK) \
 			 advapi32.lib $(WIN_AWT_LIB),\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=jawt.dll" \
+			  /D "JDK_INTERNAL_NAME=jawt" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBJAWT) : $(BUILD_LIBAWT)
 
 $(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX): $(BUILD_LIBJAWT)
 	$(ECHO) Copying $(@F)
-	$(CP) $< $@
+	$(CP) $(JDK_OUTPUTDIR)/objs/libjawt/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX) $@
 
 BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX)
 
@@ -1421,7 +1507,7 @@
     $(eval $(call SetupNativeCompilation,BUILD_LIBJAWT,\
                 LIBRARY:=jawt, \
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt \
+                SRC:=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt \
                      $(JDK_TOPDIR)/src/macosx/native/sun/awt,\
 		INCLUDE_FILES:=$(JAWT_FILES),\
 		LANG:=C,\
@@ -1432,10 +1518,11 @@
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjawt/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_solaris:=-L$(OPENWIN_HOME)/sfw/lib$(ISA_DIR) -L$(OPENWIN_LIB)$(ISA_DIR),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(JAWT_LIBS),\
-		LDFLAGS_SUFFIX_solaris:=-lXrender,\
-		LDFLAGS_SUFFIX_macosx:=-framework Cocoa, \
+		LDFLAGS_solaris:=-L$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR),\
+		LDFLAGS_SUFFIX_linux:=$(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX_solaris:=$(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX) -lXrender,\
+		LDFLAGS_SUFFIX_macosx:=-Xlinker -rpath -Xlinker @loader_path $(JAWT_LIBS) \
+				       -framework Cocoa $(LDFLAGS_JDKLIB_SUFFIX),\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt))
 
 ifndef BUILD_HEADLESS_ONLY
@@ -1494,7 +1581,13 @@
 		LDFLAGS:=$(LIBJDBCODBC_LDFLAGS) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN) $(LIBJDBCODBC_LIBS),\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBJDBCODBC_SONAME),\
-		OBJECT_DIR:=$(LIBJDBCODBC_DIR)))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=JdbcOdbc.dll" \
+			  /D "JDK_INTERNAL_NAME=JdbcOdbc" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(LIBJDBCODBC_DIR),\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBJDBCODBC) : $(BUILD_LIBJAVA)
 
@@ -1538,11 +1631,11 @@
 
 ##########################################################################################
 
-BUILD_LIBINSTRUMENT_SRC   :=$(JDK_TOPDIR)/src/share/instrument \
-                               $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/io \
-                               $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/instrument
-
-BUILD_LIBINSTRUMENT_FILES :=\
+LIBINSTRUMENT_SRC   :=$(JDK_TOPDIR)/src/share/instrument \
+                      $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/io \
+                      $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/instrument
+
+LIBINSTRUMENT_FILES :=\
 	EncodingSupport.c \
 	EncodingSupport_md.c \
 	FileSystemSupport_md.c \
@@ -1557,50 +1650,54 @@
 	Utilities.c \
 	canonicalize_md.c
 
-BUILD_LIBINSTRUMENT_DIR   :=$(JDK_OUTPUTDIR)/objs/libinstrument
-BUILD_LIBINSTRUMENT_CFLAGS:=-I$(JDK_TOPDIR)/src/share/instrument \
-                               -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/instrument \
-                               -I$(JDK_TOPDIR)/src/share/bin
-
-BUILD_LIBINSTRUMENT_LDFLAGS:=
-BUILD_LIBINSTRUMENT_LDFLAGS_SUFFIX:=
+LIBINSTRUMENT_DIR   :=$(JDK_OUTPUTDIR)/objs/libinstrument
+LIBINSTRUMENT_CFLAGS:=$(CFLAGS_JDKLIB) \
+                      -I$(JDK_TOPDIR)/src/share/instrument \
+                      -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/instrument \
+                      -I$(JDK_TOPDIR)/src/share/bin
+
+LIBINSTRUMENT_LDFLAGS:=
+LIBINSTRUMENT_LDFLAGS_SUFFIX:=
 
 ifeq ($(OPENJDK_TARGET_OS), windows)
-  BUILD_LIBINSTRUMENT_LDFLAGS += $(JDK_OUTPUTDIR)/objs/jli_static.lib $(WIN_JAVA_LIB) \
-				 -export:Agent_OnAttach
-  # equivalent of strcasecmp is stricmp on Windows
-  BUILD_LIBINSTRUMENT_CFLAGS += -Dstrcasecmp=stricmp
-else ifneq (,$(findstring $(OPENJDK_TARGET_OS), macosx))
-	ifneq ($(ARCH), universal)
-		BUILD_LIBINSTRUMENT_LDFLAGS += -Wl,-all_load
-	endif
-
-	BUILD_LIBINSTRUMENT_LDFLAGS += $(JDK_OUTPUTDIR)/objs/libjli_static.a
-	BUILD_LIBINSTRUMENT_LDFLAGS += -liconv
-	BUILD_LIBINSTRUMENT_LDFLAGS += -framework Cocoa -framework Security -framework ApplicationServices
-	BUILD_LIBINSTRUMENT_LDFLAGS += $(LIBZ)
-else
-	BUILD_LIBINSTRUMENT_LDFLAGS += -L $(INSTALL_LIBRARIES_HERE)/jli
-	BUILD_LIBINSTRUMENT_LDFLAGS_SUFFIX += -ljli $(LIBDL)
+    LIBINSTRUMENT_LDFLAGS += $(JDK_OUTPUTDIR)/objs/jli_static.lib $(WIN_JAVA_LIB) \
+				 -export:Agent_OnAttach advapi32.lib
+    # Statically link the C runtime so that there are not dependencies on modules 
+    # not on the search patch when invoked from the Windows system directory 
+    # (or elsewhere).
+    LIBINSTRUMENT_CFLAGS := $(filter-out -MD,$(LIBINSTRUMENT_CFLAGS))
+    # equivalent of strcasecmp is stricmp on Windows
+    LIBINSTRUMENT_CFLAGS += -Dstrcasecmp=stricmp
 endif
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBINSTRUMENT,\
 		LIBRARY:=instrument, \
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
-		SRC:=$(BUILD_LIBINSTRUMENT_SRC),\
-		INCLUDE_FILES:=$(BUILD_LIBINSTRUMENT_FILES),\
+		SRC:=$(LIBINSTRUMENT_SRC),\
+		INCLUDE_FILES:=$(LIBINSTRUMENT_FILES),\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
-		CFLAGS:=$(CFLAGS_JDKLIB) \
-                        $(BUILD_LIBINSTRUMENT_CFLAGS),\
+		CFLAGS:=$(LIBINSTRUMENT_CFLAGS),\
 		CFLAGS_debug:=-DJPLIS_LOGGING,\
 		CFLAGS_release:=-DNO_JPLIS_LOGGING,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libinstrument/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN)\
-			 $(call SET_SHARED_LIBRARY_ORIGIN,jli) \
-                         $(BUILD_LIBINSTRUMENT_LDFLAGS),\
-		LDFLAGS_SUFFIX:=$(LIBZ) $(BUILD_LIBINSTRUMENT_LDFLAGS_SUFFIX),\
-		OBJECT_DIR:=$(BUILD_LIBINSTRUMENT_DIR),\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+			 $(call SET_SHARED_LIBRARY_ORIGIN) \
+                         $(LIBINSTRUMENT_LDFLAGS),\
+		LDFLAGS_linux:=$(call SET_SHARED_LIBRARY_ORIGIN,/jli),\
+		LDFLAGS_solaris:= $(call SET_SHARED_LIBRARY_ORIGIN,/jli),\
+		LDFLAGS_macosx:=-Xlinker -all_load $(JDK_OUTPUTDIR)/objs/libjli_static.a \
+				-framework Cocoa -framework Security -framework ApplicationServices,\
+		LDFLAGS_SUFFIX:=$(LIBINSTRUMENT_LDFLAGS_SUFFIX),\
+		LDFLAGS_SUFFIX_macosx:=-liconv $(LIBZ),\
+		LDFLAGS_SUFFIX_solaris:=$(LIBZ) -L $(INSTALL_LIBRARIES_HERE)/jli -ljli $(LIBDL),\
+		LDFLAGS_SUFFIX_linux:=$(LIBZ) -L $(INSTALL_LIBRARIES_HERE)/jli -ljli $(LIBDL),\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=instrument.dll" \
+			  /D "JDK_INTERNAL_NAME=instrument" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(LIBINSTRUMENT_DIR),\
 		DEBUG_SYMBOLS:=true))
 
 ifneq (,$(findstring $(OPENJDK_TARGET_OS), macosx windows))
@@ -1615,8 +1712,8 @@
 ##########################################################################################
 
 BUILD_LIBMANAGEMENT_SRC:=$(JDK_TOPDIR)/src/share/native/sun/management \
-                           $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/management \
-                           $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/com/sun/management
+                           $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/management \
+                           $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/com/sun/management
 
 BUILD_LIBMANAGEMENT_EXCLUDES:=
 
@@ -1640,6 +1737,12 @@
 	BUILD_LIBMANAGEMENT_EXCLUDES += MacosxOperatingSystem.c
 endif
 
+LIBMANAGEMENT_OPTIMIZATION:=HIGH
+ifneq ($(findstring $(OPENJDK_TARGET_OS),solaris linux),)
+    ifeq ($(ENABLE_DEBUG_SYMBOLS), yes)
+        LIBMANAGEMENT_OPTIMIZATION:=LOW
+    endif
+endif
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBMANAGEMENT,\
 		LIBRARY:=management,\
@@ -1647,7 +1750,7 @@
 		SRC:=$(BUILD_LIBMANAGEMENT_SRC),\
 		EXCLUDE_FILES:=$(BUILD_LIBMANAGEMENT_EXCLUDES),\
 		LANG:=C,\
-		OPTIMIZATION:=HIGH, \
+		OPTIMIZATION:=$(LIBMANAGEMENT_OPTIMIZATION), \
 		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBMANAGEMENT_CFLAGS),\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libmanagement/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
@@ -1655,6 +1758,11 @@
 		LDFLAGS_windows:=$(WIN_JAVA_LIB) jvm.lib advapi32.lib psapi.lib,\
 		LDFLAGS_solaris:=-lkstat,\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=management.dll" \
+			  /D "JDK_INTERNAL_NAME=management" \
+			  /D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmanagement,\
 		DEBUG_SYMBOLS:=true))
 
@@ -1664,10 +1772,10 @@
 
 ##########################################################################################
 
-BUILD_LIBHPROF_SRC:=$(JDK_TOPDIR)/src/share/demo/jvmti/hprof $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/demo/jvmti/hprof
+BUILD_LIBHPROF_SRC:=$(JDK_TOPDIR)/src/share/demo/jvmti/hprof $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/demo/jvmti/hprof
 BUILD_LIBHPROF_CFLAGS:=-I$(JDK_TOPDIR)/src/share/demo/jvmti/hprof \
                          -I$(JDK_TOPDIR)/src/share/npt \
-                         -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/npt \
+                         -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt \
                          -I$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo
 
 BUILD_LIBHPROF_LDFLAGS:=
@@ -1676,6 +1784,13 @@
      BUILD_LIBHPROF_LDFLAGS += -lsocket -lnsl
 endif
 
+LIBHPROF_OPTIMIZATION:=HIGHEST
+ifneq ($(findstring $(OPENJDK_TARGET_OS),solaris linux),)
+    ifeq ($(ENABLE_DEBUG_SYMBOLS), yes)
+        LIBHPROF_OPTIMIZATION:=LOW
+    endif
+endif
+
 ifneq ($(OPENJDK_TARGET_OS),windows)
      BUILD_LIBHPROF_LDFLAGS += $(LIBDL)
 endif
@@ -1685,7 +1800,7 @@
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(BUILD_LIBHPROF_SRC),\
 		LANG:=C,\
-		OPTIMIZATION:=HIGHEST, \
+		OPTIMIZATION:=$(LIBHPROF_OPTIMIZATION), \
 		CFLAGS:=$(CFLAGS_JDKLIB) \
                          $(BUILD_LIBHPROF_CFLAGS),\
 		CFLAGS_debug:=-DHPROF_LOGGING,\
@@ -1694,6 +1809,11 @@
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_windows:=wsock32.lib winmm.lib advapi32.lib,\
 		LDFLAGS_SUFFIX:=$(BUILD_LIBHPROF_LDFLAGS),\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=hprof.dll" \
+			  /D "JDK_INTERNAL_NAME=hprof" \
+			  /D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libhprof_jvmti,\
 		DEBUG_SYMBOLS:=true))
 
@@ -1712,7 +1832,11 @@
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjava_crw_demo/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=java_crw_demo.dll" \
+			  /D "JDK_INTERNAL_NAME=java_crw_demo" \
+			  /D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjava_crw_demo,\
 		DEBUG_SYMBOLS:=true))
 
@@ -1723,17 +1847,22 @@
 $(eval $(call SetupNativeCompilation,BUILD_LIBNPT,\
 		LIBRARY:=npt, \
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
-		SRC:=$(JDK_TOPDIR)/src/share/npt $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/npt,\
+		SRC:=$(JDK_TOPDIR)/src/share/npt $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt,\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) \
                         -I$(JDK_TOPDIR)/src/share/npt \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/npt,\
+                        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnpt/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_macosx:=-liconv,\
 		LDFLAGS_SUFFIX_windows:=-export:nptInitialize -export:nptTerminate,\
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=npt.dll" \
+			  /D "JDK_INTERNAL_NAME=npt" \
+			  /D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnpt,\
 		DEBUG_SYMBOLS:=true))
 
@@ -1742,11 +1871,11 @@
 ##########################################################################################
 
 LIBNET_SRC_DIRS:=$(JDK_TOPDIR)/src/share/native/java/net \
-                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/net \
-                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/net/dns \
-                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/net/www/protocol/http/ntlm \
-                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/net/sdp \
-                   $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/net/spi
+                   $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/net \
+                   $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/net/dns \
+                   $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/net/www/protocol/http/ntlm \
+                   $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/net/sdp \
+                   $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/net/spi
 
 LIBNET_CFLAGS:=$(foreach dir,$(LIBNET_SRC_DIRS),-I$(dir))
 
@@ -1767,8 +1896,6 @@
 				NTLMAuthSequence.c NetworkInterface_winXP.c
 endif
 
-LIBNET_LDFLAGS_SUFFIX:=
-
 $(eval $(call SetupNativeCompilation,BUILD_LIBNET,\
 		LIBRARY:=net,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
@@ -1781,13 +1908,19 @@
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnet/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) $(LIBNET_LDFLAGS_SUFFIX),\
-		LDFLAGS_SUFFIX_solaris:=-lnsl -lsocket $(LIBDL) ,\
-		LDFLAGS_SUFFIX_linux:=$(LIBDL) -lpthread ,\
+		LDFLAGS_SUFFIX_macosx:=-ljvm -ljava,\
+		LDFLAGS_SUFFIX_solaris:=-ljvm -ljava -lnsl -lsocket $(LIBDL) ,\
+		LDFLAGS_SUFFIX_linux:=$(LIBDL) -ljvm -lpthread -ljava,\
 		LDFLAGS_SUFFIX_windows:=ws2_32.lib $(JVMLIB) secur32.lib iphlpapi.lib \
 					  delayimp.lib $(WIN_JAVA_LIB) jvm.lib advapi32.lib \
                                           /DELAYLOAD:secur32.dll /DELAYLOAD:iphlpapi.dll, \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnet))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=net.dll" \
+			  /D "JDK_INTERNAL_NAME=net" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnet,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBNET) : $(BUILD_LIBJAVA)
 
@@ -1801,7 +1934,7 @@
 COPY_FILES += $(JDK_OUTPUTDIR)/lib/net.properties
 
 ifeq ($(OPENJDK_TARGET_OS), solaris)
-$(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template : $(JDK_TOPDIR)/src/${LEGACY_OPENJDK_TARGET_OS_API}/lib/sdp/sdp.conf.template
+$(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template : $(JDK_TOPDIR)/src/${OPENJDK_TARGET_OS_API_DIR}/lib/sdp/sdp.conf.template
 	$(ECHO) Copying $(@F)
 	$(MKDIR) -p $(@D)
 	$(CP) $< $@
@@ -1812,15 +1945,15 @@
 ##########################################################################################
 
 BUILD_LIBNIO_SRC:=\
-        $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/nio \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/ch \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/fs
+        $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/nio \
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/ch \
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/fs
 
 BUILD_LIBNIO_CFLAGS:=\
 	-I$(JDK_TOPDIR)/src/share/native/sun/nio/ch \
 	-I$(JDK_TOPDIR)/src/share/native/java/io \
 	-I$(JDK_TOPDIR)/src/share/native/java/net \
-        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/net
+        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/net
 
 BUILD_LIBNIO_FILES:=\
         DatagramChannelImpl.c \
@@ -1847,14 +1980,14 @@
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
-	BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-linux
+	BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
 	BUILD_LIBNIO_FILES += \
 		EPoll.c \
 		EPollArrayWrapper.c \
 		EPollPort.c \
 		InheritedChannel.c \
 		NativeThread.c \
-	        PollArrayWrapper.c \
+		PollArrayWrapper.c \
 		UnixAsynchronousServerSocketChannelImpl.c \
 		UnixAsynchronousSocketChannelImpl.c \
 		GnomeFileTypeDetector.c \
@@ -1865,7 +1998,7 @@
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
-	BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-bsd
+	BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
 	BUILD_LIBNIO_SRC += $(JDK_TOPDIR)/src/macosx/native/sun/nio/ch
 	BUILD_LIBNIO_FILES += \
 		InheritedChannel.c \
@@ -1873,8 +2006,8 @@
 	        PollArrayWrapper.c \
 		UnixAsynchronousServerSocketChannelImpl.c \
 		UnixAsynchronousSocketChannelImpl.c \
-		GnomeFileTypeDetector.c \
 		BsdNativeDispatcher.c \
+		MacOSXNativeDispatcher.c \
 		UnixCopyFile.c \
 		UnixNativeDispatcher.c \
 		KQueue.c \
@@ -1883,7 +2016,7 @@
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), solaris)
-	BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-solaris
+	BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
 	BUILD_LIBNIO_FILES += \
 		DevPollArrayWrapper.c \
 		InheritedChannel.c \
@@ -1912,17 +2045,22 @@
 		LDFLAGS:=$(LDFLAGS_JDKLIB) $(BUILD_LIBNIO_LDFLAGS) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX_linux:=-ljava -lnet -lpthread $(LIBDL),\
-		LDFLAGS_SUFFIX_solaris:=$(LDFLAGS_JDKLIB_SUFFIX) \
-                                        $(JVMLIB) -lsocket -lposix4 $(LIBDL) -lsendfile \
-		                        -ljava -lnet,\
+		LDFLAGS_SUFFIX_solaris:=-ljvm -lsocket -lposix4 $(LIBDL) \
+				        -lsendfile -ljava -lnet -lc,\
 		LDFLAGS_SUFFIX_windows:=$(LDFLAGS_JDKLIB_SUFFIX) \
                                         $(WIN_JAVA_LIB) $(JDK_OUTPUTDIR)/objs/libnet/net.lib \
 					advapi32.lib jvm.lib ws2_32.lib\
                                         $(JDK_OUTPUTDIR)/objs/libjava/io_util.obj \
 		                        $(JDK_OUTPUTDIR)/objs/libjava/FileDescriptor_md.obj ,\
-		LDFLAGS_SUFFIX_macosx:=-ljava -lnet -pthread,\
+		LDFLAGS_SUFFIX_macosx:=-ljava -lnet -pthread -framework CoreFoundation,\
 		LDFLAGS_SUFFIX:=,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnio))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=nio.dll" \
+			  /D "JDK_INTERNAL_NAME=nio" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnio,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(BUILD_LIBNIO)
 
@@ -1942,23 +2080,23 @@
     $(eval $(call SetupNativeCompilation,BUILD_LIBSCTP,\
                 LIBRARY:=sctp,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
-                SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/ch/sctp,\
+                SRC:=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/ch/sctp,\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB)\
 			-I$(JDK_TOPDIR)/src/share/native/sun/nio/ch \
 			-I$(JDK_TOPDIR)/src/share/native/sun/nio/ch/sctp \
 			-I$(JDK_TOPDIR)/src/share/native/java/net \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/ch \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/java/net,\
+			-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/ch \
+			-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/net,\
 		CFLAGS_linux:=$(SCTP_WERROR),\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libsctp/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX_linux:=$(LIBDL) -lpthread,\
+		LDFLAGS_SUFFIX_linux:=-lpthread $(LIBDL) -ljava -ljvm,\
 		LDFLAGS_SUFFIX_posix:=-lnio -lnet,\
-		LDFLAGS_SUFFIX_solaris:=-lsocket,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX_solaris:=-lsocket -ljava -ljvm,\
+		LDFLAGS_SUFFIX_macosx:=-ljava -ljvm,\
 		INCLUDE_FILES:=SctpNet.c SctpChannelImpl.c SctpServerChannelImpl.c,\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsctp))
 
@@ -1970,8 +2108,8 @@
 
 ##########################################################################################
 
-BUILD_LIBJLI_SRC_DIRS:=$(JDK_TOPDIR)/src/share/bin $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/bin
-BUILD_LIBJLI_CFLAGS:=$(foreach dir,$(BUILD_LIBJLI_SRC_DIRS),-I$(dir))
+BUILD_LIBJLI_SRC_DIRS:=$(JDK_TOPDIR)/src/share/bin $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin
+LIBJLI_CFLAGS:=$(CFLAGS_JDKLIB) $(foreach dir,$(BUILD_LIBJLI_SRC_DIRS),-I$(dir))
 
 BUILD_LIBJLI_FILES:=\
 	java.c \
@@ -1983,16 +2121,16 @@
 
 ifeq ($(JVM_VARIANT_ZERO), true)
 	ERGO_FAMILY:=zero
-else # !ZERO_BUILD
-	ifneq (,$(findstring $(ARCH), amd64 x86_64))
+else
+	ifeq ($(OPENJDK_TARGET_CPU_ARCH), x86)
 		ERGO_FAMILY:=i586
-	else # !X86 FAMILY
-		ERGO_FAMILY:=$(ARCH)
-	endif #ARCH_FAMILY
-endif # ZERO_BUILD
+	else
+		ERGO_FAMILY:=$(OPENJDK_TARGET_CPU_ARCH)
+	endif
+endif
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
-	BUILD_LIBJLI_CFLAGS += -I$(JDK_TOPDIR)/src/macosx/bin
+	LIBJLI_CFLAGS += -I$(JDK_TOPDIR)/src/macosx/bin
 	BUILD_LIBJLI_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/bin
 	BUILD_LIBJLI_FILES += java_md_common.c java_md_macosx.c
 
@@ -2001,7 +2139,10 @@
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), windows)
-	BUILD_LIBJLI_FILES += java_md.c
+	BUILD_LIBJLI_FILES += java_md.c \
+			      cmdtoargs.c
+        # Staticically link with c runtime on windows.
+	LIBJLI_CFLAGS:=$(filter-out -MD,$(LIBJLI_CFLAGS))
 else ifneq ($(OPENJDK_TARGET_OS), macosx)
 
 	BUILD_LIBJLI_FILES += java_md_common.c
@@ -2011,36 +2152,23 @@
 
         # if the architecture specific ergo file exists then
         # use it, else use the generic definitions from ergo.c
-	ifneq ($(wildcard $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/bin/$(ERGO_ARCH_FILE)),)
+	ifneq ($(wildcard $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin/$(ERGO_ARCH_FILE)),)
 		BUILD_LIBJLI_FILES += $(ERGO_ARCH_FILE)
 	else # !ERGO_ARCH_FILE
-		BUILD_LIBJLI_CFLAGS += -DUSE_GENERIC_ERGO
+		LIBJLI_CFLAGS += -DUSE_GENERIC_ERGO
 	endif # ERGO_ARCH_FILE
 endif #WINDOWS
 
-# Names of arch directories
-ifneq ($(OPENJDK_TARGET_OS), macosx)
-	BUILD_LIBJLI_CFLAGS += -DLIBARCHNAME='"$(LIBARCH)"'
-else
-	BUILD_LIBJLI_CFLAGS += -DLIBARCHNAME='"$(ARCH)"'
-endif
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-	ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
-		BUILD_LIBJLI_CFLAGS += -DLIBARCH32NAME='"sparc"'
-		BUILD_LIBJLI_CFLAGS += -DLIBARCH64NAME='"sparcv9"'
-	else
-		BUILD_LIBJLI_CFLAGS += -DLIBARCH32NAME='"i386"'
-		BUILD_LIBJLI_CFLAGS += -DLIBARCH64NAME='"amd64"'
-	endif
-endif # OPENJDK_TARGET_OS
+# Append defines depending on target platform
+LIBJLI_CFLAGS += $(OPENJDK_TARGET_CPU_JLI_CFLAGS)
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
-	BUILD_LIBJLI_CFLAGS += -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
+	LIBJLI_CFLAGS += -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
 endif
 
 ifneq ($(USE_EXTERNAL_LIBZ),true)
 	BUILD_LIBJLI_SRC_DIRS += $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5
-	BUILD_LIBJLI_CFLAGS += $(LIBZ_INCLUDE)
+	LIBJLI_CFLAGS += $(LIBZ_INCLUDE)
 	BUILD_LIBJLI_FILES += \
 		inflate.c \
 		inftrees.c \
@@ -2063,13 +2191,16 @@
 		INCLUDE_FILES:=$(BUILD_LIBJLI_FILES),\
 		LANG:=C,\
 		OPTIMIZATION:=HIGH, \
-		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBJLI_CFLAGS),\
+		CFLAGS:=$(LIBJLI_CFLAGS),\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjli/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=$(LIBZ),\
-		LDFLAGS_SUFFIX_posix:=$(LIBDL) -lc,\
-		LDFLAGS_SUFFIX_linux:=-lpthread,\
+		LDFLAGS_linux:=$(call SET_SHARED_LIBRARY_ORIGIN,/..),\
+		LDFLAGS_solaris:=$(call SET_SHARED_LIBRARY_ORIGIN,/..),\
+		LDFLAGS_macosx:=-framework Cocoa -framework Security -framework ApplicationServices,\
+		LDFLAGS_SUFFIX_solaris:=$(LIBZ) $(LIBDL) -lc,\
+		LDFLAGS_SUFFIX_linux:=$(LIBZ) $(LIBDL) -lc -lpthread,\
+		LDFLAGS_SUFFIX_macosx:=$(LIBZ),\
 		LDFLAGS_SUFFIX_windows:=\
 			-export:JLI_Launch \
 			-export:JLI_ManifestIterate \
@@ -2078,11 +2209,20 @@
 			-export:JLI_ReportErrorMessageSys \
 			-export:JLI_ReportMessage \
 			-export:JLI_ReportExceptionDescription \
+			-export:JLI_MemAlloc \
+			-export:JLI_CmdToArgs \
+			-export:JLI_GetStdArgc \
+			-export:JLI_GetStdArgs \
 			advapi32.lib \
 			comctl32.lib \
 			user32.lib,\
-		LDFLAGS_SUFFIX_macosx:=-framework Cocoa -framework Security -framework ApplicationServices, \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS) \
+			  /D "JDK_FNAME=jli.dll" \
+			  /D "JDK_INTERNAL_NAME=jli" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJLI)
 
@@ -2097,7 +2237,7 @@
 		INCLUDE_FILES:=$(BUILD_LIBJLI_FILES),\
 		LANG:=C,\
 		OPTIMIZATION:=HIGH, \
-		CFLAGS:=$(CFLAGS_JDKLIB) $(STATIC_LIBRARY_FLAGS) $(BUILD_LIBJLI_CFLAGS),\
+		CFLAGS:=$(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS),\
 		ARFLAGS:=$(ARFLAGS),\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))
 
@@ -2115,7 +2255,7 @@
 		INCLUDE_FILES:=$(BUILD_LIBJLI_FILES),\
 		LANG:=C,\
 		OPTIMIZATION:=HIGH, \
-		CFLAGS:=$(CFLAGS_JDKLIB) $(BUILD_LIBJLI_CFLAGS),\
+		CFLAGS:=$(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS),\
 		LDFLAGS:=-nostdlib -r,\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))
 
@@ -2140,7 +2280,13 @@
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjfr/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjfr))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=jfr.dll" \
+			  /D "JDK_INTERNAL_NAME=jfr" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjfr,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJFR)
 
@@ -2180,11 +2326,17 @@
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libkcms/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX_linux:=-lpthread,\
+		LDFLAGS_SUFFIX_linux:=-lc -lpthread,\
 		LDFLAGS_SUFFIX_windows:=$(WIN_JAVA_LIB) advapi32.lib user32.lib version.lib, \
 		LDFLAGS_SUFFIX:=-lm $(LDFLAGS_JDKLIB_SUFFIX),\
 		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/closed/share/native/sun/java2d/cmm/kcms/cmm.rc,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkcms))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/closed/share/native/sun/java2d/cmm/kcms/cmm.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=kcms.dll" \
+			  /D "JDK_INTERNAL_NAME=kcms" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkcms,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBKCMS) : $(BUILD_LIBJAVA)
 
@@ -2196,12 +2348,12 @@
 
 ifndef OPENJDK
 ifeq ($(OPENJDK_TARGET_OS), solaris)
-ifneq ($(ARCH), amd64)
+ifneq ($(OPENJDK_TARGET_CPU), x86_64)
 
 ifeq ($(shell if test "$(OS_VERSION_MAJOR)" -eq 5 -a "$(OS_VERSION_MINOR)" -le 10; then $(ECHO) ok; fi), ok)
 
 SUNWJDGA_MAPFILE:=
-ifneq (,$(findstring $(ARCH),sparc))
+ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
 	SUNWJDGA_MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjdga/mapfile-vers
 endif
 
@@ -2213,12 +2365,12 @@
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/share/javavm/export \
-			-I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/javavm/export \
+			-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \
 			-I$(OPENWIN_HOME)/include, \
 		MAPFILE:=$(SUNWJDGA_MAPFILE), \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX:=-L$(OPENWIN_LIB)$(ISA_DIR) -R$(OPENWIN_LIB)$(ISA_DIR) -ldga -lX11 $(LIBDL) -lc, \
+		LDFLAGS_SUFFIX:=-L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -ldga -lX11 $(LIBDL) -lc, \
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunwjdga))
 
 BUILD_LIBRARIES += $(BUILD_LIBSUNWJDGA)
@@ -2245,13 +2397,13 @@
 			  $(CUPS_CFLAGS) \
 			  $(X_CFLAGS) \
 			  -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
-			  -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/java2d \
+			  -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
 			  -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
 			  -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
 			  -I$(JDK_TOPDIR)/src/share/native/sun/awt/image \
 			  -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
 			  -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
-			  -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/jdga \
+			  -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/jdga \
                           $(foreach dir,$(LIBAWT_HEADLESS_DIRS),-I$(dir))
 
 LIBAWT_HEADLESS_FILES:=\
@@ -2282,12 +2434,10 @@
         AccelGlyphCache.c \
 	CUPSfuncs.c
 
-LIBAWT_HEADLESS_LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) -lawt -lm
-
 LIBAWT_HEADLESS_REORDER:=
 ifeq ($(OPENJDK_TARGET_OS), solaris)
-	ifneq ($(ARCH), amd64)
-		LIBAWT_HEADLESS_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libawt_headless/reorder-$(ARCH)
+	ifneq ($(OPENJDK_TARGET_CPU), x86_64)
+		LIBAWT_HEADLESS_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU)
 	endif
 endif
 
@@ -2302,11 +2452,15 @@
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libawt_headless/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_linux:=$(call SET_SHARED_LIBRARY_ORIGIN,/..),\
+		LDFLAGS_solaris:=$(call SET_SHARED_LIBRARY_ORIGIN,/..) \
+				 -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
+				 -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR),\
+		LDFLAGS_macosx:=$(call SET_SHARED_LIBRARY_ORIGIN).,\
 		REORDER:=$(LIBAWT_HEADLESS_REORDER), \
-		LDFLAGS_SUFFIX:=$(LIBAWT_HEADLESS_LDFLAGS_SUFFIX),\
-		LDFLAGS_SUFFIX_posix:=$(LIBDL),\
-		LDFLAGS_SUFFIX_macosx:=$(LIBCXX), \
-		LDFLAGS_SUFFIX_solaris:=$(LIBCXX), \
+		LDFLAGS_SUFFIX_linux:=-ljvm -lawt -lm $(LIBDL) -ljava,\
+		LDFLAGS_SUFFIX_solaris:=$(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX), \
+		LDFLAGS_SUFFIX_macosx:=-ljvm $(LIBCXX) -lawt $(LIBDL) -ljava, \
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_headless))
 
 $(BUILD_LIBAWT_HEADLESS) : $(BUILD_LIBAWT)
@@ -2324,7 +2478,7 @@
 	$(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/libpng \
 	$(JDK_TOPDIR)/src/share/native/sun/awt/splashscreen \
-        $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/awt/splashscreen
+        $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt/splashscreen
 
 LIBSPLASHSCREEN_CFLAGS:=-DSPLASHSCREEN -DPNG_NO_MMX_CODE \
 	$(foreach dir,$(LIBSPLASHSCREEN_DIRS),-I$(dir))
@@ -2458,7 +2612,7 @@
                                   -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
 				  -framework JavaNativeFoundation
 else ifneq ($(OPENJDK_TARGET_OS), windows)
-	LIBSPLASHSCREEN_LDFLAGS_SUFFIX += -L$(OPENWIN_LIB)$(ISA_DIR) -lX11 -lXext $(LIBM) -lpthread
+	LIBSPLASHSCREEN_LDFLAGS_SUFFIX += -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -lX11 -lXext $(LIBM) -lpthread
 else # OPENJDK_TARGET_OS
 	LIBSPLASHSCREEN_LDFLAGS_SUFFIX += kernel32.lib user32.lib gdi32.lib delayimp.lib /DELAYLOAD:user32.dll
 endif # OPENJDK_TARGET_OS
@@ -2474,9 +2628,14 @@
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libsplashscreen/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX_linux:=$(LIBDL), \
 		LDFLAGS_SUFFIX:=$(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsplashscreen))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=splashscreen.dll" \
+			  /D "JDK_INTERNAL_NAME=splashscreen" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsplashscreen,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(LIBSPLASHSCREEN)
 
@@ -2508,11 +2667,17 @@
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 			$(LIBDCPR_CFLAGS), \
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libdcpr/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) $(LIBM)\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX:=$(LIBM) $(LDFLAGS_JDKLIB_SUFFIX),\
 		LDFLAGS_SUFFIX_posix:=-lm,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdcpr))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=dcpr.dll" \
+			  /D "JDK_INTERNAL_NAME=dcpr" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdcpr,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBDCPR) : $(BUILD_LIBJAVA)
 
@@ -2526,20 +2691,26 @@
 		LIBRARY:=j2pcsc,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/smartcardio \
-                     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/smartcardio,\
+                     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio,\
 		LANG:=C,\
 		CFLAGS_posix:=-D__sun_jdk,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) \
                      -I$(JDK_TOPDIR)/src/share/native/sun/security/smartcardio \
-                     -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/smartcardio\
-                     -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/smartcardio/MUSCLE,\
+                     -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio\
+                     -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio/MUSCLE,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2pcsc/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX_posix:=$(LIBDL), \
 		LDFLAGS_SUFFIX_windows:=winscard.lib,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pcsc))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=j2pcsc.dll" \
+			  /D "JDK_INTERNAL_NAME=j2pcsc" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pcsc,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJ2PCSC)
 
@@ -2550,12 +2721,12 @@
 		LIBRARY:=j2gss,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/jgss/wrapper \
-                     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/jgss/wrapper,\
+                     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/jgss/wrapper,\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) \
                      -I$(JDK_TOPDIR)/src/share/native/sun/security/jgss/wrapper \
-                     -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/jgss/wrapper,\
+                     -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/jgss/wrapper,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2gss/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
@@ -2571,7 +2742,7 @@
 ifeq ($(OPENJDK_TARGET_OS), windows)
      BUILD_LIBKRB5_NAME:=w2k_lsa_auth
      BUILD_LIBKRB5_FILES:=NativeCreds.c WindowsDirectory.c
-     BUILD_LIBKRB5_SRC:=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/krb5
+     BUILD_LIBKRB5_SRC:=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/krb5
      BUILD_LIBKRB5_LIBS:=Secur32.lib netapi32.lib \
 	kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib \
 	advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib \
@@ -2593,11 +2764,17 @@
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/security/krb5 \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/krb5 ,\
+                        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/krb5 ,\
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=$(BUILD_LIBKRB5_LIBS) ,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkrb5))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=$(BUILD_LIBKRB5_NAME).dll" \
+			  /D "JDK_INTERNAL_NAME=$(BUILD_LIBKRB5_NAME)" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkrb5,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(BUILD_LIBKRB5)
 endif
@@ -2610,46 +2787,56 @@
 		LIBRARY:=sunmscapi,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/mscapi \
-		     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/mscapi,\
+		     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/mscapi,\
 		INCLUDE_FILES:=security.cpp, \
 		LANG:=C++,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/security/mscapi \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/mscapi ,\
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
+                        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/mscapi ,\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=Crypt32.Lib advapi32.lib,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunmscapi))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=sunmscapi.dll" \
+			  /D "JDK_INTERNAL_NAME=sunmscapi" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunmscapi,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(BUILD_LIBSUNMSCAPI)
 endif
 
 ##########################################################################################
 
-ifneq ($(OPENJDK_TARGET_OS)-$(ARCH_DATA_MODEL), windows-64)
 $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PKCS11,\
 		LIBRARY:=j2pkcs11,\
                 OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
 		SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/pkcs11 \
-                     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11 \
+                     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/pkcs11 \
                      $(JDK_TOPDIR)/src/share/native/sun/security/pkcs11/wrapper \
-                     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11/wrapper,\
+                     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/pkcs11/wrapper,\
 		LANG:=C,\
 		OPTIMIZATION:=LOW, \
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/security/pkcs11 \
-		        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11 \
+		        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/pkcs11 \
 		        -I$(JDK_TOPDIR)/src/share/native/sun/security/pkcs11/wrapper \
-                        -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/security/pkcs11/wrapper,\
+                        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/pkcs11/wrapper,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2pkcs11/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX_posix:=$(LIBDL), \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pkcs11))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=j2pkcs11.dll" \
+			  /D "JDK_INTERNAL_NAME=j2pkcs11" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pkcs11,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJ2PKCS11)
-endif
 
 ##########################################################################################
 
@@ -2685,11 +2872,18 @@
 		CXXFLAGS:=$(filter-out $(ECC_JNI_SOLSPARC_FILTER), $(CXXFLAGS_JDKLIB)) \
                           $(BUILD_LIBSUNEC_FLAGS),\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libsunec/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB) \
-			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK),\
+		LDFLAGS_macosx:=$(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=$(LIBCXX),\
+                LDFLAGS_SUFFIX_linux:=-lc ,\
                 LDFLAGS_SUFFIX_solaris:=-lc ,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunec))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=sunec.dll" \
+			  /D "JDK_INTERNAL_NAME=sunec" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunec,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 BUILD_LIBRARIES += $(BUILD_LIBSUNEC)
 endif
@@ -2698,7 +2892,7 @@
 
 LIBJSOUND_SRC_DIRS:=\
 	$(JDK_TOPDIR)/src/share/native/com/sun/media/sound \
-	$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/com/sun/media/sound
+	$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/com/sun/media/sound
 
 LIBJSOUND_SRC_FILES:=Utilities.c Platform.c
 
@@ -2781,29 +2975,29 @@
 ifeq ($(JVM_VARIANT_ZERO), true)
 	LIBJSOUND_CFLAGS += -DX_ARCH=X_ZERO
 else
-  ifeq ($(ARCH), i586)
+  ifeq ($(OPENJDK_TARGET_CPU), x86)
 	LIBJSOUND_CFLAGS += -DX_ARCH=X_I586
-  endif # ARCH i586
-
-  ifeq ($(ARCH), sparc)
+  endif
+
+  ifeq ($(OPENJDK_TARGET_CPU), sparc)
 	LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARC
-  endif # ARCH sparc
-
-  ifeq ($(ARCH), sparcv9)
+  endif
+
+  ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
 	LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARCV9
-  endif # ARCH sparcv9
-
-  ifeq ($(ARCH), amd64)
+  endif
+
+  ifeq ($(OPENJDK_TARGET_CPU), x86_64)
 	LIBJSOUND_CFLAGS += -DX_ARCH=X_AMD64
-  endif # ARCH amd64
-
-  ifeq ($(ARCH), arm)
+  endif
+
+  ifeq ($(OPENJDK_TARGET_CPU), arm)
 	LIBJSOUND_CFLAGS += -DX_ARCH=X_ARM
-  endif # ARCH arm
-
-  ifeq ($(ARCH), ppc)
+  endif
+
+  ifeq ($(OPENJDK_TARGET_CPU), ppc)
 	LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC
-  endif # ARCH ppc
+  endif
 endif
 
 LIBJSOUND_CFLAGS += -DEXTRA_SOUND_JNI_LIBS='"$(EXTRA_SOUND_JNI_LIBS)"'
@@ -2815,18 +3009,25 @@
 		INCLUDE_FILES:=$(LIBJSOUND_SRC_FILES),\
 		LANG:=$(LIBJSOUND_LANG),\
 		OPTIMIZATION:=LOW, \
-		CFLAGS:=$(CFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \
+		CFLAGS:=$(CFLAGS_JDKLIB) \
+		        $(LIBJSOUND_CFLAGS), \
 		CXXFLAGS:=$(CXXFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjsound/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
+		LDFLAGS_macosx:=-framework CoreAudio -framework CoreFoundation \
+				-framework CoreServices -framework AudioUnit $(LIBCXX) \
+				-framework CoreMIDI -framework AudioToolbox,\
 		LDFLAGS_windows:=$(WIN_JAVA_LIB) advapi32.lib winmm.lib,\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
+		LDFLAGS_SUFFIX:=-ljava -ljvm,\
 		LDFLAGS_SUFFIX_solaris:=-lc ,\
-		LDFLAGS_SUFFIX_macosx:=-framework CoreAudio -framework CoreFoundation \
-             -framework CoreServices -framework AudioUnit $(LIBCXX) \
-             -framework CoreMIDI -framework AudioToolbox ,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsound))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=jsound.dll" \
+			  /D "JDK_INTERNAL_NAME=jsound" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsound,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBJSOUND) : $(BUILD_LIBJAVA)
 
@@ -2860,7 +3061,7 @@
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjsoundalsa/mapfile-vers, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) -lasound,\
+		LDFLAGS_SUFFIX:=-lasound -ljava -ljvm,\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundalsa))
 
 $(BUILD_LIBJSOUNDALSA) : $(BUILD_LIBJAVA)
@@ -2884,10 +3085,16 @@
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 			$(LIBJSOUND_CFLAGS) \
 			-DUSE_DAUDIO=TRUE, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB)\
+		LDFLAGS:=$(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) dsound.lib winmm.lib user32.lib ole32.lib,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundds))
+		VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
+		RC_FLAGS:=$(RC_FLAGS)\
+			  /D "JDK_FNAME=jsoundds.dll" \
+			  /D "JDK_INTERNAL_NAME=jsoundds" \
+			  /D "JDK_FTYPE=0x2L",\
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundds,\
+		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
 
 $(BUILD_LIBJSOUNDDS) : $(BUILD_LIBJAVA)
 
@@ -2909,8 +3116,7 @@
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/closed/solaris/native/com/oracle/security/ucrypto ,\
 		MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2ucrypto/mapfile-vers, \
-		LDFLAGS:=$(LDFLAGS_JDKLIB)\
-			 $(call SET_SHARED_LIBRARY_ORIGIN), \
+		LDFLAGS:=$(LDFLAGS_JDKLIB),\
 		LDFLAGS_SUFFIX:=$(LIBDL),\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2ucrypto))
 
@@ -2944,11 +3150,11 @@
                         -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX) \
-    -framework Cocoa \
-    -framework Carbon \
-    -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-    -framework JavaNativeFoundation, \
+		LDFLAGS_SUFFIX:=-framework Cocoa \
+                                -framework Carbon \
+                                -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
+                                -framework JavaNativeFoundation \
+                                $(LDFLAGS_JDKLIB_SUFFIX),\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libAppleScriptEngine))
 
 $(BUILD_LIBAPPLESCRIPTENGINE) : $(BUILD_LIBJAVA)
@@ -3161,20 +3367,19 @@
                         -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks,\
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX_macosx:=\
-	-lawt -lmlib_image -losxapp $(LDFLAGS_JDKLIB_SUFFIX) $(LIBM) \
-	-framework Accelerate \
-	-framework ApplicationServices \
-	-framework AudioToolbox \
-	-framework Carbon \
-	-framework Cocoa \
-	-framework Security \
-	-framework ExceptionHandling \
-        -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-	-framework JavaNativeFoundation \
-	-framework JavaRuntimeSupport \
-	-framework OpenGL \
-        -framework QuartzCore ,\
+		LDFLAGS_SUFFIX_macosx:=-lawt -lmlib_image -losxapp -ljvm $(LIBM) \
+				       -framework Accelerate \
+				       -framework ApplicationServices \
+				       -framework AudioToolbox \
+				       -framework Carbon \
+				       -framework Cocoa \
+				       -framework Security \
+				       -framework ExceptionHandling \
+				       -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
+				       -framework JavaNativeFoundation \
+				       -framework JavaRuntimeSupport \
+				       -framework OpenGL \
+				       -framework QuartzCore -ljava,\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_lwawt))
 
 BUILD_LIBRARIES += $(BUILD_LIBAWT_LWAWT)
@@ -3216,16 +3421,16 @@
 			-I$(JDK_TOPDIR)/src/macosx/native/sun/awt \
                         -F/System/Library/Frameworks/JavaVM.framework/Frameworks, \
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
-			 $(call SET_SHARED_LIBRARY_ORIGIN), \
-		LDFLAGS_SUFFIX_macosx:=\
-    $(LDFLAGS_JDKLIB_SUFFIX) \
-    -lawt -losxapp -lawt_lwawt \
-    -framework Cocoa \
-    -framework Carbon \
-    -framework ApplicationServices \
-    -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-    -framework JavaNativeFoundation \
-    -framework JavaRuntimeSupport, \
+			 $(call SET_SHARED_LIBRARY_ORIGIN) \
+			 -Xlinker -rpath -Xlinker @loader_path,\
+		LDFLAGS_SUFFIX_macosx:=-lawt -losxapp -lawt_lwawt \
+				       -framework Cocoa \
+				       -framework Carbon \
+				       -framework ApplicationServices \
+				       -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
+				       -framework JavaNativeFoundation \
+				       -framework JavaRuntimeSupport \
+				       -ljava -ljvm,\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxui))
 
 BUILD_LIBRARIES += $(BUILD_LIBOSXUI)
@@ -3244,9 +3449,33 @@
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
 
-$(eval $(call SetupNativeCompilation,BUILD_LIBJOBJC,\
+# Ugly hack to mimic behaviour in old build where this is built as an xcode project.
+SET_SHARED_LIBRARY_NAME=-Xlinker -install_name -Xlinker /usr/local/lib/libJObjC.dylib
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJOBJC32,\
 		LIBRARY:=JObjC,\
-                OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
+                OUTPUT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc32,\
+		SRC:=$(JDK_TOPDIR)/src/macosx/native/jobjc/src/core/native \
+                     $(JDK_TOPDIR)/src/macosx/native/jobjc/src/runtime-additions/native ,\
+		LANG:=C,\
+		OPTIMIZATION:=LOW, \
+		CFLAGS:=-fpascal-strings \
+                        -fobjc-gc \
+                        -gdwarf-2 \
+                        $(CFLAGS_JDKLIB) \
+                        -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
+			-m32,\
+		LDFLAGS:=$(LDFLAGS_JDKLIB)\
+			-m32, \
+		LDFLAGS_SUFFIX:=-framework Foundation -framework JavaVM \
+                                  -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
+                                  -framework JavaNativeFoundation \
+                                  -lffi, \
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc32))
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBJOBJC64,\
+		LIBRARY:=JObjC,\
+                OUTPUT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc64,\
 		SRC:=$(JDK_TOPDIR)/src/macosx/native/jobjc/src/core/native \
                      $(JDK_TOPDIR)/src/macosx/native/jobjc/src/runtime-additions/native ,\
 		LANG:=C,\
@@ -3266,9 +3495,12 @@
                                   -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
                                   -framework JavaNativeFoundation \
                                   -lffi, \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc))
-
-BUILD_LIBRARIES += $(BUILD_LIBJOBJC)
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc64))
+
+$(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)JObjC$(SHARED_LIBRARY_SUFFIX): $(BUILD_LIBJOBJC32) $(BUILD_LIBJOBJC64)
+	$(LIPO) -create -output $@ $(BUILD_LIBJOBJC32) $(BUILD_LIBJOBJC64)
+
+BUILD_LIBRARIES += $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)JObjC$(SHARED_LIBRARY_SUFFIX)
 
 endif
 
--- a/jdk/makefiles/CopyFiles.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/CopyFiles.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -47,12 +47,12 @@
 
 $(INCLUDEDIR)/%.h: $(JDK_TOPDIR)/src/share/javavm/export/%.h
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
-$(OPENJDK_TARGET_OS_INCLUDE)/%.h: $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/javavm/export/%.h
+$(OPENJDK_TARGET_OS_INCLUDE)/%.h: $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export/%.h
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES = $(H_TARGET_FILES)
@@ -64,7 +64,7 @@
 
 $(SERVICETAG_LIBDIR)/jdk_header.png: $(JDK_TOPDIR)/src/share/classes/com/sun/servicetag/resources/jdk_header.png
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 	$(CHMOD) 444 $@
 
@@ -79,20 +79,20 @@
 
 $(MGMT_LIBDIR)/management.properties: $(MGMT_LIB_SRC)/management.properties
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 	$(CHMOD) 644 $@
 
 # this file has different permissions...don't know why...
 $(MGMT_LIBDIR)/jmxremote.access: $(MGMT_LIB_SRC)/jmxremote.access
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 	$(CHMOD) 644 $@
 
 $(MGMT_LIBDIR)/%: $(MGMT_LIB_SRC)/%
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 	$(CHMOD) 444 $@
 
@@ -104,7 +104,7 @@
 
 $(LIBDIR)/logging.properties: $(LOGGING_LIB_SRC)/logging.properties
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(LIBDIR)/logging.properties
@@ -119,7 +119,7 @@
 
 $(LIBDIR)/%: $(PSFONTPROPFILE_SRC_DIR)/%
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(PSFONTPROPFILE_TARGET_FILES)
@@ -129,24 +129,24 @@
 # Copy flavormap.properties, cursor.properties and cursors gif files to LIBDIR
 #
 ifneq ($(OPENJDK_TARGET_OS), macosx)
-OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/lib
+OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib
 else
 OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/macosx/lib
 endif
 
 $(LIBDIR)/flavormap.properties: $(OPENJDK_TARGET_OS_LIB_SRC)/flavormap.properties
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(LIBDIR)/flavormap.properties
 
 CURSORS_DEST_DIR = $(LIBDIR)/images/cursors
-CURSORS_OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/lib/images/cursors
+CURSORS_OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib/images/cursors
 
 $(CURSORS_DEST_DIR)/cursors.properties: $(CURSORS_OPENJDK_TARGET_OS_LIB_SRC)/cursors.properties
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(CURSORS_DEST_DIR)/cursors.properties
@@ -161,18 +161,18 @@
 
 $(CURSORS_DEST_DIR)/%: $(CURSORS_LIB_SRC)/%
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(CURSORS_TARGET_FILES)
 
 ##########################################################################################
 
-CONTENT_TYPES_SRC=$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/lib
+CONTENT_TYPES_SRC=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib
 
 $(LIBDIR)/content-types.properties: $(CONTENT_TYPES_SRC)/content-types.properties
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(LIBDIR)/content-types.properties
@@ -183,7 +183,7 @@
 
 $(LIBDIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(LIBDIR)/calendars.properties
@@ -192,11 +192,11 @@
 
 ifeq ($(OPENJDK_TARGET_OS),windows)
 
-TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/lib
+TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib
 
 $(LIBDIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(LIBDIR)/tzmappings
@@ -218,7 +218,7 @@
 
 $(ICCPROFILE_DEST_DIR)%.pf: $(ICCPROFILE_SRC_DIR)%.pf
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 	$(CHMOD) 444 $@
 
@@ -248,7 +248,7 @@
         FREETYPE_LIB = $(JDK_OUTPUTDIR)/bin/$(call SHARED_LIBRARY,freetype)
     else 
         ifeq ($(USING_SYSTEM_FT_LIB), false)
-            FREETYPE_LIB = $(JDK_OUTPUTDIR)/lib/$(LIBARCH)/$(call SHARED_LIBRARY,freetype).6
+            FREETYPE_LIB = $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/$(call SHARED_LIBRARY,freetype).6
         endif
     endif 
 
@@ -269,7 +269,7 @@
     MSVCRNN_TARGET := $(JDK_OUTPUTDIR)/bin/$(notdir $(MSVCRNN_DLL))
     $(MSVCRNN_TARGET): $(MSVCRNN_DLL)
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
     COPY_FILES += $(MSVCRNN_TARGET)
@@ -281,7 +281,7 @@
 
 $(LIBDIR)/jvm.hprof.txt : $(HPROF_SRC)
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(LIBDIR)/jvm.hprof.txt
@@ -292,26 +292,21 @@
 # How to install jvm.cfg.
 #
 ifeq ($(JVM_VARIANT_ZERO), true)
-JVMCFG_ARCH := zero
+    JVMCFG_ARCH := zero
 else
-    JVMCFG_ARCH := $(ARCH)
+    JVMCFG_ARCH := $(OPENJDK_TARGET_CPU_LEGACY)
 endif
 
 ifeq ($(OPENJDK_TARGET_OS),macosx)
-  ifeq ($(JVMCFG_ARCH),amd64)
-      JVMCFG_ARCH := x86_64
-  endif
   JVMCFG_SRC := $(JDK_TOPDIR)/src/macosx/bin/$(JVMCFG_ARCH)/jvm.cfg
-  JVMCFG_DIR := $(JDK_OUTPUTDIR)/lib
 else
-  JVMCFG_SRC := $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/bin/$(JVMCFG_ARCH)/jvm.cfg
-  JVMCFG_DIR := $(JDK_OUTPUTDIR)/lib/$(LIBARCH)
+  JVMCFG_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin/$(JVMCFG_ARCH)/jvm.cfg
 endif
-
+JVMCFG_DIR := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)
 JVMCFG := $(JVMCFG_DIR)/jvm.cfg
 
 
-ifeq ($(ARCH_DATA_MODEL),32)
+ifeq ($(OPENJDK_TARGET_CPU_BITS),32)
     # On 32 bit machines, we can have client and/or server libjvms installed.
     # Since the currently committed jvm.cfg expects clientANDserver, we need 
     # to patch the jvm.cfg when we have built only a client or only a server.
@@ -320,7 +315,7 @@
         # Create a patched jvm.cfg to use -client by default and alias -server to -client.
         $(JVMCFG):
 		$(MKDIR) -p $(@D)
-		$(RM) -f $(JVMCFG)
+		$(RM) $(JVMCFG)
 		$(PRINTF) "-client KNOWN\n">$(JVMCFG)
 		$(PRINTF) "-server IGNORE\n">>$(JVMCFG)
 		$(PRINTF) "-hotspot ALIASED_TO -client\n">>$(JVMCFG)
@@ -334,7 +329,7 @@
 
             $(JVMCFG):
 		$(MKDIR) -p $(@D)
-		$(RM) -f $(JVMCFG)
+		$(RM) $(JVMCFG)
 		$(PRINTF) "-server KNOWN\n">$(JVMCFG)
 		$(PRINTF) "-client IGNORE\n">>$(JVMCFG)
 		$(PRINTF) "-hotspot IGNORE\n">>$(JVMCFG)
@@ -345,7 +340,7 @@
             # Use the default jvm.cfg for this 32 bit setup. 
             $(JVMCFG): $(JVMCFG_SRC)
 	    	$(MKDIR) -p $(@D)
-		$(RM) -f $@
+		$(RM) $@
 		$(CP) $< $@
         endif
     endif
@@ -353,7 +348,7 @@
     # Use the default jvm.cfg for this 64 bit setup.
     $(JVMCFG): $(JVMCFG_SRC)
 		$(MKDIR) -p $(@D)
-		$(RM) -f $@
+		$(RM) $@
 		$(CP) $< $@
 endif
 
@@ -378,7 +373,7 @@
 
 $(PROPS_DST): $(PROPS_SRC)
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(PROPS_DST)
@@ -390,7 +385,7 @@
 
 $(POLICY_DST): $(POLICY_SRC)
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(POLICY_DST)
@@ -402,7 +397,7 @@
 
 $(CACERTS_DST): $(CACERTS_SRC)
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(CACERTS_DST)
@@ -419,14 +414,14 @@
 
 $(BLACKLIST_DST): $(BLACKLIST_SRC)
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(BLACKLIST_DST)
 
 $(TRUSTEDLIBS_DST): $(TRUSTEDLIBS_SRC)
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(TRUSTEDLIBS_DST)
@@ -462,7 +457,11 @@
 	$(RM) $@
 	$(CP) $< $@
 
-COPY_FILES += $(SHARED_FONTS_DST) $(SHARED_FONTS_DST_DIR)/fonts.dir
+COPY_FILES += $(SHARED_FONTS_DST)
+
+ifneq ($(OPENJDK_TARGET_OS), windows)
+    COPY_FILES += $(SHARED_FONTS_DST_DIR)/fonts.dir
+endif
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
 
@@ -537,21 +536,21 @@
 
 _DGALIBS_amd64 = 	# no amd64 library yet
 
-DGALIBS = $(_DGALIBS_$(ARCH):%=$(JDK_OUTPUTDIR)/lib/$(LIBARCH)/%)
+DGALIBS = $(_DGALIBS_$(OPENJDK_TARGET_CPU_LEGACY):%=$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/%)
 
-$(JDK_OUTPUTDIR)/lib/$(LIBARCH)/libxinerama.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(ARCH)/libxinerama.so
+$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libxinerama.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(OPENJDK_TARGET_CPU_LEGACY)/libxinerama.so
 	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(CP) $< $@
 	$(CHMOD) 755 $@
 
-$(JDK_OUTPUTDIR)/lib/$(LIBARCH)/libjdgaSUNW%.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(ARCH)/libjdgaSUNW%.so
+$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNW%.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(OPENJDK_TARGET_CPU_LEGACY)/libjdgaSUNW%.so
 	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(CP) $< $@
 	$(CHMOD) 755 $@
 
-$(JDK_OUTPUTDIR)/lib/$(LIBARCH)/libjdgaSUNWafb.so: $(JDK_OUTPUTDIR)/lib/$(LIBARCH)/libjdgaSUNWffb.so
+$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNWafb.so: $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNWffb.so
 	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(LN) -s $< $@
--- a/jdk/makefiles/CopyIntoClasses.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/CopyIntoClasses.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -174,11 +174,11 @@
 $(shell $(MKDIR) -p $(JDK_OUTPUTDIR)/classes/META-INF/services)
 # Find all META-INF/services/* files
 ALL_META-INF_DIRS_share:=$(shell $(FIND) $(JDK_TOPDIR)/src/share/classes -type d -a -name META-INF)
-ALL_META-INF_DIRS_targetapi:=$(shell $(FIND) $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes -type d -a -name META-INF)
+ALL_META-INF_DIRS_targetapi:=$(shell $(FIND) $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes -type d -a -name META-INF)
 # Platform specific overrides shared
 ifneq ($(ALL_META-INF_DIRS_targetapi),)
     ALL_META-INF_DIRS:=$(ALL_META-INF_DIRS_targetapi) \
-	$(filter-out %$(patsubst $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes%,%,$(ALL_META-INF_DIRS_targetapi)),\
+	$(filter-out %$(patsubst $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes%,%,$(ALL_META-INF_DIRS_targetapi)),\
 		$(ALL_META-INF_DIRS_share))
 else
     ALL_META-INF_DIRS:=$(ALL_META-INF_DIRS_share)
@@ -216,9 +216,9 @@
 	$(shell $(PRINTF) "$(SRC_SERVICES_FILES)\n" | $(SED) -e 's|/[^ ]*/META-INF/services/||g'))
 OUT_SERVICES_FILES_COLON:=$(addsuffix :,$(OUT_SERVICES_FILES))
 # Exception handling for print services with no META-INF directory
-SRC_SERVICES_FILES_PRINT = $(wildcard $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes/sun/print/services/*)
+SRC_SERVICES_FILES_PRINT = $(wildcard $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes/sun/print/services/*)
 OUT_SERVICES_FILES_PRINT = $(addprefix $(JDK_OUTPUTDIR)/classes/META-INF/services/,\
-	$(patsubst $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes/sun/print/services/%,%,\
+	$(patsubst $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes/sun/print/services/%,%,\
 		$(SRC_SERVICES_FILES_PRINT)))
 OUT_SERVICES_FILES_PRINT_COLON = $(addsuffix :,$(OUT_SERVICES_FILES_PRINT))
 RULES_SERVICES_PRINT = $(join $(OUT_SERVICES_FILES_PRINT_COLON),$(SRC_SERVICES_FILES_PRINT))
@@ -257,23 +257,10 @@
             javax.sound.midi.spi.SoundbankReader \
             javax.sound.sampled.spi.AudioFileReader \
             javax.sound.sampled.spi.AudioFileWriter \
-            javax.sound.sampled.spi.FormatConversionProvider
-
-COPY_EXTRA += $(foreach F,$(notdir $(JAVAX_SOUND_SRC_FILES)),$(JDK_OUTPUTDIR)/classes/META-INF/services/${F})
+            javax.sound.sampled.spi.FormatConversionProvider \
+            javax.sound.sampled.spi.MixerProvider
 
-ifeq ($(OPENJDK_TARGET_OS)-$(ARCH),windows-ia64)
-	JAVAX_SOUND_SRC_FILES += windows-ia64/javax.sound.sampled.spi.MixerProvider
-	COPY_EXTRA += $(JDK_OUTPUTDIR)/classes/META-INF/services/javax.sound.sampled.spi.MixerProvider
-else ifeq ($(OPENJDK_TARGET_OS),windows)
-	JAVAX_SOUND_SRC_FILES += windows-i586/javax.sound.sampled.spi.MixerProvider
-	COPY_EXTRA += $(JDK_OUTPUTDIR)/classes/META-INF/services/javax.sound.sampled.spi.MixerProvider
-else ifeq ($(OPENJDK_TARGET_OS)-$(ARCH),linux-i586)
-	JAVAX_SOUND_SRC_FILES += linux-i586/javax.sound.sampled.spi.MixerProvider
-	COPY_EXTRA += $(JDK_OUTPUTDIR)/classes/META-INF/services/javax.sound.sampled.spi.MixerProvider
-else
-	JAVAX_SOUND_SRC_FILES += javax.sound.sampled.spi.MixerProvider
-	COPY_EXTRA += $(JDK_OUTPUTDIR)/classes/META-INF/services/javax.sound.sampled.spi.MixerProvider
-endif
+COPY_EXTRA += $(addprefix $(JDK_OUTPUTDIR)/classes/META-INF/services/,$(JAVAX_SOUND_SRC_FILES))
 
 JAVAX_SOUND_RULES := $(foreach F,$(JAVAX_SOUND_SRC_FILES),$(JDK_OUTPUTDIR)/classes/META-INF/services/$(notdir $F):$(JAVAX_SOUND_SRC)/$F)
 
--- a/jdk/makefiles/CopySamples.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/CopySamples.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -54,17 +54,17 @@
 
 $(SAMPLE_TARGET_DIR)/dtrace/%: $(SAMPLE_SOLARIS_SOURCE_DIR)/dtrace/%
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 $(SAMPLE_TARGET_DIR)/webservices/%: $(SAMPLE_CLOSED_SOURCE_DIR)/webservices/%
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 $(SAMPLE_TARGET_DIR)/%: $(SAMPLE_SOURCE_DIR)/%
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@
+	$(RM) $@
 	$(CP) $< $@
 
 COPY_FILES += $(SAMPLE_TARGET)
--- a/jdk/makefiles/CreateJars.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/CreateJars.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -151,10 +151,12 @@
 	sun/security/ec/ECDSASignature\$$$$SHA384.class \
 	sun/security/ec/ECDSASignature\$$$$SHA512.class \
 	sun/security/ec/ECDSASignature.class \
+	sun/security/ec/ECKeyFactory.class \
 	sun/security/ec/ECKeyPairGenerator.class \
 	sun/security/ec/SunEC\$$$$1.class \
 	sun/security/ec/SunEC.class \
 	sun/security/ec/SunECEntries.class \
+	sun/security/mscapi \
 	sun/security/pkcs11 \
 	com/sun/net/ssl/internal/ssl \
 	javax/crypto \
@@ -260,50 +262,64 @@
 
 # Find all files in the classes dir to use as dependencies. This could be more fine granular.
 ALL_FILES_IN_CLASSES := $(shell $(FIND) $(JDK_OUTPUTDIR)/classes -type f \
-			| $(GREP) -v -e '/_the\.*' -e '^_the\.*')
+			| $(GREP) -v -e '/_the\.*' -e '^_the\.*' -e 'javac_state')
 
 RT_JAR_MANIFEST_FILE := $(JDK_OUTPUTDIR)/lib/_the.rt.jar_manifest
 RESOURCE_JAR_MANIFEST_FILE := $(JDK_OUTPUTDIR)/lib/_the.resources.jar_manifest
 
 $(RT_JAR_MANIFEST_FILE): $(MAINMANIFEST) $(BEANMANIFEST)
 	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	$(SED) -e "s#@@RELEASE@@#$(RELEASE)#" 		\
 	       -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \
-	       $(MAINMANIFEST) >> $@
-	$(ECHO) >> $@
-	$(CAT) $(BEANMANIFEST) >> $@
+	       $(MAINMANIFEST) >> $@.tmp
+	$(ECHO) >> $@.tmp
+	$(CAT) $(BEANMANIFEST) >> $@.tmp
+	$(MV) $@.tmp $@
 
 $(RESOURCE_JAR_MANIFEST_FILE): $(MAINMANIFEST)
 	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	$(SED) -e "s#@@RELEASE@@#$(RELEASE)#" 		\
 	       -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \
-	       $(MAINMANIFEST) >> $@
+	       $(MAINMANIFEST) >> $@.tmp
+	$(MV) $@.tmp $@
 
 $(JDK_OUTPUTDIR)/lib/_the.jars.exclude: $(MAKEFILE)
 	$(MKDIR) -p $(@D)
-	$(call ListPathsSafely,RT_JAR_EXCLUDES,\n, >> $@)
+	$(RM) $@ $@.tmp
+	$(call ListPathsSafely,RT_JAR_EXCLUDES,\n, >> $@.tmp)
+	$(MV) $@.tmp $@
 
 $(JDK_OUTPUTDIR)/lib/classlist : $(JDK_TOPDIR)/make/tools/sharing/classlist.$(OPENJDK_TARGET_OS) \
   $(MAKEFILE)
 	$(MKDIR) -p $(@D)
-	$(RM) -f $@.temp
-	$(TOOL_ADDJSUM) $< $@.temp
-	$(MV) $@.temp $@
+	$(RM) $@ $@.tmp
+	$(TOOL_ADDJSUM) $< $@.tmp
+	$(MV) $@.tmp $@
 
 $(JDK_OUTPUTDIR)/lib/_the.jars.contents: $(BUILD_TOOLS) $(JDK_OUTPUTDIR)/lib/_the.jars.exclude \
 					 $(ALL_FILES_IN_CLASSES) $(JDK_OUTPUTDIR)/lib/classlist
 	$(MKDIR) -p $(@D)
-	$(RM) $@.temp
+	$(RM) $@ $@.tmp
 	($(CD) $(JDK_OUTPUTDIR)/classes && \
 	    $(TOOL_JARREORDER) \
-		-o  $@.temp $(JDK_OUTPUTDIR)/lib/classlist $(JDK_OUTPUTDIR)/lib/_the.jars.exclude . )
-	$(MV) $@.temp $@
+		-o  $@.tmp $(JDK_OUTPUTDIR)/lib/classlist $(JDK_OUTPUTDIR)/lib/_the.jars.exclude . )
+	$(MV) $@.tmp $@
 
 $(JDK_OUTPUTDIR)/lib/_the.rt.jar.contents: $(JDK_OUTPUTDIR)/lib/_the.jars.contents
-	$(GREP) -e '\.class$$' $(JDK_OUTPUTDIR)/lib/_the.jars.contents > $@
+	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
+	$(GREP) -e '\.class$$' $(JDK_OUTPUTDIR)/lib/_the.jars.contents > $@.tmp
+	$(MV) $@.tmp $@
 
 $(JDK_OUTPUTDIR)/lib/_the.resources.jar.contents: $(JDK_OUTPUTDIR)/lib/_the.jars.contents
-	$(GREP) -v -e '\.class$$' -e '/_the\.*' -e '^_the\.*' $(JDK_OUTPUTDIR)/lib/_the.jars.contents > $@
+	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
+	$(GREP) -v -e '\.class$$' \
+	    -e '/_the\.*' -e '^_the\.*' -e '\\_the\.*' -e 'javac_state' \
+	    $(JDK_OUTPUTDIR)/lib/_the.jars.contents > $@.tmp
+	$(MV) $@.tmp $@
 
 RT_JAR_CREATE_OPTIONS := c0fm
 ifeq ($(COMPRESS_JARS), true)
@@ -312,16 +328,22 @@
 
 $(JDK_OUTPUTDIR)/lib/rt.jar: $(JDK_OUTPUTDIR)/lib/_the.rt.jar.contents $(RT_JAR_MANIFEST_FILE)
 	$(ECHO) Creating rt.jar
+	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	$(CD) $(JDK_OUTPUTDIR)/classes && \
-	    $(JAR) $(RT_JAR_CREATE_OPTIONS) $@ $(RT_JAR_MANIFEST_FILE) \
+	    $(JAR) $(RT_JAR_CREATE_OPTIONS) $@.tmp $(RT_JAR_MANIFEST_FILE) \
 	        @$(JDK_OUTPUTDIR)/lib/_the.rt.jar.contents
+	$(MV) $@.tmp $@
 
 $(JDK_OUTPUTDIR)/lib/resources.jar: $(JDK_OUTPUTDIR)/lib/_the.resources.jar.contents \
 				    $(RESOURCE_JAR_MANIFEST_FILE)
 	$(ECHO) Creating resources.jar
+	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	$(CD) $(JDK_OUTPUTDIR)/classes && \
-	    $(JAR) $(RT_JAR_CREATE_OPTIONS) $@ $(RESOURCE_JAR_MANIFEST_FILE) \
+	    $(JAR) $(RT_JAR_CREATE_OPTIONS) $@.tmp $(RESOURCE_JAR_MANIFEST_FILE) \
 	        @$(JDK_OUTPUTDIR)/lib/_the.resources.jar.contents
+	$(MV) $@.tmp $@
 
 JARS+=$(JDK_OUTPUTDIR)/lib/rt.jar $(JDK_OUTPUTDIR)/lib/resources.jar
 
@@ -385,31 +407,30 @@
 
 ##########################################################################################
 
-ifneq ($(OPENJDK_TARGET_OS)-$(ARCH_DATA_MODEL),windows-64)
-    SUNPKCS11_JAR_DST := $(JDK_OUTPUTDIR)/lib/ext/sunpkcs11.jar
+SUNPKCS11_JAR_DST := $(JDK_OUTPUTDIR)/lib/ext/sunpkcs11.jar
 
-    ifndef OPENJDK
+ifndef OPENJDK
+
+    SUNPKCS11_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/pkcs11/sunpkcs11.jar
 
-        SUNPKCS11_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/pkcs11/sunpkcs11.jar
-
-        $(SUNPKCS11_JAR_DST) : $(SUNPKCS11_JAR_SRC)
-		@$(ECHO) "\n>>>Installing prebuilt SunPKCS11 provider..."
-		$(RM) $@
-		$(CP) $< $@
+    $(SUNPKCS11_JAR_DST) : $(SUNPKCS11_JAR_SRC)
+	@$(ECHO) "\n>>>Installing prebuilt SunPKCS11 provider..."
+	$(MKDIR) -p $(@D)
+	$(RM) $@
+	$(CP) $< $@
 
-    else
+else
 
-         $(eval $(call SetupArchive,BUILD_SUNPKCS11_JAR,$(SUNPKCS11_JAR_DEPS),\
-		SRCS:=$(JDK_OUTPUTDIR)/classes, \
-		SUFFIXES:=.class,\
-		INCLUDES:=sun/security/pkcs11,\
-		JAR:=$(SUNPKCS11_JAR_DST), \
-		SKIP_METAINF := true))
+    $(eval $(call SetupArchive,BUILD_SUNPKCS11_JAR,$(SUNPKCS11_JAR_DEPS),\
+	SRCS:=$(JDK_OUTPUTDIR)/classes, \
+	SUFFIXES:=.class,\
+	INCLUDES:=sun/security/pkcs11,\
+	JAR:=$(SUNPKCS11_JAR_DST), \
+	SKIP_METAINF := true))
 
-    endif
+endif
 
-    JARS += $(SUNPKCS11_JAR_DST)
-endif
+JARS += $(SUNPKCS11_JAR_DST)
 
 ##########################################################################################
 
@@ -421,6 +442,7 @@
 
 $(SUNEC_JAR_DST) : $(SUNEC_JAR_SRC)
 	@$(ECHO) "\n>>>Installing prebuilt SunEC provider..."
+	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(CP) $< $@
 
@@ -430,12 +452,6 @@
 		SRCS:=$(JDK_OUTPUTDIR)/classes, \
 		SUFFIXES:=.class,\
 		INCLUDES:=sun/security/ec,\
-		EXCLUDE_FILES := sun/security/ec/ECKeyFactory.class \
-			sun/security/ec/ECParameters.class \
-			sun/security/ec/ECPrivateKeyImpl.class \
-			sun/security/ec/ECPublicKeyImpl.class \
-			sun/security/ec/NamedCurve.class \
-			sun/security/ec/ECKeyFactory*,\
 		JAR:=$(SUNEC_JAR_DST), \
 		SKIP_METAINF := true))
 
@@ -465,6 +481,7 @@
 
     $(SUNJCE_PROVIDER_JAR_DST) : $(SUNJCE_PROVIDER_JAR_SRC)
 	@$(ECHO) "\n>>>Installing prebuilt SunJCE provider..."
+	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(CP) $< $@
 else
@@ -489,6 +506,7 @@
 
 $(JCE_JAR_DST) : $(JCE_JAR_SRC)
 	@$(ECHO) "\n>>>Installing prebuilt jce.jar..."
+	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(CP) $< $@
 
@@ -520,6 +538,7 @@
 
 $(US_EXPORT_POLICY_JAR_TMP)/% : $(US_EXPORT_POLICY_JAR_SRC_DIR)/%
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(CP) $< $@
 
 US_EXPORT_POLICY_JAR_DEPS := $(US_EXPORT_POLICY_JAR_TMP)/default_US_export.policy
@@ -552,6 +571,7 @@
 
 $(LOCAL_POLICY_JAR_TMP)/% : $(LOCAL_POLICY_JAR_SRC_DIR)/%
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(CP) $< $@
 
 $(eval $(call SetupArchive,BUILD_LOCAL_POLICY_JAR,$(LOCAL_POLICY_JAR_DEPS),\
@@ -576,6 +596,7 @@
 
 $(SUNMSCAPI_JAR_DST) : $(SUNMSCAPI_JAR_SRC)
 	@$(ECHO) "\n>>>Installing prebuilt SunMSCAPI provider..."
+	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(CP) $< $@
 
@@ -586,9 +607,9 @@
 		SUFFIXES:=.class,\
 		INCLUDES:= sun/security/mscapi,\
 		JAR:=$(SUNMSCAPI_JAR_DST), \
-		MANIFEST := $(JDK_TOPDIR)/make/tools/manifest.mf, \
-		EXTRA_MANIFEST_ATTR := Extension-Name: javax.crypto\nImplementation-Vendor-Id: com.sun, \
-		SKIP_METAINF := true))
+		MANIFEST:=$(JDK_TOPDIR)/make/tools/manifest.mf, \
+		EXTRA_MANIFEST_ATTR:=Extension-Name: javax.crypto\nImplementation-Vendor-Id: com.sun, \
+		SKIP_METAINF:=true))
 endif
 
 JARS += $(SUNMSCAPI_JAR_DST)
@@ -605,6 +626,7 @@
 
 $(UCRYPTO_JAR_DST) : $(UCRYPTO_JAR_SRC)
 	@$(ECHO) "\n>>>Installing prebuilt OracleUcrypto provider..."
+	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(CP) $< $@
 
@@ -711,8 +733,8 @@
 
 ##########################################################################################
 
-include $(JDK_TOPDIR)/makefiles/docs/CORE_PKGS.gmk
-include $(JDK_TOPDIR)/makefiles/docs/NON_CORE_PKGS.gmk
+include javadoc/CORE_PKGS.gmk
+include javadoc/NON_CORE_PKGS.gmk
 
 # The compiler should not issue a "Proprietary" warning when compiling
 # classes in the com.sun.java.swing.plaf packages, since we've always
@@ -740,7 +762,7 @@
                         com.oracle.nio
 
 $(IMAGES_OUTPUTDIR)/symbols/_the.symbols: $(JDK_OUTPUTDIR)/lib/rt.jar
-	$(RM) -rf $(IMAGES_OUTPUTDIR)/symbols/META-INF/sym
+	$(RM) -r $(IMAGES_OUTPUTDIR)/symbols/META-INF/sym
 	$(MKDIR) -p $(IMAGES_OUTPUTDIR)/symbols/META-INF/sym
 	$(JAVA) \
 		-Xbootclasspath/a:$(JDK_OUTPUTDIR)/classes \
@@ -808,9 +830,10 @@
 	org/ietf			\
 	org/omg				\
 	org/w3c/dom			\
-	org/xml/sax
+	org/xml/sax			\
+	sunw
 
-SRC_ZIP_SRCS = $(JDK_TOPDIR)/src/share/classes $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes
+SRC_ZIP_SRCS = $(JDK_TOPDIR)/src/share/classes $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes
 SRC_ZIP_SRCS += $(JDK_OUTPUTDIR)/gensrc
 SRC_ZIP_SRCS += $(JDK_OUTPUTDIR)/impsrc
 SRC_ZIP_SRCS += $(JDK_OUTPUTDIR)/gendocsrc_rmic
@@ -821,17 +844,19 @@
 # Need to copy launcher src files into desired directory structure
 # before zipping the sources.
 LAUNCHER_SRC_FILES := $(wildcard $(JDK_TOPDIR)/src/share/bin/*) \
-                      $(wildcard $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/bin/java_md*)
+                      $(wildcard $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin/java_md*)
 LAUNCHER_ZIP_SRC := $(patsubst $(JDK_TOPDIR)/src/share/bin/%,$(IMAGES_OUTPUTDIR)/src/launcher/%,\
-		    $(patsubst $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/bin/%,$(IMAGES_OUTPUTDIR)/src/launcher/%,\
+		    $(patsubst $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin/%,$(IMAGES_OUTPUTDIR)/src/launcher/%,\
 			$(LAUNCHER_SRC_FILES)))
 
 $(IMAGES_OUTPUTDIR)/src/launcher/%: $(JDK_TOPDIR)/src/share/bin/%
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(CP) $< $@
 
-$(IMAGES_OUTPUTDIR)/src/launcher/%: $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/bin/%
+$(IMAGES_OUTPUTDIR)/src/launcher/%: $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin/%
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(CP) $< $@
 
 $(IMAGES_OUTPUTDIR)/src.zip: $(LAUNCHER_ZIP_SRC)
@@ -849,6 +874,10 @@
 
 ##########################################################################################
 
+-include $(CUSTOM_MAKE_DIR)/CreateJars.gmk
+
+##########################################################################################
+
 all: $(JARS)
 
 .PHONY: default all
--- a/jdk/makefiles/GendataBreakIterator.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GendataBreakIterator.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -48,10 +48,12 @@
 # two files in that directory and not get anything implicit from
 # surrounding directories which aren't jdk 6 compatible. 
 # Because we are targeting jdk 6, but the surrounding source code is jdk 7. Ugh.
-# These two files should be moved out to a build tool!
+# These two files should be moved out to a build tool! We have to disable
+# sjavac here as well.
 $(eval $(call SetupJavaCompilation,BUILD_BREAKITERATOR,\
 		SETUP:=GENERATE_OLDBYTECODE,\
 		SRC:=$(TEXT_SRCDIR),\
+		DISABLE_SJAVAC:=true,\
 		JAVAC_SOURCE_PATH_UGLY_OVERRIDE:=$(TEXT_SRCDIR)/$(TEXT_PKG),\
 		INCLUDES:=$(TEXT_PKG),\
 		INCLUDE_FILES:=$(TEXT_SOURCES),\
@@ -70,23 +72,23 @@
 BIFILES_TH =	$(DATA_PKG_DIR)/th/WordBreakIteratorData_th \
 		$(DATA_PKG_DIR)/th/LineBreakIteratorData_th
 
-$(BIFILES): $(BREAK_ITERATOR_DIR)/_the.bifiles
-$(BREAK_ITERATOR_DIR)/_the.bifiles: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES)
-$(BREAK_ITERATOR_DIR)/_the.bifiles: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR)
+$(BIFILES): $(DATA_PKG_DIR)/_the.bifiles
+$(DATA_PKG_DIR)/_the.bifiles: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES)
+$(DATA_PKG_DIR)/_the.bifiles: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR)
 	$(ECHO) "Generating BreakIteratorData"
 	$(MKDIR) -p  $(DATA_PKG_DIR)
-	$(RM) -f $(BIFILES)
+	$(RM) $(BIFILES)
 	$(TOOL_GENERATEBREAKITERATORDATA) \
 		-o $(DATA_PKG_DIR) \
 		-spec $(UNICODEDATA)
 	$(TOUCH) $@
 
-$(BIFILES_TH): $(BREAK_ITERATOR_DIR)/_the.bifiles_th
-$(BREAK_ITERATOR_DIR)/_the.bifiles_th: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES)
-$(BREAK_ITERATOR_DIR)/_the.bifiles_th: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR)
+$(BIFILES_TH): $(DATA_PKG_DIR)/_the.bifiles_th
+$(DATA_PKG_DIR)/_the.bifiles_th: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES)
+$(DATA_PKG_DIR)/_the.bifiles_th: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR)
 	$(ECHO) "Generating BreakIteratorData_th"
 	$(MKDIR) -p  $(DATA_PKG_DIR)/th
-	$(RM) -f $(BIFILES_TH)
+	$(RM) $(BIFILES_TH)
 	$(TOOL_GENERATEBREAKITERATORDATA) \
 		-o $(DATA_PKG_DIR) \
 		-spec $(UNICODEDATA) \
--- a/jdk/makefiles/GendataFontConfig.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GendataFontConfig.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -26,53 +26,61 @@
 GENDATA_FONT_CONFIG_DST := $(JDK_OUTPUTDIR)/lib
 
 ifeq ($(OPENJDK_TARGET_OS), windows)
-GENDATA_FONT_CONFIG_SRC_DIR    := $(JDK_TOPDIR)/src/windows/classes/sun/awt/windows
-GENDATA_FONT_CONFIG_SRC_FILES  := fontconfig.properties
-GENDATA_FONT_CONFIG_SRC_PREFIX := 
+  GENDATA_FONT_CONFIG_SRC_DIR    := $(JDK_TOPDIR)/src/windows/classes/sun/awt/windows
+  GENDATA_FONT_CONFIG_SRC_FILES  := fontconfig.properties
+  GENDATA_FONT_CONFIG_SRC_PREFIX := 
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
-GENDATA_FONT_CONFIG_SRC_PREFIX := linux.
-ifdef OPENJDK
-GENDATA_FONT_CONFIG_SRC_DIR   := $(JDK_TOPDIR)/src/solaris/classes/sun/awt/fontconfigs
-GENDATA_FONT_CONFIG_SRC_FILES := \
+  GENDATA_FONT_CONFIG_SRC_PREFIX := linux.
+  ifdef OPENJDK
+    GENDATA_FONT_CONFIG_SRC_DIR   := \
+        $(JDK_TOPDIR)/src/solaris/classes/sun/awt/fontconfigs
+    GENDATA_FONT_CONFIG_SRC_FILES := \
 	fontconfig.properties \
 	fontconfig.SuSE.properties \
 	fontconfig.Ubuntu.properties \
 	fontconfig.Fedora.properties
-else
-GENDATA_FONT_CONFIG_SRC_DIR   := $(JDK_TOPDIR)/src/closed/solaris/classes/sun/awt/fontconfigs
-GENDATA_FONT_CONFIG_SRC_FILES := \
+  else
+    GENDATA_FONT_CONFIG_SRC_DIR   := \
+        $(JDK_TOPDIR)/src/closed/solaris/classes/sun/awt/fontconfigs
+    GENDATA_FONT_CONFIG_SRC_FILES := \
 	fontconfig.properties				\
 	fontconfig.RedHat.5.properties			\
 	fontconfig.RedHat.6.properties			\
 	fontconfig.Turbo.properties			\
 	fontconfig.SuSE.10.properties                   \
 	fontconfig.SuSE.11.properties
-endif
+  endif
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), solaris)
-GENDATA_FONT_CONFIG_SRC_DIR    := $(JDK_TOPDIR)/src/solaris/classes/sun/awt/fontconfigs
-GENDATA_FONT_CONFIG_SRC_FILES  := fontconfig.properties
-GENDATA_FONT_CONFIG_SRC_PREFIX := solaris.
+  GENDATA_FONT_CONFIG_SRC_DIR    := \
+      $(JDK_TOPDIR)/src/solaris/classes/sun/awt/fontconfigs
+  GENDATA_FONT_CONFIG_SRC_FILES  := fontconfig.properties
+  GENDATA_FONT_CONFIG_SRC_PREFIX := solaris.
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
-GENDATA_FONT_CONFIG_SRC_DIR    := $(JDK_TOPDIR)/src/macosx/classes/sun/awt/fontconfigs
-GENDATA_FONT_CONFIG_SRC_FILES  := fontconfig.properties
-GENDATA_FONT_CONFIG_SRC_PREFIX := macosx.
-endif # OPENJDK_TARGET_OS
+  GENDATA_FONT_CONFIG_SRC_DIR    := \
+      $(JDK_TOPDIR)/src/macosx/classes/sun/awt/fontconfigs
+  GENDATA_FONT_CONFIG_SRC_FILES  := fontconfig.properties
+  GENDATA_FONT_CONFIG_SRC_PREFIX := macosx.
+endif
 
 ###
 
-$(GENDATA_FONT_CONFIG_DST)/%.src : $(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)%
+$(GENDATA_FONT_CONFIG_DST)/%.src : \
+    $(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)%
+	$(RM) $@
 	$(MKDIR) -p $(@D)
 	$(CP) $< $@
 	$(CHMOD) 644 $@
 
-$(GENDATA_FONT_CONFIG_DST)/%.bfc : $(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)%.properties
+$(GENDATA_FONT_CONFIG_DST)/%.bfc : \
+    $(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)%.properties
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(TOOL_COMPILEFONTCONFIG) $< $@
 	$(CHMOD) 444 $@
 
@@ -84,3 +92,4 @@
 GENDATA_FONT_CONFIG := $(GENDATA_FONT_CONFIGS) $(GENDATA_BFONT_CONFIGS)
 
 ###
+
--- a/jdk/makefiles/GendataTimeZone.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GendataTimeZone.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -46,9 +46,9 @@
 GENDATA_TIMEZONE_MAPFILE:=ZoneInfoMappings
 
 $(GENDATA_TIMEZONE_DST)/$(GENDATA_TIMEZONE_MAPFILE) : $(TZFILES)
-	$(RM) -rf $(GENDATA_TIMEZONE_TMP)
+	$(RM) -r $(GENDATA_TIMEZONE_TMP)
 	$(MKDIR) -p $(GENDATA_TIMEZONE_TMP)
-	$(RM) -rf $(GENDATA_TIMEZONE_DST)
+	$(RM) -r $(GENDATA_TIMEZONE_DST)
 	$(MKDIR) -p $(GENDATA_TIMEZONE_DST)
 	$(TOOL_JAVAZIC) -V "$(GENDATA_TIMEZONE_VERSION)" -d $(GENDATA_TIMEZONE_TMP) $(TZFILES)
 	$(CP) -r $(GENDATA_TIMEZONE_TMP)/* $(GENDATA_TIMEZONE_DST)/
--- a/jdk/makefiles/GenerateClasses.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GenerateClasses.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -31,7 +31,7 @@
 
 # To ensure the latest stub generator files are picked up from corba repo
 # when available, we need to run with latest rmic version available. 
-ifeq ($(CROSS_COMPILE_ARCH),)
+ifneq ($(COMPILE_TYPE),cross)
     RMIC := $(UNCYGDRIVE) $(JDK_OUTPUTDIR)/bin/rmic
 endif  
 
--- a/jdk/makefiles/GenerateData.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GenerateData.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -67,8 +67,8 @@
 $(GENDATA_CURDATA): $(JDK_TOPDIR)/src/share/classes/java/util/CurrencyData.properties $(BUILD_TOOLS)
 	$(MKDIR) -p $(@D)
 	$(RM) $@
-	$(TOOL_GENERATECURRENCYDATA) -o $@.temp < $<
-	$(MV) $@.temp $@
+	$(TOOL_GENERATECURRENCYDATA) -o $@.tmp < $<
+	$(MV) $@.tmp $@
 	$(CHMOD) 444 $@
 
 GENDATA += $(GENDATA_CURDATA)
@@ -77,6 +77,9 @@
 
 $(GENDATA) : $(BUILD_TOOLS)
 
-all: $(GENDATA)
+$(JDK_OUTPUTDIR)/classes/_the.gendata : $(GENDATA)
+	$(TOUCH) $@
+
+all: $(JDK_OUTPUTDIR)/classes/_the.gendata
 
 .PHONY: all
--- a/jdk/makefiles/GensrcBuffer.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GensrcBuffer.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -226,7 +226,7 @@
 	endif
 
 $$($1_DST) : $$($1_DEP) $(GENSRC_BUFFER_DST)/_the.dir
-	$(TOOL_SPP) < $$($1_SRC) > $$($1_OUT).temp \
+	$(TOOL_SPP) < $$($1_SRC) > $$($1_OUT).tmp \
 		-K$$($1_type) \
 		-K$$($1_category) \
 		-Dtype=$$($1_type) \
@@ -248,19 +248,19 @@
 		-Da=$$($1_a) \
 		-DA=$$($1_A) \
 		-Kbo$$($1_BO)
-		$(MV) $$($1_OUT).temp $$($1_OUT)
+		$(MV) $$($1_OUT).tmp $$($1_OUT)
 # Do the extra bin thing
 ifeq ($$($1_BIN),1)
-	$(SED) -e '/#BIN/,$$$$d' < $$($1_OUT) > $$($1_DST).temp
+	$(SED) -e '/#BIN/,$$$$d' < $$($1_OUT) > $$($1_DST).tmp
 	$(RM) $$($1_OUT)
-	$$($1_char_CMD) < $$($1_SRC_BIN) >> $$($1_DST).temp
-	$$($1_short_CMD) < $$($1_SRC_BIN) >> $$($1_DST).temp
-	$$($1_int_CMD) < $$($1_SRC_BIN) >> $$($1_DST).temp
-	$$($1_long_CMD) < $$($1_SRC_BIN) >> $$($1_DST).temp
-	$$($1_float_CMD) < $$($1_SRC_BIN) >> $$($1_DST).temp
-	$$($1_double_CMD) < $$($1_SRC_BIN) >> $$($1_DST).temp
-	$(PRINTF) "}\n" >> $$($1_DST).temp
-	mv $$($1_DST).temp $$($1_DST)
+	$$($1_char_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp
+	$$($1_short_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp
+	$$($1_int_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp
+	$$($1_long_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp
+	$$($1_float_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp
+	$$($1_double_CMD) < $$($1_SRC_BIN) >> $$($1_DST).tmp
+	$(PRINTF) "}\n" >> $$($1_DST).tmp
+	mv $$($1_DST).tmp $$($1_DST)
 endif
 
 GENSRC_BUFFER += $$($1_DST)
--- a/jdk/makefiles/GensrcCharsetCoder.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GensrcCharsetCoder.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -36,8 +36,8 @@
 
 $(GENSRC_CHARSETCODER_DST)/CharsetDecoder.java : $(GENSRC_CHARSETCODER_TEMPLATE)
 	$(MKDIR) -p $(@D)
-	-$(RM) $@.temp
-	$(TOOL_SPP) < $< >$@.temp \
+	-$(RM) $@.tmp
+	$(TOOL_SPP) < $< >$@.tmp \
 		-Kdecoder \
 		-DA='A' \
 		-Da='a' \
@@ -63,7 +63,7 @@
 		-DnotLegal='not legal for this charset' \
 		-Dotypes-per-itype='chars-per-byte' \
 		-DoutSequence='Unicode character'
-	$(MV) $@.temp $@
+	$(MV) $@.tmp $@
 
 GENSRC_CHARSETCODER += $(GENSRC_CHARSETCODER_DST)/CharsetDecoder.java
 
@@ -71,8 +71,8 @@
 
 $(GENSRC_CHARSETCODER_DST)/CharsetEncoder.java : $(GENSRC_CHARSETCODER_TEMPLATE)
 	$(MKDIR) -p $(@D)
-	-$(RM) $@.temp
-	$(TOOL_SPP) < $< >$@.temp \
+	-$(RM) $@.tmp
+	$(TOOL_SPP) < $< >$@.tmp \
 		-Kencoder \
 		-DA='An' \
 		-Da='an' \
@@ -98,7 +98,7 @@
 		-DnotLegal='not a legal sixteen-bit Unicode sequence' \
 		-Dotypes-per-itype='bytes-per-char' \
 		-DoutSequence='byte sequence in the given charset'
-	$(MV) $@.temp $@
+	$(MV) $@.tmp $@
 
 GENSRC_CHARSETCODER += $(GENSRC_CHARSETCODER_DST)/CharsetEncoder.java
 
--- a/jdk/makefiles/GensrcIcons.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GensrcIcons.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -29,7 +29,7 @@
 GENSRC_ICONS_DST := $(GENSRC_ICONS_TMP)/sun/awt/X11
 
 ifdef OPENJDK
-	ICONS_PATH_PREFIX := $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)
+	ICONS_PATH_PREFIX := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)
 else
 	ICONS_PATH_PREFIX := $(JDK_TOPDIR)/src/closed/solaris
 endif
@@ -41,7 +41,7 @@
     $(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon48.png
 
 
-ICONPATH := $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes/sun/awt/X11
+ICONPATH := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes/sun/awt/X11
 
 GENSRC_ICONS_SRC += \
    $(ICONPATH)/security-icon-bw16.png \
@@ -85,10 +85,7 @@
 	$(ECHO) "package sun.awt.X11;" > $$@.tmp
 	$(ECHO) "public class $$($1_NAME32) {" >> $$@.tmp
 	$(ECHO) "public static int[] $$($1_SHORTNAME) = { " >> $$@.tmp
-# TODO FIX FIX FIX
-ifneq ($(OPENJDK_TARGET_OS),macosx)
 	$(CAT) $$< | $(TOOL_TOBIN) >> $$@.tmp
-endif
 	$(ECHO) "}; }" >> $$@.tmp
 	$(MV) $$@.tmp $$@
 
@@ -99,10 +96,7 @@
 	$(ECHO) "package sun.awt.X11;" > $$@.tmp
 	$(ECHO) "public class $$($1_NAME64) {" >> $$@.tmp
 	$(ECHO) "public static long[] $$($1_SHORTNAME) = { " >> $$@.tmp
-# TODO FIX FIX FIX
-ifneq ($(OPENJDK_TARGET_OS),macosx)
 	$(CAT) $$< | $(TOOL_TOBIN) >> $$@.tmp
-endif
 	$(ECHO) "}; }" >> $$@.tmp
 	$(MV) $$@.tmp $$@
 
--- a/jdk/makefiles/GensrcJDWP.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GensrcJDWP.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -31,8 +31,17 @@
 $(JDK_OUTPUTDIR)/gensrc_jdwp/com/sun/tools/jdi/JDWP.java : $(JDK_TOPDIR)/makefiles/jpda/jdwp/jdwp.spec
 	$(MKDIR) -p $(@D)
 	$(MKDIR) -p $(JDK_OUTPUTDIR)/gensrc_jdwp_headers
+	$(RM) $@ $(JDK_OUTPUTDIR)/gensrc_jdwp_headers/JDWPCommands.h
 	$(ECHO) Creating JDWP.java and JDWPCommands.h from jdwp.spec
 	$(TOOL_JDWPGEN) $< -jdi $@ -include $(JDK_OUTPUTDIR)/gensrc_jdwp_headers/JDWPCommands.h
 
+$(JDK_OUTPUTDIR)/gensrc_jdwp_doc/jdwp-protocol.html : $(JDK_TOPDIR)/makefiles/jpda/jdwp/jdwp.spec
+	$(MKDIR) -p $(@D)
+	$(RM) $@
+	$(ECHO) Creating $(@F) from jdwp.spec
+	$(TOOL_JDWPGEN) $< -doc $@
+
 GENSRC_JDWP:=	$(JDK_OUTPUTDIR)/gensrc_jdwp/com/sun/tools/jdi/JDWP.java \
-		$(JDK_OUTPUTDIR)/gensrc_jdwp_headers/JDWPCommands.h
+		$(JDK_OUTPUTDIR)/gensrc_jdwp_headers/JDWPCommands.h \
+		$(JDK_OUTPUTDIR)/gensrc_jdwp_doc/jdwp-protocol.html
+
--- a/jdk/makefiles/GensrcJObjC.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GensrcJObjC.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -38,43 +38,71 @@
 #
 $(eval $(call SetupJavaCompilation,BUILD_JOBJC_PRIMITIVE_CODER,\
 		SETUP:=GENERATE_OLDBYTECODE,\
+		DISABLE_SJAVAC:=true,\
 		INCLUDES:=core/java \
                           com/apple,\
-                HEADERS :=$(JOBJC_DST)/jni_headers/core ,\
+                HEADERS:=$(JOBJC_DST)/jni_headers/core ,\
 		SRC:=$(JOBJC_SRC)/src \
                      $(JOBJC_SRC)/src/generator/java, \
 		BIN:=$(JOBJC_TMP)/bin))
 
-GENSRC_JOBJC += $(JOBJC_TMP)/bin/_the.batch
+GENSRC_JOBJC += $(BUILD_JOBJC_PRIMITIVE_CODER)
 
 #
-# Generate bridge support
+# Generate bridge support for select frameworks
 #
 BRIDGESUPPORT := $(addprefix $(JOBJC_TMP)/bridge/,$(addsuffix Full.bridgesupport,$(JOBJC_FRAMEWORKS)))
 
-$(JOBJC_TMP)/bridge/%Full.bridgesupport : $(FRAMEWORKS_DIR)/%.framework/Headers/*.h
-	$(MKDIR) -p $(@D)
-	if [ -f $(FRAMEWORKS_DIR)/$*.framework/Resources/BridgeSupport/$(@F) ]; then \
-		cp $(FRAMEWORKS_DIR)/$*.framework/Resources/BridgeSupport/$(@F) $@ ;\
-	else \
-		$(GBM) -F complete --framework $* -o $@ ; \
-	fi
+#
+# Define macro for rules to create bridge support
+#    Not sure why, but if the system has this framework bridge support,
+#    we appear to copy that, otherwise we run GBM which can be very slow.
+#
+define CreateBridgeSupport # Framework
+$(RM) $@ $@.tmp
+$(MKDIR) -p $(@D)
+if [ -f $(FRAMEWORKS_DIR)/$1.framework/Resources/BridgeSupport/$(@F) ]; then \
+    $(CP) $(FRAMEWORKS_DIR)/$1.framework/Resources/BridgeSupport/$(@F) $@.tmp ;\
+else \
+    $(GBM) -F complete --framework $1 -o $@.tmp ; \
+fi
+$(MV) $@.tmp $@
+endef
 
 #
-# Find Xbootclasspath
+# Currently 3 frameworks, avoid pattern rule due to the names being conflicting
 #
-$(JOBJC_TMP)/_the.generator_bootclasspath : $(JOBJC_TMP)/bin/_the.batch
+$(JOBJC_TMP)/bridge/FoundationFull.bridgesupport : \
+		$(wildcard $(FRAMEWORKS_DIR)/Foundation.framework/Headers/*.h)
+	$(call CreateBridgeSupport,Foundation)
+$(JOBJC_TMP)/bridge/CoreFoundationFull.bridgesupport : \
+		$(wildcard $(FRAMEWORKS_DIR)/CoreFoundation.framework/Headers/*.h)
+	$(call CreateBridgeSupport,CoreFoundation)
+$(JOBJC_TMP)/bridge/AppKitFull.bridgesupport : \
+		$(wildcard $(FRAMEWORKS_DIR)/AppKit.framework/Headers/*.h)
+	$(call CreateBridgeSupport,AppKit)
+
+#
+# Find Xbootclasspath, for some reason, this involves firing up Java just
+#     so we can get the boot classpath, so we can remove anything in that
+#     classpath that ends with "JObjC.jar", and emit the new bootclasspath.
+#
+$(JOBJC_TMP)/_the.generator_bootclasspath : $(BUILD_JOBJC_PRIMITIVE_CODER)
+	$(RM) $@
 	$(JAVA) -cp $(JOBJC_TMP)/bin com.apple.internal.jobjc.generator.BootClassPathMinus JObjC.jar > $@.tmp
 	$(MV) $@.tmp $@
 
-
 #
 # Run generator
+#    Now we use bootclasspath to run java again, with the bridge support to
+#    generate more source.
+#    Note the use of the | (order-only) on the BRIDGESUPPORT, should serialize
+#    them just in case GBM run in parallel has issues.
 #
-TOOL_JOBJC := $(JAVA) -cp $(JOBJC_TMP)/bin -ea com.apple.internal.jobjc.generator.Generator
-
-$(JOBJC_TMP)/_the.generator : $(JOBJC_TMP)/bin/_the.batch $(JOBJC_TMP)/_the.generator_bootclasspath $(BRIDGESUPPORT)
+$(JOBJC_TMP)/_the.generator : $(JOBJC_TMP)/_the.generator_bootclasspath | $(BRIDGESUPPORT)
+	$(RM) $@
 	$(JAVA) -d64 -Xbootclasspath:`$(CAT) $(JOBJC_TMP)/_the.generator_bootclasspath` -cp $(JOBJC_TMP)/bin -ea com.apple.internal.jobjc.generator.Generator dst=$(JOBJC_DST) frameworks=$(JOBJC_TMP)/bridge
 	$(TOUCH) $@
 
 GENSRC_JOBJC += $(JOBJC_TMP)/_the.generator
+
--- a/jdk/makefiles/GensrcMisc.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GensrcMisc.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -31,12 +31,14 @@
 $(JDK_OUTPUTDIR)/gensrc_misc/sun/misc/Version.java: \
 	$(JDK_TOPDIR)/src/share/classes/sun/misc/Version.java.template
 	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	$(ECHO) Generating sun/misc/Version.java
 	$(SED) -e 's/@@launcher_name@@/$(LAUNCHER_NAME)/g' \
 	       -e 's/@@java_version@@/$(RELEASE)/g' \
 	       -e 's/@@java_runtime_version@@/$(FULL_VERSION)/g' \
 	       -e 's/@@java_runtime_name@@/$(RUNTIME_NAME)/g' \
-            $< > $@
+            $< > $@.tmp
+	$(MV) $@.tmp $@
 
 GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc_misc/sun/misc/Version.java
 
@@ -46,8 +48,10 @@
 $(JDK_OUTPUTDIR)/gensrc_misc/sun/tools/jconsole/Version.java: \
                 $(JDK_TOPDIR)/src/share/classes/sun/tools/jconsole/Version.java.template
 	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	$(ECHO) Generating sun/tools/jconsole/Version.java
-	$(SED) -e 's/@@jconsole_version@@/$(FULL_VERSION)/g' $< > $@
+	$(SED) -e 's/@@jconsole_version@@/$(FULL_VERSION)/g' $< > $@.tmp
+	$(MV) $@.tmp $@
 
 GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc_misc/sun/tools/jconsole/Version.java
 
@@ -80,12 +84,14 @@
 
     $(JDK_OUTPUTDIR)/gensrc_c/libjdbcodbc/dummyodbc1.c : 
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(ECHO) Creating $@
 	$(PRINTF) "void dummyOdbc(void){}\n" > $@
 	$(ECHO) Created $@
 
     $(JDK_OUTPUTDIR)/gensrc_c/libjdbcodbc/dummyodbc2.c : 
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(ECHO) Creating $@
 	$(PRINTF) "void dummyOdbc(void){}\n" > $@
 	$(ECHO) Created $@
@@ -110,21 +116,27 @@
 		SRC:=$(GENSRC_SOR_SRC),\
 		INCLUDE_FILES:=$(GENSRC_SOR_SRC_FILE),\
 		LANG:=C,\
-		CC:=$(HOST_CC),\
-		LDEXE:=$(HOST_LD),\
+		CC:=$(BUILD_CC),\
+		LDEXE:=$(BUILD_LD),\
 		OBJECT_DIR:=$(GENSRC_SOR_BIN),\
 		OUTPUT_DIR:=$(GENSRC_SOR_BIN),\
                 PROGRAM:=genSocketOptionRegistry))
 
-ifneq ($(JAVASE_EMBEDDED), true)
+ifneq ($(wildcard $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java),)
+  HAS_SOCKET_OPTION_REGISTRY:=true
+endif
+
+ifneq ($(HAS_SOCKET_OTION_REGISTRY),true)
 $(JDK_OUTPUTDIR)/gensrc_misc/sun/nio/ch/SocketOptionRegistry.java : $(BUILD_GENSRC_SOR_EXE)
 	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	NAWK="$(NAWK)" SH="$(SH)" $(SH) -e $(JDK_TOPDIR)/makefiles/scripts/addNotices.sh "$(SOR_COPYRIGHT_YEARS)" > $@.tmp
 	$(BUILD_GENSRC_SOR_EXE) >> $@.tmp
 	$(MV) $@.tmp $@
 else
 $(JDK_OUTPUTDIR)/gensrc_misc/sun/nio/ch/SocketOptionRegistry.java : $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(CP) $< $@
 endif
 
@@ -134,7 +146,7 @@
 
 GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc_misc/sun/nio/fs/UnixConstants.java
 
-GENSRC_UC_SRC := $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/fs
+GENSRC_UC_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/fs
 GENSRC_UC_SRC_FILE := genUnixConstants.c
 GENSRC_UC_BIN := $(JDK_OUTPUTDIR)/gensrc_misc/genUnixConstants
 
@@ -145,21 +157,27 @@
 		SRC:=$(GENSRC_UC_SRC),\
 		INCLUDE_FILES:=$(GENSRC_UC_SRC_FILE),\
 		LANG:=C,\
-		CC:=$(HOST_CC),\
-		LDEXE:=$(HOST_CC),\
+		CC:=$(BUILD_CC),\
+		LDEXE:=$(BUILD_CC),\
 		OBJECT_DIR:=$(GENSRC_UC_BIN),\
                 OUTPUT_DIR:=$(GENSRC_UC_BIN),\
 		PROGRAM:=genUnixConstants))
 
-ifneq ($(JAVASE_EMBEDDED), true)
+ifneq ($(wildcard $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java),)
+  HAS_UNIX_CONSTANTS:=true
+endif
+
+ifneq ($(HAS_UNIX_CONSTANTS),true)
 $(JDK_OUTPUTDIR)/gensrc_misc/sun/nio/fs/UnixConstants.java : $(BUILD_GENSRC_UC_EXE)
 	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	NAWK="$(NAWK)" SH="$(SH)" $(SH) -e $(JDK_TOPDIR)/makefiles/scripts/addNotices.sh "$(UC_COPYRIGHT_YEARS)" > $@.tmp
 	$(BUILD_GENSRC_UC_EXE) >> $@.tmp
 	$(MV) $@.tmp $@
 else
 $(JDK_OUTPUTDIR)/gensrc_misc/sun/nio/fs/UnixConstants.java : $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(CP) $< $@
 endif
 
@@ -171,7 +189,7 @@
 
 GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc_misc/sun/nio/fs/SolarisConstants.java
 
-GENSRC_SOL_SRC := $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/sun/nio/fs
+GENSRC_SOL_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/fs
 GENSRC_SOL_SRC_FILE := genSolarisConstants.c
 GENSRC_SOL_BIN := $(JDK_OUTPUTDIR)/gensrc_misc/genSolarisConstants
 
@@ -182,14 +200,15 @@
 		SRC:=$(GENSRC_SOL_SRC),\
 		INCLUDE_FILES:=$(GENSRC_SOL_SRC_FILE),\
 		LANG:=C,\
-		CC:=$(HOST_CC),\
-		LDEXE:=$(HOST_CC),\
+		CC:=$(BUILD_CC),\
+		LDEXE:=$(BUILD_CC),\
 		OBJECT_DIR:=$(GENSRC_SOL_BIN),\
 		OUTPUT_DIR:=$(GENSRC_SOL_BIN),\
 		PROGRAM:=genSolarisConstants))
 
 $(JDK_OUTPUTDIR)/gensrc_misc/sun/nio/fs/SolarisConstants.java : $(BUILD_GENSRC_SOL_EXE)
 	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	NAWK="$(NAWK)" SH="$(SH)" $(SH) -e $(JDK_TOPDIR)/makefiles/scripts/addNotices.sh "$(SOL_COPYRIGHT_YEARS)" > $@.tmp
 	$(BUILD_GENSRC_SOL_EXE) >> $@.tmp
 	$(MV) $@.tmp $@
--- a/jdk/makefiles/GensrcProperties.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GensrcProperties.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -46,8 +46,9 @@
 
   # Strip away prefix and suffix,
   # leaving for example: sun/util/resources/CurrencyNames_sv
-  $1_PROPPATHS:=$$(patsubst $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes/%.properties,%,\
-                $$(patsubst $(JDK_TOPDIR)/src/share/classes/%.properties,%,$2))
+  $1_PROPPATHS:=$$(patsubst $(JDK_TOPDIR)/src/windows/classes/%.properties,%,\
+		$$(patsubst $(JDK_TOPDIR)/src/macosx/classes/%.properties,%,\
+                $$(patsubst $(JDK_TOPDIR)/src/share/classes/%.properties,%,$2)))
 
   # Apply optional name transformation, example: hz_TW -> hz_HK
   $(if $4,$1_PROPPATHS:=$$(patsubst $4,$5,$$($1_PROPPATHS)))
@@ -75,7 +76,7 @@
 
   # Strip away prefix and suffix,
   # leaving for example: sun/util/resources/CurrencyNames_sv
-  $1_PROPPATHS:=$$(patsubst $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes/%.properties,%,\
+  $1_PROPPATHS:=$$(patsubst $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes/%.properties,%,\
                 $$(patsubst $(JDK_TOPDIR)/src/share/classes/%.properties,%,$2))
 
   # Apply optional name transformation, example: hz_TW -> hz_HK
@@ -113,6 +114,13 @@
 
 # Some packages have properties that need to be converted to java source files.
 
+#com/apple/laf/resources
+ifeq ($(OPENJDK_TARGET_OS),macosx)
+    $(eval $(call add_properties_to_compile,COM_APPLE_LAF,\
+	$(shell find $(JDK_TOPDIR)/src/macosx/classes/com/apple/laf/resources -name "*.properties"),\
+		ListResourceBundle))
+endif
+
 #com/sun/accessibility/internal/resources
 $(eval $(call add_properties_to_compile,COM_SUN_ACCESSIBILITY,\
 	$(shell find $(JDK_TOPDIR)/src/share/classes/com/sun/accessibility/internal/resources -name "*.properties"),\
@@ -210,6 +218,16 @@
 $(eval $(call add_properties_to_compile,SUN_AWT_HK,\
 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/awt/resources -name "*.properties"),\
 		ListResourceBundle,%zh_TW,%zh_HK))
+#sun/awt/windows/
+ifeq ($(OPENJDK_TARGET_OS),windows)
+    $(eval $(call add_properties_to_compile,SUN_AWT,\
+	$(shell find $(JDK_TOPDIR)/src/windows/classes/sun/awt/windows -name "awtLocalization*.properties"),\
+		ListResourceBundle))
+    $(eval $(call add_properties_to_compile,SUN_AWT_HK,\
+	$(shell find $(JDK_TOPDIR)/src/windows/classes/sun/awt/windows -name "awtLocalization*.properties"),\
+		ListResourceBundle,%zh_TW,%zh_HK))
+endif
+
 #sun/launcher/resources
 $(eval $(call add_properties_to_compile,SUN_LAUNCHER,\
 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/launcher/resources -name "*.properties"),\
@@ -286,7 +304,7 @@
 
 # Now setup the rule for the generation of the resource bundles.
 $(JDK_OUTPUTDIR)/gensrc_properties/_the.compiled_properties : $(ALL_COMPILED_PROPSOURCES) $(BUILD_TOOLS)
-	$(RM) -rf $(JDK_OUTPUTDIR)/gensrc_properties/*
+	$(RM) -r $(JDK_OUTPUTDIR)/gensrc_properties/*
 #	Generate all output directories in advance since the build tool does not do that...
 	$(MKDIR) -p $(sort $(dir $(ALL_COMPILED_PROPJAVAS)))
 	$(ECHO) Compiling $(words $(ALL_COMPILED_PROPSOURCES)) properties into resource bundles
@@ -297,7 +315,7 @@
 # Now setup the rule for the generation of the cleaned properties.
 # FIXME: We currently don't handle removed properties incrementally. 
 $(JDK_OUTPUTDIR)/classes/_the.cleaned_properties : $(ALL_CLEANED_PROPSOURCES) $(BUILD_TOOLS)
-	$(RM) -f $(JDK_OUTPUTDIR)/classes/_the.cleaned_properties.cmdline
+	$(RM) $(JDK_OUTPUTDIR)/classes/_the.cleaned_properties.cmdline
 #	Generate all output directories in advance since the build tool does not do that...
 	$(MKDIR) -p $(sort $(dir $(ALL_CLEANED_PROPOUTPUT)))
 	$(ECHO) Copying and cleaning $(words $(ALL_CLEANED_PROPSOURCES)) properties 
--- a/jdk/makefiles/GensrcX11Wrappers.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/GensrcX11Wrappers.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -23,36 +23,33 @@
 # questions.
 #
 
+
+# This file is responsible for extracting the x11 native struct offsets to
+# the xawt Java library. This is done by compiling and running a native
+# binary, which dumps output to a text file. The offsets differ on 32 and 64
+# bit systems, so care must be taken here.
+
+# Note: Some of the more complex logic here is most likely not needed anymore.
+
 GENSRC_X11WRAPPERS :=
 GENSRC_X11WRAPPERS_TMP := $(JDK_OUTPUTDIR)/gensrc_x11wrappers
 
 GENSRC_SIZER_SRC := $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator
 
-GENSRC_SIZES :=
+# Normal case is to generate version according to target bits
+GENSRC_SIZES := sizes.$(OPENJDK_TARGET_CPU_BITS)
 
-ifeq ($(OPENJDK_TARGET_OS)-$(LIBARCH), solaris-i386)
-GENSRC_SIZES := sizes.32 sizes.64
-else ifeq ($(OPENJDK_TARGET_OS), solaris)
-isalist:=$(shell isainfo)
-ifneq (,$(findstring sparcv9, $(isalist)))
-# On sparcv9 we generate both 32 and 64-bit sizers in spite of ARCH_DATA_MODEL.
-GENSRC_SIZES := sizes.32 sizes.64
-else
-ifneq (,$(findstring amd64, $(isalist)))
-# On amd64 we generate both 32 and 64-bit sizers in spite of ARCH_DATA_MODEL.
+ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
+ifneq ($(OPENJDK_TARGET_OS), linux)
+# On all 64-bit systems except Linux, generate both 32 and 64 bit versions
 GENSRC_SIZES := sizes.32 sizes.64
-else # !sparcv9 : includes (32-bit) sparc, i586
-GENSRC_SIZES := sizes.32
-endif # amd64
-endif # sparcv9
-else # !solaris
-ifeq ($(OPENJDK_TARGET_OS), macosx)
+endif
+else
+ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-x86)
+# As a special case, solaris on x86 (32-bit) also generates the 64-bit version
 GENSRC_SIZES := sizes.32 sizes.64
-else # !macosx
-GENSRC_SIZES := sizes.$(ARCH_DATA_MODEL)
-endif # !macosx
-endif # solaris
-
+endif
+endif
 
 ##########################################################################################
 
@@ -62,40 +59,44 @@
 	$(TOOL_WRAPPERGENERATOR) $(@D) $< "sizer" $*
 
 $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.exe : $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.c
-	(cd $(@D) && $(HOST_CC) -m$* -o $@ $< \
+	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
+	(cd $(@D) && $(BUILD_CC) -m$* -o $@.tmp $< \
               -I$(JDK_OUTPUTDIR)/include \
               -I$(JDK_TOPDIR)/src/share/javavm/export \
-              -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/javavm/export \
+              -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \
               -I$(JDK_TOPDIR)//src/share/native/common \
-              -I$(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/native/common \
+              -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \
               -I$(JDK_TOPDIR)/src/solaris/native/sun/awt \
 	      -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
 	      -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils -lc)
+	$(MV) $@.tmp $@
 
-ifeq ($(OPENJDK_TARGET_OS)-$(LIBARCH), solaris-i386)
-
-$(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.32 : $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.32.exe
+# Run the generated sizer binary to create the sizes text file
+$(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.% : $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.exe
+	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
 	$< > $@.tmp
 	$(MV) $@.tmp $@
 
-$(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 : $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes/sun/awt/X11/generator/sizes.64-$(OPENJDK_TARGET_OS)-$(LIBARCH)
+ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-x86)
+  # On solaris-x86 we also need to create the 64-bit version, but we can't run a 64-bit binary
+  # As a workaround, copy this from a pre-generated file.
+$(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 : $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386
 	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(CP) $< $@
-else
-
-$(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.% : $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.exe
-	$< > $@.tmp
-	$(MV) $@.tmp $@
-
 endif
 
 $(GENSRC_X11WRAPPERS_TMP)/classes/_the.classes : $(foreach S,$(GENSRC_SIZES),$(GENSRC_X11WRAPPERS_TMP)/sizer/$(S))
+	$(RM) $@
 	$(MKDIR) -p $(@D)/sun/awt/X11
 	$(RM) $(@D)/sun/awt/X11/*
 	$(TOOL_WRAPPERGENERATOR) $(@D)/sun/awt/X11 $(GENSRC_SIZER_SRC)/xlibtypes.txt "gen" $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes
-ifeq ($(OPENJDK_TARGET_OS)-$(LIBARCH), solaris-amd64)
-	$(ECHO) COMPARING $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 and $(GENSRC_SIZER_SRC)/sizes.64-$(OPENJDK_TARGET_OS)-i386
-	$(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 $(GENSRC_SIZER_SRC)/sizes.64-$(OPENJDK_TARGET_OS)-i386
+ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-x86_64)
+  # On solaris-x86_64, as a safety measure, compare the generated file with the checked-in version 
+	$(ECHO) COMPARING $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 and $(GENSRC_SIZER_SRC)/sizes.64-solaris-i386
+	$(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 $(GENSRC_SIZER_SRC)/sizes.64-solaris-i386
 endif
 	$(TOUCH) $@
 
--- a/jdk/makefiles/Images.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/Images.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -32,11 +32,21 @@
 
 include Tools.gmk
 
-images: jre-image jdk-image
+# Note: This double-colon rule is intentional, to support
+# custom make file integration.
+images:: jre-image jdk-image
+
+overlay-images: jre-overlay-image jdk-overlay-image
+
+
+-include $(CUSTOM_MAKE_DIR)/Images.gmk
+
 
 ifeq ($(OPENJDK_TARGET_OS),solaris)
+# On Solaris, if the target is a symlink and exists, cp won't overwrite.
 define install-file
 	$(MKDIR) -p $(@D)
+	$(RM) '$@'
 	$(CP) -f -r -P '$<' '$(@D)'
 endef
 else ifeq ($(OPENJDK_TARGET_OS),macosx)
@@ -51,11 +61,34 @@
 endef
 endif
 
+# Processing license files from source area to image area
+# These will be modified to have the platform specific EOL chars.
+define process-doc-file
+	$(ECHO) Processing $(patsubst $(OUTPUT_ROOT)/%,%,$@)
+	$(MKDIR) -p $(@D)
+	$(RM) $@
+	$(SED) 's/$$//g' $< > $@
+	$(CHMOD) 444 $@
+endef
+
+
+JDK_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2sdk-image
+JRE_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2re-image
+
+JDK_OVERLAY_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2sdk-overlay-image
+JRE_OVERLAY_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2re-overlay-image
+
 ################################################################################
 #
 # JRE and JDK build rules
 #
 ################################################################################
+#
+# Variable prefixes explained:
+# JRE_ refers to files in the j2re-image.
+# JDK_ refers to files in the j2sdk-image outside of the jre subdir.
+# JDKJRE_ refers to files in the j2sdk-image inside the jre subdir.
+#
 
 ################################################################################
 # /bin dir
@@ -72,6 +105,19 @@
 	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 	$(install-file)
 
+# Overaly image targets
+$(JRE_OVERLAY_IMAGE_DIR)/bin/%: $(JDK_OUTPUTDIR)/bin/%
+	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
+	$(install-file)
+
+$(JDK_OVERLAY_IMAGE_DIR)/bin/%: $(JDK_OUTPUTDIR)/bin/%
+	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
+	$(install-file)
+
+$(JDK_OVERLAY_IMAGE_DIR)/jre/bin/%: $(JDK_OUTPUTDIR)/bin/%
+	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
+	$(install-file)
+
 NOT_JRE_BIN_FILES := \
 	appletviewer$(EXE_SUFFIX) \
 	extcheck$(EXE_SUFFIX) \
@@ -107,26 +153,54 @@
 
 WINDOWS_JDK_BIN_FILES = \
 	$(EXE_SUFFIX) \
-	$(LIB_PREFIX)jli$(SHARED_LIBRARY_SUFFIX) \
-	$(MSVCRNN_DLL)
+	$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX) \
+	$(notdir $(MSVCRNN_DLL))
+
+WINDOWS_JDKJRE_BIN_FILES := \
+	$(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX) \
+	$(SALIB_NAME)
 
 # Find all files in bin dir
 ALL_BIN_LIST := $(shell $(FIND) $(JDK_OUTPUTDIR)/bin -type f)
 
-# For unknown reason the debuginfo files for binaries are not put into images
+# For unknown reason the debuginfo files for executables are not put into images
 # e.g filter them out
-ALL_BIN_LIST := $(filter-out %.debuginfo %.diz, $(ALL_BIN_LIST))
+ifneq ($(OPENJDK_TARGET_OS),windows)
+    ALL_BIN_LIST := $(filter-out %.debuginfo %.diz, $(ALL_BIN_LIST))
+else
+# On windows, the libraries are in the bin dir, only filter out debuginfo files
+# for executables. "java" is both a library and executable.
+    ALL_BIN_EXEC_FILES := $(filter-out java.exe,$(notdir $(shell $(FIND) $(JDK_OUTPUTDIR)/bin -type f -name "*.exe")))
+    ALL_BIN_DEBUG_FILTER := $(addprefix %,$(patsubst %.exe,%.debuginfo,$(ALL_BIN_EXEC_FILES)) \
+					   $(patsubst %.exe,%.diz,$(ALL_BIN_EXEC_FILES))) %.pdb
+    ALL_BIN_LIST := $(filter-out $(ALL_BIN_DEBUG_FILTER),$(ALL_BIN_LIST))
+endif
 
 ifeq ($(OPENJDK_TARGET_OS),windows)
     JDK_BIN_LIST := $(filter $(addprefix %,$(WINDOWS_JDK_BIN_FILES)), $(ALL_BIN_LIST))
 else
     JDK_BIN_LIST := $(ALL_BIN_LIST)
 endif
-JRE_BIN_LIST := $(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES)), $(ALL_BIN_LIST))
+JDKJRE_BIN_LIST := $(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES)), $(ALL_BIN_LIST))
+JRE_BIN_LIST := $(filter-out $(addprefix %,$(WINDOWS_JDKJRE_BIN_FILES)), $(JDKJRE_BIN_LIST))
+
+ifneq ($(OPENJDK_TARGET_CPU_ISADIR),)
+    OVERLAY_FILTER := $(JDK_OUTPUTDIR)/bin$(OPENJDK_TARGET_CPU_ISADIR)%
+endif
 
-JRE_BIN_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JRE_IMAGE_DIR)/%, $(JRE_BIN_LIST))
-JDK_BIN_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JDK_IMAGE_DIR)/%, $(JDK_BIN_LIST))
-JDKJRE_BIN_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JDK_IMAGE_DIR)/jre/%, $(JRE_BIN_LIST))
+JRE_BIN_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JRE_IMAGE_DIR)/%, \
+			$(filter-out $(OVERLAY_FILTER),$(JRE_BIN_LIST)))
+JDK_BIN_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JDK_IMAGE_DIR)/%, \
+			$(filter-out $(OVERLAY_FILTER),$(JDK_BIN_LIST)))
+JDKJRE_BIN_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JDK_IMAGE_DIR)/jre/%, \
+			$(filter-out $(OVERLAY_FILTER),$(JDKJRE_BIN_LIST)))
+
+JRE_OVERLAY_BIN_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JRE_OVERLAY_IMAGE_DIR)/%, \
+				$(filter $(OVERLAY_FILTER),$(JRE_BIN_LIST)))
+JDK_OVERLAY_BIN_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JDK_OVERLAY_IMAGE_DIR)/%, \
+				$(filter $(OVERLAY_FILTER),$(JDK_BIN_LIST)))
+JDKJRE_OVERLAY_BIN_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JDK_OVERLAY_IMAGE_DIR)/jre/%, \
+				$(filter $(OVERLAY_FILTER),$(JDKJRE_BIN_LIST)))
 
 ################################################################################
 # /lib dir
@@ -143,9 +217,24 @@
 	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 	$(install-file)
 
-JDKJRE_LIB_FILES := \
-	$(LIB_PREFIX)attach$(SHARED_LIBRARY_SUFFIX) \
+# Overlay image targets
+$(JRE_OVERLAY_IMAGE_DIR)/lib/%: $(JDK_OUTPUTDIR)/lib/%
+	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
+	$(install-file)
+
+$(JDK_OVERLAY_IMAGE_DIR)/lib/%: $(JDK_OUTPUTDIR)/lib/%
+	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
+	$(install-file)
+
+$(JDK_OVERLAY_IMAGE_DIR)/jre/lib/%: $(JDK_OUTPUTDIR)/lib/%
+	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
+	$(install-file)
+
+ifneq ($(OPENJDK_TARGET_OS), macosx)
+    JDKJRE_LIB_FILES := \
+	$(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX) \
 	$(SALIB_NAME)
+endif
 
 NOT_JRE_LIB_FILES := \
 	tools.jar \
@@ -156,12 +245,16 @@
 	ir.idl \
 	ct.sym
 
+ifeq ($(OPENJDK_TARGET_OS), windows)
+    NOT_JRE_LIB_FILES += jawt.lib jvm.lib
+endif
+
 JDK_LIB_FILES := $(NOT_JRE_LIB_FILES)
 ifeq ($(OPENJDK_TARGET_OS), linux)
     JDK_LIB_FILES += jexec
 endif
 
-ALL_LIB_LIST := $(shell $(FIND) $(JDK_OUTPUTDIR)/lib \( -type f -o -type l \) ! -name "_the*")
+ALL_LIB_LIST := $(shell $(FIND) $(JDK_OUTPUTDIR)/lib \( -type f -o -type l \) -a ! \( -name "_the*" -o -name "javac_state " \) )
 JRE_LIB_LIST := $(filter-out $(addprefix %,$(NOT_JRE_LIB_FILES) $(JDKJRE_LIB_FILES)),$(ALL_LIB_LIST))
 JDKJRE_LIB_LIST := $(filter-out $(addprefix %,$(NOT_JRE_LIB_FILES)),$(ALL_LIB_LIST))
 JDK_LIB_LIST := $(filter $(addprefix %,$(JDK_LIB_FILES)),$(ALL_LIB_LIST))
@@ -170,6 +263,13 @@
 JDK_LIB_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JDK_IMAGE_DIR)/%,$(JDK_LIB_LIST))
 JDKJRE_LIB_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/%,$(JDK_IMAGE_DIR)/jre/%,$(JDKJRE_LIB_LIST))
 
+JRE_OVERLAY_LIB_TARGETS := $(subst $(JRE_IMAGE_DIR),$(JRE_OVERLAY_IMAGE_DIR),\
+				$(filter $(JRE_IMAGE_DIR)/lib$(OPENJDK_TARGET_CPU_ISADIR)/%,$(JRE_LIB_TARGETS)))
+JDK_OVERLAY_LIB_TARGETS := $(subst $(JDK_IMAGE_DIR),$(JDK_OVERLAY_IMAGE_DIR),\
+				$(filter $(JDK_IMAGE_DIR)/lib$(OPENJDK_TARGET_CPU_ISADIR)/%,$(JDK_LIB_TARGETS)))
+JDKJRE_OVERLAY_LIB_TARGETS := $(subst $(JDK_IMAGE_DIR),$(JDK_OVERLAY_IMAGE_DIR),\
+				$(filter $(JDK_IMAGE_DIR)/jre/lib$(OPENJDK_TARGET_CPU_ISADIR)/%,$(JDKJRE_LIB_TARGETS)))
+
 # CTE plugin security change require new empty directory lib/applet
 $(JRE_IMAGE_DIR)/lib/applet: 
 	$(ECHO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
@@ -179,19 +279,20 @@
 	$(ECHO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 	$(MKDIR) -p $@
 
+# In the old build, JObjC.jar is not part of the meta-index
 $(JRE_IMAGE_DIR)/lib/meta-index: $(JRE_LIB_TARGETS)
 	$(ECHO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index *.jar
+	$(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index `$(LS) *.jar | $(SED) 's/JObjC\.jar//g'`
 
 $(JDK_IMAGE_DIR)/jre/lib/meta-index: $(JDKJRE_LIB_TARGETS)
 	$(ECHO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index *.jar
+	$(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index `$(LS) *.jar | $(SED) 's/JObjC\.jar//g'`
 
 $(JRE_IMAGE_DIR)/lib/ext/meta-index: $(JRE_LIB_TARGETS)
 	$(ECHO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 	$(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index *.jar
 
-$(JDK_IMAGE_DIR)/jre/lib/ext/meta-index: $(JRE_LIB_TARGETS)
+$(JDK_IMAGE_DIR)/jre/lib/ext/meta-index: $(JDKJRE_LIB_TARGETS)
 	$(ECHO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 	$(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index *.jar
 
@@ -378,12 +479,12 @@
 # /demo dir
 
 ifndef NO_DEMOS
-# FIXME: newdemo/applets/GraphLayout/GraphPanel$2.class is sometimes not copied.
+# FIXME: demo/applets/GraphLayout/GraphPanel$2.class is sometimes not copied.
 
 #   The db demo contains an empty dir that needs to be copied. The other 
 #   directories will always trigger the rule for recompile since 
 #   _the.list_of_packages files are touched.
-    $(JDK_IMAGE_DIR)/demo/%: $(JDK_OUTPUTDIR)/newdemo/%
+    $(JDK_IMAGE_DIR)/demo/%: $(JDK_OUTPUTDIR)/demo/%
 	if [ ! -d "$@" ]; then \
 	  $(ECHO) Copying '$(patsubst $(OUTPUT_ROOT)/%,%,$@)'; \
 	  $(MKDIR) -p $(@D); \
@@ -391,8 +492,25 @@
 	fi
 
 #   Find all files including directories
-    JDK_DEMO_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/newdemo/%,$(JDK_IMAGE_DIR)/demo/%,\
-			$(shell $(FIND) $(JDK_OUTPUTDIR)/newdemo ! -name "_the.*"))
+    JDK_DEMO_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/demo/%,$(JDK_IMAGE_DIR)/demo/%,\
+			$(shell $(FIND) $(JDK_OUTPUTDIR)/demo ! \( -name "_the*" -o -name "javac_state" \) ))
+
+
+
+    # Param 1 is source file
+    define CreateOverlayDemoRule
+        $1_TARGET:=$$(subst $(JDK_OUTPUTDIR),$(JDK_OVERLAY_IMAGE_DIR),\
+			$$(dir $1)$(OPENJDK_TARGET_CPU_ISADIR)/$$(notdir $1))
+        $$($1_TARGET): $1
+		$(ECHO) Copying '$$(patsubst $(OUTPUT_ROOT)/%,%,$$@)'
+		$(MKDIR) -p $$(@D)
+		$(RM) $$@
+		$(CP) -f '$$<' '$$@'
+
+        JDK_OVERLAY_DEMO_TARGETS += $$($1_TARGET)
+    endef
+    JDK_OVERLAY_DEMO_SOURCES := $(shell $(FIND) $(JDK_OUTPUTDIR)/demo -name "*$(SHARED_LIBRARY_SUFFIX)")
+    $(foreach lib,$(JDK_OVERLAY_DEMO_SOURCES),$(eval $(call CreateOverlayDemoRule,$(lib))))
 
 endif
 
@@ -471,50 +589,47 @@
 JDK_DOC_TARGETS := $(addprefix $(JDK_IMAGE_DIR)/,$(JDK_DOC_FILES))
 
 $(JRE_IMAGE_DIR)/%: $(JRE_DOC_LOCATION)/%
-	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(install-file)
-	$(CHMOD) 444 $(@)
+	$(process-doc-file)
 
 $(JDK_IMAGE_DIR)/jre/%: $(JRE_DOC_LOCATION)/%
-	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(install-file)
-	$(CHMOD) 444 $(@)
+	$(process-doc-file)
 
 $(JRE_IMAGE_DIR)/README.txt: $(JRE_DOC_LOCATION)/README
-	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(MKDIR) -p $(@D)
-	$(CP) $< $@
-	$(CHMOD) 444 $(@)
+	$(process-doc-file)
 
 $(JDK_IMAGE_DIR)/jre/README.txt: $(JRE_DOC_LOCATION)/README
-	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(MKDIR) -p $(@D)
-	$(CP) $< $@
-	$(CHMOD) 444 $(@)
+	$(process-doc-file)
 
 $(JDK_IMAGE_DIR)/%: $(JDK_DOC_LOCATION)/%
-	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(install-file)
-	$(CHMOD) 444 $(@)
+	$(process-doc-file)
 
 $(JDK_IMAGE_DIR)/demo/%: $(JDK_DOC_LOCATION)/%
-	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(install-file)
-	$(CHMOD) 444 $(@)
+	$(process-doc-file)
 
 $(JDK_IMAGE_DIR)/sample/%: $(JDK_DOC_LOCATION)/%
-	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(install-file)
-	$(CHMOD) 444 $(@)
+	$(process-doc-file)
 
 JRE_INFO_FILE := $(JRE_IMAGE_DIR)/release
 JDK_INFO_FILE := $(JDK_IMAGE_DIR)/release
 
+JRE_OVERLAY_INFO_FILE := $(JRE_OVERLAY_IMAGE_DIR)/release
+JDK_OVERLAY_INFO_FILE := $(JDK_OVERLAY_IMAGE_DIR)/release
+
 # Common way to emit a line into the release or info file
 define info-file-item # name value
 $(PRINTF) '%s="%s"\n' $1 $2 >> $@
 endef
 
+define create-info-file
+	$(MKDIR) -p $(@D)
+	$(RM) $@
+	$(call info-file-item, "JAVA_VERSION", "$(JDK_VERSION)")
+	$(call info-file-item, "OS_NAME",      "$(REQUIRED_OS_NAME)")
+	$(call info-file-item, "OS_VERSION",   "$(REQUIRED_OS_VERSION)")
+	$(call info-file-item, "OS_ARCH",      "$(OPENJDK_TARGET_CPU_LEGACY)")
+	$(call info-file-item, "SOURCE",       "$(ALL_SOURCE_TIPS)")
+endef
+
 ALL_SOURCE_TIPS = $(shell \
   if [ -f $(OUTPUT_ROOT)/source_tips ] ; then \
     $(CAT) $(OUTPUT_ROOT)/source_tips ; \
@@ -522,23 +637,19 @@
 
 $(JRE_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
 	$(ECHO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(call info-file-item, "JAVA_VERSION", "$(JDK_VERSION)")
-	$(call info-file-item, "OS_NAME",      "$(REQUIRED_OS_NAME)")
-	$(call info-file-item, "OS_VERSION",   "$(REQUIRED_OS_VERSION)")
-	$(call info-file-item, "OS_ARCH",      "$(ARCH)")
-	$(call info-file-item, "SOURCE",       "$(ALL_SOURCE_TIPS)")
+	$(call create-info-file)
 
 $(JDK_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
 	$(ECHO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(call info-file-item, "JAVA_VERSION", "$(JDK_VERSION)")
-	$(call info-file-item, "OS_NAME",      "$(REQUIRED_OS_NAME)")
-	$(call info-file-item, "OS_VERSION",   "$(REQUIRED_OS_VERSION)")
-	$(call info-file-item, "OS_ARCH",      "$(ARCH)")
-	$(call info-file-item, "SOURCE",       "$(ALL_SOURCE_TIPS)")
+	$(call create-info-file)
+
+$(JRE_OVERLAY_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
+	$(ECHO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
+	$(call create-info-file)
+
+$(JDK_OVERLAY_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
+	$(ECHO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
+	$(call create-info-file)
 
 $(JDK_IMAGE_DIR)/src.zip: $(IMAGES_OUTPUTDIR)/src.zip
 	$(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
@@ -549,51 +660,75 @@
 
 ifneq ($(POST_STRIP_CMD),)
     ifeq ($(OPENJDK_TARGET_OS), windows)
-        EXEC_LIST:=$(shell $(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*.exe \
+        EXEC_LIST_BIN:=$(shell $(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*.exe \
 		-o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)")
     else
         # Find all executables in JDK_OUTPUTDIR since they exist when this makefile is parsed
-        EXEC_LIST:=$(shell $(FIND) $(JDK_OUTPUTDIR)/lib -type f -name \*$(SHARED_LIBRARY_SUFFIX) && \
-		$(FILE) `$(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*$(EXE_SUFFIX)` \
+        EXEC_LIST_BIN:=$(shell $(FILE) `$(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*$(EXE_SUFFIX)` \
 		| $(EGREP) 'ELF' | $(CUT) -d':' -f1)
+        # On mac, the old build searches for static libraries for stripping instead of shared.
+        # Not clear if it's intentional.
+	ifneq ($(OPENJDK_TARGET_OS), macosx)
+            EXEC_LIST_LIB:=$(shell $(FIND) $(JDK_OUTPUTDIR)/lib -type f -name \*$(SHARED_LIBRARY_SUFFIX))
+	endif
     endif
+
+    # Filter out the overlay specific bin files
+    EXEC_LIST:=$(filter-out $(OVERLAY_FILTER),$(EXEC_LIST_BIN)) $(EXEC_LIST_LIB)
+    EXEC_LIST_OVERLAY:=$(filter $(OVERLAY_FILTER),$(EXEC_LIST_BIN)) $(EXEC_LIST_LIB)
+
     # Filter out non JRE files and convert to unique touch files to depend on
-    JRE_EXEC_TOUCH_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%,$(IMAGES_OUTPUTDIR)/_strip_jre/%.stripped,\
-			$(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES)), $(EXEC_LIST)))
+    JRE_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%,$(IMAGES_OUTPUTDIR)/_strip_jre/%.stripped,\
+			$(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES) $(JDKJRE_LIB_FILES)),\
+				 $(EXEC_LIST)))
 
-    JDK_JRE_EXEC_TOUCH_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%, \
+    JDKJRE_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%, \
                         $(IMAGES_OUTPUTDIR)/_strip_jdk/jre/%.stripped, \
 			$(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES)), $(EXEC_LIST)))
 
-    JDK_BIN_EXEC_TOUCH_LIST := $(patsubst $(JDK_OUTPUTDIR)/%, \
+    JDK_BIN_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%, \
                           $(IMAGES_OUTPUTDIR)/_strip_jdk/%.stripped, \
                           $(filter-out $(JDK_OUTPUTDIR)/lib/%, $(EXEC_LIST)))
 
+    # Do the same for overlay image
+    JRE_OVERLAY_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%,$(IMAGES_OUTPUTDIR)/_strip_jre_overlay/%.stripped,\
+			$(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES) $(JDKJRE_LIB_FILES)),\
+				 $(EXEC_LIST_OVERLAY)))
+
+    JDKJRE_OVERLAY_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%, \
+                        $(IMAGES_OUTPUTDIR)/_strip_jdk_overlay/jre/%.stripped, \
+			$(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES)), $(EXEC_LIST_OVERLAY)))
+
+    JDK_OVERLAY_BIN_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%, \
+                          $(IMAGES_OUTPUTDIR)/_strip_jdk_overlay/%.stripped, \
+                          $(filter-out $(JDK_OUTPUTDIR)/lib/%, $(EXEC_LIST_OVERLAY)))
+
+    define mcs-file
+	$(if $(POST_MCS_CMD),$(POST_MCS_CMD) $<)
+    endef
+
+    define strip-file
+	$(ECHO) Stripping $(patsubst $(OUTPUT_ROOT)/%,%,$<)
+	$(CHMOD) u+w $<
+	$(POST_STRIP_CMD) $<
+	$(call mcs-file)
+	$(CHMOD) go-w $<
+	$(MKDIR) -p $(@D)
+	$(TOUCH) $@
+    endef
+
     # Setup a rule for stripping files based on touch files
     $(IMAGES_OUTPUTDIR)/_strip_jre/%.stripped: $(JRE_IMAGE_DIR)/%
-	$(ECHO) Stripping $(patsubst $(OUTPUT_ROOT)/%,%,$<)
-	$(CHMOD) u+w $<
-	$(POST_STRIP_CMD) $<
-	$(CHMOD) go-w $<
-	$(MKDIR) -p $(@D)
-	$(TOUCH) $@
+	$(call strip-file)
+
+    $(IMAGES_OUTPUTDIR)/_strip_jdk/%.stripped: $(JDK_IMAGE_DIR)/%
+	$(call strip-file)
 
-    $(IMAGES_OUTPUTDIR)/_strip_jdk/bin/%.stripped: $(JDK_IMAGE_DIR)/bin/%
-	$(ECHO) Stripping $(patsubst $(OUTPUT_ROOT)/%,%,$<)
-	$(CHMOD) u+w $<
-	$(POST_STRIP_CMD) $<
-	$(CHMOD) go-w $<
-	$(MKDIR) -p $(@D)
-	$(TOUCH) $@
+    $(IMAGES_OUTPUTDIR)/_strip_jre_overlay/%.stripped: $(JRE_OVERLAY_IMAGE_DIR)/%
+	$(call strip-file)
 
-    # Setup a rule for stripping files based on touch files
-    $(IMAGES_OUTPUTDIR)/_strip_jdk/jre/%.stripped: $(JDK_IMAGE_DIR)/jre/%
-	$(ECHO) Stripping $(patsubst $(OUTPUT_ROOT)/%,%,$<)
-	$(CHMOD) u+w $<
-	$(POST_STRIP_CMD) $<
-	$(CHMOD) go-w $<
-	$(MKDIR) -p $(@D)
-	$(TOUCH) $@
+    $(IMAGES_OUTPUTDIR)/_strip_jdk_overlay/%.stripped: $(JDK_OVERLAY_IMAGE_DIR)/%
+	$(call strip-file)
 
 endif
 
@@ -602,7 +737,7 @@
 
 jre-image: $(JRE_BIN_TARGETS) $(JRE_LIB_TARGETS) $(JRE_IMAGE_DIR)/lib/applet \
 	$(JRE_IMAGE_DIR)/lib/meta-index $(JRE_IMAGE_DIR)/lib/ext/meta-index \
-	$(JRE_MAN_PAGE_LIST) $(JRE_DOC_TARGETS) $(JRE_INFO_FILE) $(JRE_EXEC_TOUCH_LIST)
+	$(JRE_MAN_PAGE_LIST) $(JRE_DOC_TARGETS) $(JRE_INFO_FILE) $(JRE_STRIP_LIST)
 
 jdk-image: $(JDK_BIN_TARGETS) $(JDKJRE_BIN_TARGETS) \
 	$(JDK_LIB_TARGETS) $(JDKJRE_LIB_TARGETS) \
@@ -612,9 +747,17 @@
 	$(JDK_MAN_PAGE_LIST) $(JDK_SAMPLE_TARGETS) \
 	$(JDK_DB_TARGETS) $(JDK_INCLUDE_TARGETS) \
 	$(JDKJRE_DOC_TARGETS) $(JDK_DOC_TARGETS) \
-	$(JDK_INFO_FILE) $(JDK_JRE_EXEC_TOUCH_LIST) $(JDK_BIN_EXEC_TOUCH_LIST) \
+	$(JDK_INFO_FILE) $(JDKJRE_STRIP_LIST) $(JDK_BIN_STRIP_LIST) \
         $(JDK_IMAGE_DIR)/src.zip
 
+jre-overlay-image: $(JRE_OVERLAY_BIN_TARGETS) $(JRE_OVERLAY_LIB_TARGETS) \
+	 $(JRE_OVERLAY_INFO_FILE) $(JRE_OVERLAY_STRIP_LIST)
+
+jdk-overlay-image: $(JDK_OVERLAY_BIN_TARGETS) $(JDKJRE_OVERLAY_BIN_TARGETS) \
+	$(JDK_OVERLAY_LIB_TARGETS) $(JDKJRE_OVERLAY_LIB_TARGETS) \
+	$(JDK_OVERLAY_DEMO_TARGETS) $(JDK_OVERLAY_INFO_FILE) \
+	$(JDKJRE_OVERLAY_STRIP_LIST) $(JDK_OVERLAY_BIN_STRIP_LIST) 
+
 ################################################################################
 
 .PHONY: default images jre-image jdk-image
--- a/jdk/makefiles/Import.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/Import.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -41,12 +41,8 @@
 
 # Put the libraries here. Different locations for different target apis.
 ifeq ($(OPENJDK_TARGET_OS_API),posix)
-    ifneq ($(OPENJDK_TARGET_OS),macosx)
-        INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/lib/$(LIBARCH)
-    else
-        INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/lib
-    endif
-    HOTSPOT_LIB_DIR:=$(HOTSPOT_DIST)/jre/lib/$(LIBARCH)
+    INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)
+    HOTSPOT_LIB_DIR:=$(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)
 else
     INSTALL_LIBRARIES_HERE:=$(JDK_OUTPUTDIR)/bin
     HOTSPOT_LIB_DIR:=$(HOTSPOT_DIST)/jre/bin
@@ -65,6 +61,7 @@
 $(JDK_OUTPUTDIR)/classes/_the.$1.classes.imported : $$($1_DIST)/lib/classes.jar $$($1_CLASSES_DEP)
 	$(ECHO) Importing $1 classes.jar
 	$(MKDIR) -p $$(@D)
+	$(RM) $$@ $$@.tmp
 	($(CD) $$(@D) && $(JAR) xvf $$< > $$@.tmp)
 	$(MV) $$@.tmp $$@
 endef
@@ -76,6 +73,7 @@
 $(JDK_OUTPUTDIR)/impsrc/_the.$1.src.imported : $$($1_DIST)/lib/src.zip $$($1_SOURCES_DEP)
 	$(ECHO) Importing $1 src.zip
 	$(MKDIR) -p $$(@D)
+	$(RM) $$@ $$@.tmp
 	($(CD) $$(@D) && $(JAR) xvf $$< > $$@.tmp)
 	$(MV) $$@.tmp $$@
 endef
@@ -87,6 +85,7 @@
 $(JDK_OUTPUTDIR)/_the.$1.binaries.imported : $$($1_DIST)/lib/bin.zip $$($1_BINARIES_DEP)
 	$(ECHO) Importing $1 bin.zip
 	$(MKDIR) -p $$(@D)
+	$(RM) $$@ $$@.tmp
 	($(CD) $$(@D) && $(JAR) xvf $$< > $$@.tmp)
 	$(MV) $$@.tmp $$@
 endef
@@ -103,23 +102,26 @@
 
 ifeq ($(OPENJDK_TARGET_OS),solaris)
 define do-install-file
-	$(MKDIR) -p $$(@D)
+	$(MKDIR) -p '$$(@D)'
+	$(RM) '$$@'
 	$(CP) -r -P '$$<' '$$(@D)'
 endef
 else ifeq ($(OPENJDK_TARGET_OS),macosx)
 define do-install-file
-	$(MKDIR) -p $$(@D)
+	$(MKDIR) -p '$$(@D)'
+	$(RM) '$$@'
 	$(CP) -pRP '$$<' '$$@'
 endef
 else
 define do-install-file
-	$(MKDIR) -p $$(@D)
+	$(MKDIR) -p '$$(@D)'
+	$(RM) '$$@'
 	$(CP) -P '$$<' '$$@'
 endef
 endif
 
 define CopyDir
-        $1_SRC_FILES := $(shell $(FIND) $2 -type f)
+        $1_SRC_FILES := $(shell $(FIND) $2 -type f -a ! -name "wb.jar")
         $1_DST_FILES := $$(patsubst $2/%,$3/%,$$($1_SRC_FILES))
         IMPORT_TARGET_FILES += $$($1_DST_FILES)
 $3/% : $2/%
@@ -136,8 +138,8 @@
 $(eval $(call CopyDir,HOTSPOT0, $(HOTSPOT_LIB_DIR), $(INSTALL_LIBRARIES_HERE)))
 $(eval $(call CopyDir,HOTSPOT1, $(HOTSPOT_DIST)/lib, $(JDK_OUTPUTDIR)/lib))
 
-JSIG_DEBUGINFO := $(wildcard $(HOTSPOT_DIST)/jre/lib/$(LIBARCH)/libjsig.debuginfo) \
-                  $(wildcard $(HOTSPOT_DIST)/jre/lib/$(LIBARCH)/libjsig.diz)
+JSIG_DEBUGINFO := $(strip $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.debuginfo) \
+                  $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.diz) )
 
 ifneq ($(OPENJDK_TARGET_OS), windows)
     ifeq ($(JVM_VARIANT_SERVER), true)
@@ -155,64 +157,75 @@
 endif
 
 $(INSTALL_LIBRARIES_HERE)/server/%$(SHARED_LIBRARY_SUFFIX) : $(INSTALL_LIBRARIES_HERE)/%$(SHARED_LIBRARY_SUFFIX)
-	$(RM) -f $@
+	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(LN) -s ../$(@F) $@
 
 $(INSTALL_LIBRARIES_HERE)/server/%.debuginfo : $(INSTALL_LIBRARIES_HERE)/%.debuginfo
-	$(RM) -f $@
+	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(LN) -s ../$(@F) $@
 
 $(INSTALL_LIBRARIES_HERE)/server/%.diz : $(INSTALL_LIBRARIES_HERE)/%.diz
-	$(RM) -f $@
+	$(MKDIR) -p $(@D)
+	$(RM) $@
 ifeq (REALLY_WEIRD,1)
 	$(LN) -s ../$(@F) $@
 else
 #
 # TODO: Check if this is what they really want...a zip containing a symlink
 #
-	$(RM) -f $(basename $@).debuginfo
+	$(RM) $@.tmp $(basename $@).debuginfo
 	$(LN) -s ../$(basename $(@F)).debuginfo $(basename $@).debuginfo
-	$(ZIP) -q -y $@ $(basename $@).debuginfo
-	$(RM) -f $(basename $@).debuginfo
+	$(ZIP) -q -y $@.tmp $(basename $@).debuginfo
+	$(RM) $(basename $@).debuginfo
+	$(MV) $@.tmp $@
 endif
 
 $(INSTALL_LIBRARIES_HERE)/client/%$(SHARED_LIBRARY_SUFFIX) : $(INSTALL_LIBRARIES_HERE)/%$(SHARED_LIBRARY_SUFFIX)
-	$(RM) -f $@
+	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(LN) -s ../$(@F) $@
 
 $(INSTALL_LIBRARIES_HERE)/client/%.debuginfo : $(INSTALL_LIBRARIES_HERE)/%.debuginfo
-	$(RM) -f $@
+	$(MKDIR) -p $(@D)
+	$(RM) $@
 	$(LN) -s ../$(@F) $@
 
 $(INSTALL_LIBRARIES_HERE)/client/%.diz : $(INSTALL_LIBRARIES_HERE)/%.diz
-	$(RM) -f $@
+	$(MKDIR) -p $(@D)
+	$(RM) $@
 ifeq (REALLY_WEIRD,1)
 	$(LN) -s ../$(@F) $@
 else
 #
 # TODO: Check if this is what they really want...a zip containing a symlink
 #
-	$(RM) -f $(basename $@).debuginfo
+	$(RM) $@.tmp $(basename $@).debuginfo
 	$(LN) -s ../$(basename $(@F)).debuginfo $(basename $@).debuginfo
-	$(ZIP) -q -y $@ $(basename $@).debuginfo
-	$(RM) -f $(basename $@).debuginfo
+	$(ZIP) -q -y $@.tmp $(basename $@).debuginfo
+	$(RM) $(basename $@).debuginfo
+	$(MV) $@.tmp $@
 endif
 
 #######
 
 ifeq ($(OPENJDK_TARGET_OS),solaris)
 define install-file
-	$(MKDIR) -p $(@D)
+	$(MKDIR) -p '$(@D)'
+	$(RM) '$@'
 	$(CP) -r -P '$<' '$(@D)'
 endef
 else ifeq ($(OPENJDK_TARGET_OS),macosx)
 define install-file
-	$(MKDIR) -p $(@D)
+	$(MKDIR) -p '$(@D)'
+	$(RM) '$@'
 	$(CP) -pRP '$<' '$@'
 endef
 else
 define install-file
-	$(MKDIR) -p $(@D)
+	$(MKDIR) -p '$(@D)'
+	$(RM) '$@'
 	$(CP) -P '$<' '$@'
 endef
 endif
--- a/jdk/makefiles/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -26,6 +26,11 @@
 # This must be the first rule
 default: all
 
+# Inclusion of this pseudo-target will cause make to execute this file
+# serially, regardless of -j. Recursively called makefiles will not be
+# affected, however. This is required for correct dependency management.
+.NOTPARALLEL:
+
 include $(SPEC)
 include MakeBase.gmk
 include JavaCompilation.gmk
@@ -37,39 +42,72 @@
 # Setup the build tools.
 include Tools.gmk
 
-all: $(BUILD_TOOLS)
+import: $(BUILD_TOOLS) import-only
+import-only:
 #       Import (corba jaxp jaxws langtools hotspot)
 	+$(MAKE) -f Import.gmk
-#
+
+gensrc: import gensrc-only
+gensrc-only:
 	+$(MAKE) -f GenerateJavaSources.gmk
 #       Ok, now gensrc is fully populated.
+
+gendata: gensrc gendata-only
+gendata-only:
 	+$(MAKE) -f GenerateData.gmk
+
+classes: gendata classes-only
+classes-only:
 	+$(MAKE) -f CompileJavaClasses.gmk
 #       The classes are now built and
 #       any javah files have now been generated.
+
+libs: classes libs-only
+libs-only:
 	+$(MAKE) -f CompileNativeLibraries.gmk
+
+launchers: libs launchers-only
+launchers-only:
 #       Finally compile the launchers.
 	+$(MAKE) -f CompileLaunchers.gmk
+
+genclasses: launchers genclasses-only
+genclasses-only:
 #	Generate classes that have other sources. Needs
 #       to execute launchers.
 	+$(MAKE) -f GenerateClasses.gmk
+
+demos: genclasses demos-only
+demos-only:
 #       Now we have a complete jdk, which you can run.
 #       It is not yet wrapped up as an installed image.
 #       The demos are compiled against this jdk.
 ifndef NO_DEMOS
 	+$(MAKE) -f CompileDemos.gmk
 endif
+
+samples: demos samples-only
+samples-only:
 #	Now copy the sample sources into the jdk.
 ifndef NO_SAMPLES
 	+$(MAKE) -f CopySamples.gmk
 endif
 
+# The all target builds the JDK, but not the images
+all: import gensrc gendata classes libs launchers genclasses demos samples
+
+.PHONY: all images install overlay-images import-only gensrc-only gendata-only classes-only 
+.PHONY: libs-only launchers-only genclasses-only demos-only samples-only
+
 # Create the final jdk and jre images, to be wrapped up
 # into packages, or installed.
 images:
 	+$(MAKE) -f CreateJars.gmk
 	+$(MAKE) -f Images.gmk 
 
+overlay-images:
+	+$(MAKE) -f CompileLaunchers.gmk OVERLAY_IMAGES=true
+	+$(MAKE) -f Images.gmk overlay-images
 
 BINARIES:=$(shell if test -d $(IMAGES_OUTPUTDIR)/j2sdk-image/bin; then cd $(IMAGES_OUTPUTDIR)/j2sdk-image/bin && $(LS) ; fi)
 INSTALLDIR:=openjdk-$(RELEASE)
@@ -84,5 +122,3 @@
 	$(CP) -rp $(IMAGES_OUTPUTDIR)/j2sdk-image/* $(INSTALL_PREFIX)/jvm/$(INSTALLDIR)
 	$(RM) $(addprefix $(INSTALL_PREFIX)/bin/,$(BINARIES))
 	$(foreach b,$(BINARIES),$(LN) -s $(INSTALL_PREFIX)/jvm/$(INSTALLDIR)/bin/$b $(INSTALL_PREFIX)/bin/$b &&) true
-
-.PHONY: all install images
--- a/jdk/makefiles/Setup.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/Setup.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -36,10 +36,8 @@
      JVM:=$(JAVA),\
      JAVAC:=$(JAVAC_JARS),\
      FLAGS:=-source 7 -target 7 -bootclasspath $(BOOT_RTJAR) $(DISABLE_WARNINGS),\
-     SERVER_DIR:=$(JAVAC_SERVERS),\
-     SERVER_JVM:=$(SERVER_JAVA),\
-     MODE:=$(JAVAC_USE_MODE),\
-     USE_DEPS:=$(JAVAC_USE_DEPS)))
+     SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+     SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
 
 # The generate new bytecode javac setup uses the new compiler to compile for the
 # new jdk. This new bytecode might only be possible to run using the new jvm.
@@ -47,11 +45,9 @@
      JVM:=$(JAVA),\
      JAVAC:=$(JAVAC_JARS),\
      JAVAH:=$(JAVAH_JARS),\
-     FLAGS:=-bootclasspath "$(JDK_OUTPUTDIR)/classes" -Xprefer:source -XDignore.symbol.file=true $(DISABLE_WARNINGS),\
-     SERVER_DIR:=$(JAVAC_SERVERS),\
-     SERVER_JVM:=$(SERVER_JAVA),\
-     MODE:=$(JAVAC_USE_MODE),\
-     USE_DEPS:=$(JAVAC_USE_DEPS)))
+     FLAGS:=-bootclasspath $(JDK_OUTPUTDIR)/classes -source 7 -target 7 -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS),\
+     SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+     SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
 
 # After the jdk is built, we want to build demos using only the recently
 # generated jdk classes and nothing else, no jdk source, etc etc.
@@ -60,19 +56,6 @@
 $(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE,\
      JVM:=$(JAVA),\
      JAVAC:=$(JAVAC_JARS),\
-     FLAGS:= -Xbootclasspath:$(JDK_OUTPUTDIR)/classes $(DISABLE_WARNINGS),\
-     SERVER_DIR:=$(JAVAC_SERVERS),\
-     SERVER_JVM:=$(SERVER_JAVA),\
-     MODE:=$(JAVAC_USE_MODE),\
-     USE_DEPS:=$(JAVAC_USE_DEPS)))
-
-# A temporary solution to work around the fact that Matrix3D.java
-# exists in several applets. The javacserver does not like to be
-# fed the same class twice. Thus we compile one applet outside of the
-# javacserver.
-$(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE_NOSERV,\
-     JVM:=$(JAVA),\
-     JAVAC:=$(JAVAC_JARS),\
-     FLAGS:= -Xbootclasspath:$(JDK_OUTPUTDIR)/classes $(DISABLE_WARNINGS),\
-     MODE:=SINGLE_THREADED_BATCH,\
-     USE_DEPS:=FALSE))
+     FLAGS:=-bootclasspath $(JDK_OUTPUTDIR)/classes $(DISABLE_WARNINGS),\
+     SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+     SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
--- a/jdk/makefiles/Tools.gmk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/Tools.gmk	Tue Sep 25 11:48:00 2012 -0700
@@ -134,8 +134,8 @@
 $(eval $(call SetupNativeCompilation,ADD_GNU_DEBUGLINK,\
 		SRC:=$(JDK_TOPDIR)/make/tools/add_gnu_debuglink,\
 		LANG:=C,\
-		CC:=$(HOST_CC),\
-		LDEXE:=$(HOST_LD),\
+		CC:=$(BUILD_CC),\
+		LDEXE:=$(BUILD_LD),\
 		LDFLAGS:=-lelf,\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/add_gnu_debuglink,\
 		OUTPUT_DIR:=$(JDK_OUTPUTDIR)/btbin,\
@@ -144,8 +144,8 @@
 $(eval $(call SetupNativeCompilation,FIX_EMPTY_SEC_HDR_FLAGS,\
 		SRC:=$(JDK_TOPDIR)/make/tools/fix_empty_sec_hdr_flags,\
 		LANG:=C,\
-		CC:=$(HOST_CC),\
-		LDEXE:=$(HOST_LD),\
+		CC:=$(BUILD_CC),\
+		LDEXE:=$(BUILD_LD),\
 		LDFLAGS:=-lelf,\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/fix_empty_sec_hdr_flags,\
 		OUTPUT_DIR:=$(JDK_OUTPUTDIR)/btbin,\
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/mapfiles/launchers/mapfile-x86	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,48 @@
+#
+# 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
+# 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.
+#
+#
+# Specify what global symbols we export.  Note that we're not really
+# interested in declaring a version, simply scoping the file is sufficient.
+#
+
+SUNWprivate_1.1 {
+	global:
+		main;		# Provides basic adb symbol offsets
+		environ;	# Public symbols and required by Java run time
+		_environ;
+		__environ_lock;
+		___Argv;	# The following are private, but as they are
+		_start;		# exported from ctr1/crtn, the clever hacker
+		_init;		# might know about them.  However note, that
+		_fini;		# their use is strictly not supported.
+		_lib_version;
+#		_mcount;
+		__fsr;
+		__fsr_init_value;
+		__longdouble_used;
+
+	local:
+		*;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/mapfiles/launchers/mapfile-x86_64	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,39 @@
+#
+# 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
+# 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.
+#
+#
+# Specify what global symbols we export.  Note that we're not really
+# interested in declaring a version, simply scoping the file is sufficient.
+#
+
+SUNWprivate_1.1 {
+	global:
+		main;		# Provides basic adb symbol offsets
+		environ;	# Public symbols and required by Java run time
+		_environ;
+		__environ_lock;
+
+	local:
+		*;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/mapfiles/libawt_headless/reorder-x86	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,1 @@
+# Temporary file for headless
--- a/jdk/makefiles/mapfiles/libjava/mapfile-vers	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/mapfiles/libjava/mapfile-vers	Tue Sep 25 11:48:00 2012 -0700
@@ -285,6 +285,8 @@
 #		Java_sun_misc_VM_unsuspendSomeThreads;		threads.c
 #		Java_sun_misc_VM_unsuspendThreads;		threads.c
 
+		Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPattern;
+
 	# Outcalls from libjvm done using dlsym().
 
 		VerifyClassCodes;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/mapfiles/libjava/reorder-x86	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,109 @@
+data = R0x2000;
+text = LOAD ?RXO;
+# Test Null
+text: .text%_init;
+text: .text%init64IO: OUTPUTDIR/UnixFileSystem_md.o;
+text: .text%JNI_OnLoad;
+text: .text%Canonicalize;
+text: .text%canonicalize;
+text: .text%collapse: OUTPUTDIR/canonicalize_md.o;
+text: .text%Java_java_lang_Object_registerNatives;
+text: .text%Java_java_lang_System_registerNatives;
+text: .text%Java_java_lang_Thread_registerNatives;
+text: .text%Java_java_security_AccessController_getStackAccessControlContext;
+text: .text%Java_java_security_AccessController_getInheritedAccessControlContext;
+text: .text%Java_java_lang_ClassLoader_registerNatives;
+text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2;
+text: .text%Java_java_lang_Class_registerNatives;
+text: .text%Java_java_lang_Class_getPrimitiveClass;
+text: .text%Java_java_lang_System_initProperties;
+text: .text%GetJavaProperties;
+text: .text%uname: OUTPUTDIR/java_props_md.o;
+text: .text%mapLookup: OUTPUTDIR/java_props_md.o;
+text: .text%setPathEnvironment: OUTPUTDIR/java_props_md.o;
+text: .text%JNU_NewStringPlatform;
+text: .text%JNU_CallStaticMethodByName;
+text: .text%NewStringPlatform;
+text: .text%Java_java_io_FileInputStream_initIDs;
+text: .text%Java_java_io_FileDescriptor_initIDs;
+text: .text%Java_java_io_FileOutputStream_initIDs;
+text: .text%Java_java_lang_System_setIn0;
+text: .text%Java_sun_reflect_Reflection_getCallerClass;
+text: .text%Java_java_lang_Class_forName0;
+text: .text%Java_java_lang_String_intern;
+text: .text%Java_sun_reflect_NativeConstructorAccessorImpl_newInstance0;
+text: .text%Java_java_lang_Throwable_fillInStackTrace;
+text: .text%Java_java_lang_System_setOut0;
+text: .text%Java_java_lang_System_setErr0;
+text: .text%Java_java_lang_Compiler_registerNatives;
+text: .text%Java_java_io_FileSystem_getFileSystem;
+text: .text%JNU_NewObjectByName;
+text: .text%Java_java_io_UnixFileSystem_initIDs;
+text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2;
+text: .text%Java_java_io_UnixFileSystem_list;
+text: .text%JNU_GetStringPlatformChars;
+text: .text%JNU_ReleaseStringPlatformChars;
+text: .text%JNU_ClassString;
+text: .text%JNU_CopyObjectArray;
+text: .text%Java_java_io_UnixFileSystem_canonicalize;
+text: .text%Java_java_io_UnixFileSystem_getBooleanAttributes0;
+text: .text%Java_java_lang_ClassLoader_findLoadedClass;
+text: .text%Java_java_lang_ClassLoader_findBootstrapClass;
+text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2Ljava_security_AccessControlContext_2;
+text: .text%Java_java_lang_System_mapLibraryName;
+text: .text%cpchars: OUTPUTDIR/System.o;
+text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load;
+text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_find;
+text: .text%Java_java_lang_Float_floatToIntBits;
+text: .text%Java_java_lang_Double_doubleToLongBits;
+text: .text%Java_java_io_FileInputStream_open;
+text: .text%fileOpen;
+text: .text%Java_java_io_UnixFileSystem_getLength;
+text: .text%Java_java_io_FileInputStream_readBytes;
+text: .text%readBytes;
+text: .text%Java_java_io_FileInputStream_close0;
+text: .text%Java_java_lang_Object_getClass;
+text: .text%Java_java_lang_ClassLoader_defineClass0;
+text: .text%VerifyClassCodes;
+# Test Exit
+text: .text%Java_java_lang_Shutdown_halt;
+# Test Hello
+text: .text%Java_java_io_FileOutputStream_writeBytes;
+text: .text%writeBytes;
+# Test Sleep
+# Test IntToString
+# Test LoadToolkit
+text: .text%Java_java_util_ResourceBundle_getClassContext;
+text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2;
+text: .text%JNU_GetEnv;
+text: .text%Java_java_io_UnixFileSystem_checkAccess;
+text: .text%Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
+text: .text%Java_java_lang_ref_Finalizer_invokeFinalizeMethod;
+text: .text%Java_java_io_FileInputStream_available;
+text: .text%Java_java_lang_reflect_Array_newArray;
+text: .text%Java_java_lang_Throwable_getStackTraceDepth;
+text: .text%Java_java_lang_Throwable_getStackTraceElement;
+text: .text%Java_java_lang_System_identityHashCode;
+text: .text%Java_sun_misc_Signal_findSignal;
+text: .text%Java_sun_misc_Signal_handle0;
+text: .text%JNU_NotifyAll;
+# Test LoadFrame
+text: .text%JNU_CallMethodByName;
+text: .text%JNU_CallMethodByNameV;
+text: .text%Java_java_util_logging_FileHandler_lockFile;
+text: .text%Java_java_io_FileOutputStream_open;
+text: .text%Java_java_io_UnixFileSystem_createDirectory;
+text: .text%Java_java_io_UnixFileSystem_getLastModifiedTime;
+text: .text%Java_java_util_prefs_FileSystemPreferences_lockFile0;
+text: .text%Java_java_io_UnixFileSystem_setLastModifiedTime;
+text: .text%Java_java_util_prefs_FileSystemPreferences_unlockFile0;
+text: .text%Java_java_io_FileOutputStream_close0;
+text: .text%Java_java_util_logging_FileHandler_unlockFile;
+# Test LoadJFrame
+text: .text%Java_java_lang_Class_isAssignableFrom;
+text: .text%Java_java_lang_Class_isInstance;
+# Test JHello
+# SwingSet
+text: .text%Java_java_util_TimeZone_getSystemTimeZoneID;
+text: .text%findJavaTZ_md;
+text: .text%Java_java_lang_StrictMath_log;
--- a/jdk/makefiles/mapfiles/libjli/mapfile-vers	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/mapfiles/libjli/mapfile-vers	Tue Sep 25 11:48:00 2012 -0700
@@ -34,6 +34,8 @@
 		JLI_ReportErrorMessageSys;
 		JLI_ReportMessage;
 		JLI_ReportExceptionDescription;
+		JLI_GetStdArgs;
+		JLI_GetStdArgc;
 	local:
 		*;
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/mapfiles/libjpeg/reorder-x86	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,119 @@
+data = R0x2000;
+text = LOAD ?RXO;
+# Test Null
+# Test Exit
+# Test Hello
+# Test Sleep
+# Test IntToString
+# Test LoadToolkit
+# Test LoadFrame
+# Test LoadJFrame
+# Test JHello
+# SwingSet
+text: .text%JNI_OnLoad;
+text: .text%Java_sun_awt_image_JPEGImageDecoder_initIDs;
+text: .text%Java_sun_awt_image_JPEGImageDecoder_readImage;
+text: .text%jStdError;
+text: .text%jCreaDecompress;
+text: .text%jIMemMgr;
+text: .text%jMemInit;
+text: .text%jGetSmall;
+text: .text%jIMReader;
+text: .text%alloc_small: OUTPUTDIR/jmemmgr.o;
+text: .text%reset_marker_reader: OUTPUTDIR/jdmarker.o;
+text: .text%jIInCtlr;
+# text: .text%GET_ARRAYS: OUTPUTDIR/jpegdecoder.o;
+text: .text%jReadHeader;
+text: .text%jConsumeInput;
+text: .text%reset_input_controller: OUTPUTDIR/jdinput.o;
+text: .text%reset_error_mgr: OUTPUTDIR/jerror.o;
+text: .text%sun_jpeg_init_source;
+text: .text%consume_markers: OUTPUTDIR/jdinput.o;
+text: .text%read_markers: OUTPUTDIR/jdmarker.o;
+# text: .text%first_marker: OUTPUTDIR/jdmarker.o;
+text: .text%sun_jpeg_fill_input_buffer;
+# text: .text%RELEASE_ARRAYS: OUTPUTDIR/jpegdecoder.o;
+# text: .text%get_soi: OUTPUTDIR/jdmarker.o;
+text: .text%emit_message: OUTPUTDIR/jerror.o;
+# text: .text%next_marker: OUTPUTDIR/jdmarker.o;
+text: .text%get_interesting_appn: OUTPUTDIR/jdmarker.o;
+# text: .text%examine_app0: OUTPUTDIR/jdmarker.o;
+text: .text%skip_variable: OUTPUTDIR/jdmarker.o;
+text: .text%sun_jpeg_skip_input_data;
+# text: .text%examine_app14: OUTPUTDIR/jdmarker.o;
+text: .text%get_dqt: OUTPUTDIR/jdmarker.o;
+text: .text%jAlcQTable;
+text: .text%get_sof: OUTPUTDIR/jdmarker.o;
+# text: .text%get_dri: OUTPUTDIR/jdmarker.o;
+text: .text%get_dht: OUTPUTDIR/jdmarker.o;
+text: .text%jAlcHTable;
+text: .text%get_sos: OUTPUTDIR/jdmarker.o;
+# text: .text%initial_setup: OUTPUTDIR/jdinput.o;
+text: .text%jDivRound;
+# text: .text%default_decompress_parms: OUTPUTDIR/jdapimin.o;
+text: .text%jHasMultScn;
+text: .text%jStrtDecompress;
+text: .text%jIDMaster;
+# text: .text%master_selection: OUTPUTDIR/jdmaster.o;
+text: .text%jCalcDimensions;
+# text: .text%use_merged_upsample: OUTPUTDIR/jdmaster.o;
+# text: .text%prepare_range_limit_table: OUTPUTDIR/jdmaster.o;
+text: .text%jIDColor;
+# text: .text%build_ycc_rgb_table: OUTPUTDIR/jdcolor.o;
+text: .text%jIUpsampler;
+text: .text%jRound;
+text: .text%alloc_sarray: OUTPUTDIR/jmemmgr.o;
+text: .text%alloc_large: OUTPUTDIR/jmemmgr.o;
+text: .text%jGetLarge;
+text: .text%jIDPostC;
+text: .text%jIIDCT;
+text: .text%jIHDecoder;
+text: .text%jIDCoefC;
+text: .text%jIDMainC;
+# text: .text%alloc_funny_pointers: OUTPUTDIR/jdmainct.o;
+text: .text%realize_virt_arrays: OUTPUTDIR/jmemmgr.o;
+text: .text%start_input_pass: OUTPUTDIR/jdinput.o;
+# text: .text%per_scan_setup: OUTPUTDIR/jdinput.o;
+# text: .text%latch_quant_tables: OUTPUTDIR/jdinput.o;
+text: .text%start_pass_huff_decoder: OUTPUTDIR/jdhuff.o;
+text: .text%jMkDDerived;
+text: .text%start_input_pass: OUTPUTDIR/jdcoefct.o;
+# text: .text%start_iMCU_row: OUTPUTDIR/jdcoefct.o;
+# text: .text%output_pass_setup: OUTPUTDIR/jdapistd.o;
+text: .text%prepare_for_output_pass: OUTPUTDIR/jdmaster.o;
+text: .text%start_pass: OUTPUTDIR/jddctmgr.o;
+text: .text%start_output_pass: OUTPUTDIR/jdcoefct.o;
+text: .text%start_pass_dcolor: OUTPUTDIR/jdcolor.o;
+text: .text%start_pass_upsample: OUTPUTDIR/jdsample.o;
+text: .text%start_pass_dpost: OUTPUTDIR/jdpostct.o;
+text: .text%start_pass_main: OUTPUTDIR/jdmainct.o;
+# text: .text%make_funny_pointers: OUTPUTDIR/jdmainct.o;
+text: .text%jReadScanlines;
+text: .text%process_data_context_main: OUTPUTDIR/jdmainct.o;
+text: .text%decompress_onepass: OUTPUTDIR/jdcoefct.o;
+text: .text%jZeroFar;
+text: .text%decode_mcu: OUTPUTDIR/jdhuff.o;
+text: .text%jFilBitBuf;
+text: .text%jHufDecode;
+text: .text%jRDislow;
+text: .text%sep_upsample: OUTPUTDIR/jdsample.o;
+text: .text%fullsize_upsample: OUTPUTDIR/jdsample.o;
+text: .text%h2v2_fancy_upsample: OUTPUTDIR/jdsample.o;
+text: .text%ycc_rgb_convert: OUTPUTDIR/jdcolor.o;
+# text: .text%set_wraparound_pointers: OUTPUTDIR/jdmainct.o;
+# text: .text%process_restart: OUTPUTDIR/jdhuff.o;
+text: .text%read_restart_marker: OUTPUTDIR/jdmarker.o;
+text: .text%finish_input_pass: OUTPUTDIR/jdinput.o;
+# text: .text%set_bottom_pointers: OUTPUTDIR/jdmainct.o;
+text: .text%jFinDecompress;
+text: .text%finish_output_pass: OUTPUTDIR/jdmaster.o;
+text: .text%sun_jpeg_term_source;
+text: .text%jAbort;
+text: .text%free_pool: OUTPUTDIR/jmemmgr.o;
+text: .text%jFreeLarge;
+text: .text%jFreeSmall;
+text: .text%jDestDecompress;
+text: .text%jDestroy;
+text: .text%self_destruct: OUTPUTDIR/jmemmgr.o;
+text: .text%jMemTerm;
+text: .text%process_data_simple_main: OUTPUTDIR/jdmainct.o;
--- a/jdk/makefiles/mapfiles/libnio/mapfile-linux	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/mapfiles/libnio/mapfile-linux	Tue Sep 25 11:48:00 2012 -0700
@@ -143,6 +143,7 @@
 		Java_sun_nio_fs_LinuxNativeDispatcher_fsetxattr0;
 		Java_sun_nio_fs_LinuxNativeDispatcher_fremovexattr0;
 		Java_sun_nio_fs_LinuxNativeDispatcher_setmntent0;
+                Java_sun_nio_fs_LinuxNativeDispatcher_getmntent;
 		Java_sun_nio_fs_LinuxNativeDispatcher_endmntent;
 		Java_sun_nio_fs_UnixNativeDispatcher_init;
 		Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
@@ -189,7 +190,6 @@
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrgid;
 		Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
-		Java_sun_nio_fs_UnixNativeDispatcher_getextmntent;
 		Java_sun_nio_fs_UnixCopyFile_transfer;
 		handleSocketError;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/mapfiles/libnio/mapfile-macosx	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,174 @@
+#
+# 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
+# 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.
+#
+
+SUNWprivate_1.1 {
+	global:
+                Java_java_nio_MappedByteBuffer_force0;
+                Java_java_nio_MappedByteBuffer_isLoaded0;
+                Java_java_nio_MappedByteBuffer_load0;
+                Java_sun_nio_ch_DatagramChannelImpl_disconnect0;
+                Java_sun_nio_ch_DatagramChannelImpl_initIDs;
+                Java_sun_nio_ch_DatagramChannelImpl_receive0;
+                Java_sun_nio_ch_DatagramChannelImpl_send0;
+                Java_sun_nio_ch_DatagramDispatcher_read0;
+                Java_sun_nio_ch_DatagramDispatcher_readv0;
+                Java_sun_nio_ch_DatagramDispatcher_write0;
+                Java_sun_nio_ch_DatagramDispatcher_writev0;
+                Java_sun_nio_ch_FileChannelImpl_close0;
+                Java_sun_nio_ch_FileChannelImpl_initIDs;
+                Java_sun_nio_ch_FileChannelImpl_map0;
+                Java_sun_nio_ch_FileChannelImpl_position0;
+                Java_sun_nio_ch_FileChannelImpl_transferTo0;
+                Java_sun_nio_ch_FileChannelImpl_unmap0;
+                Java_sun_nio_ch_FileDispatcherImpl_close0;
+                Java_sun_nio_ch_FileDispatcherImpl_closeIntFD;
+		Java_sun_nio_ch_FileDispatcherImpl_force0;
+                Java_sun_nio_ch_FileDispatcherImpl_init;
+		Java_sun_nio_ch_FileDispatcherImpl_lock0;
+                Java_sun_nio_ch_FileDispatcherImpl_preClose0;
+                Java_sun_nio_ch_FileDispatcherImpl_pread0;
+                Java_sun_nio_ch_FileDispatcherImpl_pwrite0;
+                Java_sun_nio_ch_FileDispatcherImpl_read0;
+                Java_sun_nio_ch_FileDispatcherImpl_readv0;
+		Java_sun_nio_ch_FileDispatcherImpl_release0;
+		Java_sun_nio_ch_FileDispatcherImpl_size0;
+		Java_sun_nio_ch_FileDispatcherImpl_truncate0;
+                Java_sun_nio_ch_FileDispatcherImpl_write0;
+                Java_sun_nio_ch_FileDispatcherImpl_writev0;
+                Java_sun_nio_ch_FileKey_init;
+                Java_sun_nio_ch_FileKey_initIDs;
+		Java_sun_nio_ch_InheritedChannel_close0;
+		Java_sun_nio_ch_InheritedChannel_dup;
+		Java_sun_nio_ch_InheritedChannel_dup2;
+		Java_sun_nio_ch_InheritedChannel_open0;
+		Java_sun_nio_ch_InheritedChannel_peerAddress0;
+		Java_sun_nio_ch_InheritedChannel_peerPort0;
+		Java_sun_nio_ch_InheritedChannel_soType0;
+                Java_sun_nio_ch_IOUtil_configureBlocking;
+                Java_sun_nio_ch_IOUtil_drain;
+                Java_sun_nio_ch_IOUtil_fdVal;
+                Java_sun_nio_ch_IOUtil_initIDs;
+                Java_sun_nio_ch_IOUtil_makePipe;
+                Java_sun_nio_ch_IOUtil_randomBytes;
+                Java_sun_nio_ch_IOUtil_setfdVal;
+		Java_sun_nio_ch_KQueue_kqueue;
+		Java_sun_nio_ch_KQueue_keventRegister;
+		Java_sun_nio_ch_KQueue_keventPoll;
+		Java_sun_nio_ch_KQueue_keventSize;
+		Java_sun_nio_ch_KQueue_identOffset;
+		Java_sun_nio_ch_KQueue_filterOffset;
+		Java_sun_nio_ch_KQueue_flagsOffset;
+		Java_sun_nio_ch_KQueuePort_socketpair;
+		Java_sun_nio_ch_KQueuePort_interrupt;
+		Java_sun_nio_ch_KQueuePort_drain1;
+		Java_sun_nio_ch_KQueuePort_close0;
+		Java_sun_nio_ch_NativeThread_current;
+		Java_sun_nio_ch_NativeThread_init;
+		Java_sun_nio_ch_NativeThread_signal;
+		Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0;
+		Java_sun_nio_ch_Net_canJoin6WithIPv4Group0;
+		Java_sun_nio_ch_Net_socket0;
+		Java_sun_nio_ch_Net_bind0;
+		Java_sun_nio_ch_Net_connect0;
+		Java_sun_nio_ch_Net_listen;
+		Java_sun_nio_ch_Net_localPort;
+		Java_sun_nio_ch_Net_localInetAddress;
+		Java_sun_nio_ch_Net_getIntOption0;
+		Java_sun_nio_ch_Net_setIntOption0;
+                Java_sun_nio_ch_Net_initIDs;
+		Java_sun_nio_ch_Net_isIPv6Available0;
+		Java_sun_nio_ch_Net_joinOrDrop4;
+		Java_sun_nio_ch_Net_blockOrUnblock4;
+		Java_sun_nio_ch_Net_joinOrDrop6;
+		Java_sun_nio_ch_Net_blockOrUnblock6;
+		Java_sun_nio_ch_Net_setInterface4;
+		Java_sun_nio_ch_Net_getInterface4;
+		Java_sun_nio_ch_Net_setInterface6;
+		Java_sun_nio_ch_Net_getInterface6;
+		Java_sun_nio_ch_Net_shutdown;
+                Java_sun_nio_ch_PollArrayWrapper_interrupt;
+                Java_sun_nio_ch_PollArrayWrapper_poll0;
+                Java_sun_nio_ch_ServerSocketChannelImpl_accept0;
+                Java_sun_nio_ch_ServerSocketChannelImpl_initIDs;
+                Java_sun_nio_ch_SocketChannelImpl_checkConnect;
+		Java_sun_nio_ch_SocketChannelImpl_sendOutOfBandData;
+		Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_accept0;
+		Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_initIDs;
+		Java_sun_nio_ch_UnixAsynchronousSocketChannelImpl_checkConnect;
+		Java_sun_nio_fs_BsdNativeDispatcher_initIDs;
+		Java_sun_nio_fs_BsdNativeDispatcher_getfsstat;
+		Java_sun_nio_fs_BsdNativeDispatcher_fsstatEntry;
+		Java_sun_nio_fs_BsdNativeDispatcher_endfsstat;
+		Java_sun_nio_fs_UnixNativeDispatcher_init;
+		Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
+		Java_sun_nio_fs_UnixNativeDispatcher_strerror;
+		Java_sun_nio_fs_UnixNativeDispatcher_dup;
+		Java_sun_nio_fs_UnixNativeDispatcher_access0;
+		Java_sun_nio_fs_UnixNativeDispatcher_stat0;
+		Java_sun_nio_fs_UnixNativeDispatcher_lstat0;
+		Java_sun_nio_fs_UnixNativeDispatcher_fstat;
+		Java_sun_nio_fs_UnixNativeDispatcher_fstatat0;
+		Java_sun_nio_fs_UnixNativeDispatcher_chmod0;
+		Java_sun_nio_fs_UnixNativeDispatcher_fchmod;
+		Java_sun_nio_fs_UnixNativeDispatcher_chown0;
+		Java_sun_nio_fs_UnixNativeDispatcher_lchown0;
+		Java_sun_nio_fs_UnixNativeDispatcher_fchown;
+		Java_sun_nio_fs_UnixNativeDispatcher_utimes0;
+		Java_sun_nio_fs_UnixNativeDispatcher_futimes;
+		Java_sun_nio_fs_UnixNativeDispatcher_open0;
+		Java_sun_nio_fs_UnixNativeDispatcher_openat0;
+		Java_sun_nio_fs_UnixNativeDispatcher_close;
+		Java_sun_nio_fs_UnixNativeDispatcher_read;
+		Java_sun_nio_fs_UnixNativeDispatcher_write;
+		Java_sun_nio_fs_UnixNativeDispatcher_fopen0;
+		Java_sun_nio_fs_UnixNativeDispatcher_fclose;
+		Java_sun_nio_fs_UnixNativeDispatcher_opendir0;
+		Java_sun_nio_fs_UnixNativeDispatcher_fdopendir;
+		Java_sun_nio_fs_UnixNativeDispatcher_readdir;
+		Java_sun_nio_fs_UnixNativeDispatcher_closedir;
+		Java_sun_nio_fs_UnixNativeDispatcher_link0;
+		Java_sun_nio_fs_UnixNativeDispatcher_unlink0;
+		Java_sun_nio_fs_UnixNativeDispatcher_unlinkat0;
+		Java_sun_nio_fs_UnixNativeDispatcher_rename0;
+		Java_sun_nio_fs_UnixNativeDispatcher_renameat0;
+		Java_sun_nio_fs_UnixNativeDispatcher_mkdir0;
+		Java_sun_nio_fs_UnixNativeDispatcher_rmdir0;
+		Java_sun_nio_fs_UnixNativeDispatcher_symlink0;
+		Java_sun_nio_fs_UnixNativeDispatcher_readlink0;
+		Java_sun_nio_fs_UnixNativeDispatcher_realpath0;
+		Java_sun_nio_fs_UnixNativeDispatcher_statvfs0;
+		Java_sun_nio_fs_UnixNativeDispatcher_pathconf0;
+		Java_sun_nio_fs_UnixNativeDispatcher_fpathconf;
+		Java_sun_nio_fs_UnixNativeDispatcher_mknod0;
+		Java_sun_nio_fs_UnixNativeDispatcher_getpwuid;
+		Java_sun_nio_fs_UnixNativeDispatcher_getgrgid;
+		Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
+		Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
+		Java_sun_nio_fs_UnixCopyFile_transfer;
+		handleSocketError;
+
+	local:
+		*;
+};
--- a/jdk/makefiles/mapfiles/libnio/mapfile-solaris	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/mapfiles/libnio/mapfile-solaris	Tue Sep 25 11:48:00 2012 -0700
@@ -169,10 +169,10 @@
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrgid;
 		Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
-		Java_sun_nio_fs_UnixNativeDispatcher_getextmntent;
 		Java_sun_nio_fs_UnixCopyFile_transfer;
 		Java_sun_nio_fs_SolarisNativeDispatcher_init;
 		Java_sun_nio_fs_SolarisNativeDispatcher_facl;
+		Java_sun_nio_fs_SolarisNativeDispatcher_getextmntent;
 		Java_sun_nio_fs_SolarisWatchService_init;
 		Java_sun_nio_fs_SolarisWatchService_portCreate;
 		Java_sun_nio_fs_SolarisWatchService_portAssociate;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/mapfiles/libnio/reorder-x86	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,17 @@
+data = R0x2000;
+text = LOAD ?RXO;
+# Test Null
+# Test Exit
+# Test Hello
+# Test Sleep
+# Test IntToString
+# Test LoadToolkit
+text: .text%Java_sun_nio_ch_FileChannelImpl_initIDs;
+text: .text%Java_sun_nio_ch_FileDispatcher_initIDs;
+text: .text%Java_sun_nio_ch_IOUtil_initIDs;
+text: .text%Java_sun_nio_ch_FileDispatcher_read0;
+text: .text%convertReturnVal;
+# Test LoadFrame
+# Test LoadJFrame
+# Test JHello
+# SwingSet
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/mapfiles/libverify/reorder-x86	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,40 @@
+data = R0x2000;
+text = LOAD ?RXO;
+# Test Null
+text: .text%VerifyFixClassname;
+text: .text%VerifyClassname;
+text: .text%skip_over_fieldname: OUTPUTDIR/check_format.o;
+text: .text%skip_over_field_signature: OUTPUTDIR/check_format.o;
+text: .text%VerifyClass;
+text: .text%make_class_info_from_name: OUTPUTDIR/check_code.o;
+text: .text%class_name_to_ID: OUTPUTDIR/check_code.o;
+text: .text%make_class_info: OUTPUTDIR/check_code.o;
+text: .text%free_block: OUTPUTDIR/check_code.o;
+text: .text%verify_method: OUTPUTDIR/check_code.o;
+text: .text%verify_opcode_operands: OUTPUTDIR/check_code.o;
+text: .text%initialize_dataflow: OUTPUTDIR/check_code.o;
+text: .text%signature_to_fieldtype: OUTPUTDIR/check_code.o;
+text: .text%check_register_values: OUTPUTDIR/check_code.o;
+text: .text%pop_stack: OUTPUTDIR/check_code.o;
+text: .text%update_registers: OUTPUTDIR/check_code.o;
+text: .text%push_stack: OUTPUTDIR/check_code.o;
+text: .text%merge_into_successors: OUTPUTDIR/check_code.o;
+text: .text%cp_index_to_class_fullinfo: OUTPUTDIR/check_code.o;
+text: .text%set_protected: OUTPUTDIR/check_code.o;
+text: .text%merge_into_one_successor: OUTPUTDIR/check_code.o;
+text: .text%merge_registers: OUTPUTDIR/check_code.o;
+# Test Exit
+# Test Hello
+text: .text%merge_fullinfo_types: OUTPUTDIR/check_code.o;
+text: .text%isAssignableTo: OUTPUTDIR/check_code.o;
+# Test Sleep
+text: .text%isLegalTarget: OUTPUTDIR/check_code.o;
+text: .text%verify_constant_pool_type: OUTPUTDIR/check_code.o;
+# Test IntToString
+# Test LoadToolkit
+# Test LoadFrame
+# Test LoadJFrame
+# Test JHello
+# SwingSet
+text: .text%copy_stack: OUTPUTDIR/check_code.o;
+text: .text%ntohl: OUTPUTDIR/check_code.o;
--- a/jdk/makefiles/mapfiles/libzip/mapfile-vers	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/makefiles/mapfiles/libzip/mapfile-vers	Tue Sep 25 11:48:00 2012 -0700
@@ -37,16 +37,12 @@
 		Java_java_util_zip_Deflater_deflateBytes;
 		Java_java_util_zip_Deflater_end;
 		Java_java_util_zip_Deflater_getAdler;
-		Java_java_util_zip_Deflater_getBytesRead;
-		Java_java_util_zip_Deflater_getBytesWritten;
 		Java_java_util_zip_Deflater_init;
 		Java_java_util_zip_Deflater_initIDs;
 		Java_java_util_zip_Deflater_reset;
 		Java_java_util_zip_Deflater_setDictionary;
 		Java_java_util_zip_Inflater_end;
 		Java_java_util_zip_Inflater_getAdler;
-		Java_java_util_zip_Inflater_getBytesRead;
-		Java_java_util_zip_Inflater_getBytesWritten;
 		Java_java_util_zip_Inflater_inflateBytes;
 		Java_java_util_zip_Inflater_init;
 		Java_java_util_zip_Inflater_initIDs;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/makefiles/mapfiles/libzip/reorder-x86	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,49 @@
+data = R0x2000;
+text = LOAD ?RXO;
+# Test Null
+text: .text%ZIP_Open;
+text: .text%ZIP_Open_Generic;
+text: .text%InitializeZip;
+text: .text%allocZip;
+text: .text%readCEN: OUTPUTDIR/zip_util.o;
+text: .text%findEND: OUTPUTDIR/zip_util.o;
+text: .text%hash: OUTPUTDIR/zip_util.o;
+text: .text%isMetaName: OUTPUTDIR/zip_util.o;
+text: .text%addMetaName: OUTPUTDIR/zip_util.o;
+text: .text%ZIP_FindEntry;
+text: .text%ZIP_GetEntry;
+text: .text%ZIP_Lock;
+text: .text%readLOC: OUTPUTDIR/zip_util.o;
+text: .text%ZIP_Unlock;
+text: .text%ZIP_FreeEntry;
+text: .text%Java_java_util_zip_ZipFile_initIDs;
+text: .text%Java_java_util_zip_ZipFile_open;
+text: .text%Java_java_util_zip_ZipFile_getTotal;
+text: .text%Java_java_util_zip_ZipFile_getEntry;
+text: .text%Java_java_util_zip_ZipFile_freeEntry;
+text: .text%Java_java_util_zip_ZipFile_getEntryTime;
+text: .text%Java_java_util_zip_ZipFile_getEntryCrc;
+text: .text%Java_java_util_zip_ZipFile_getEntryCSize;
+text: .text%Java_java_util_zip_ZipFile_getEntrySize;
+text: .text%Java_java_util_zip_ZipFile_getEntryFlag;
+text: .text%Java_java_util_zip_ZipFile_getEntryMethod;
+text: .text%Java_java_util_zip_ZipFile_getEntryBytes;
+text: .text%Java_java_util_zip_Inflater_initIDs;
+text: .text%Java_java_util_zip_Inflater_init;
+text: .text%inflateInit2_;
+text: .text%zcalloc;
+text: .text%inflateReset;
+text: .text%Java_java_util_zip_Inflater_inflateBytes;
+text: .text%inflate;
+text: .text%Java_java_util_zip_ZipFile_read;
+text: .text%ZIP_Read;
+text: .text%huft_build: OUTPUTDIR/inftrees.o;
+text: .text%zcfree;
+text: .text%Java_java_util_jar_JarFile_getMetaInfEntryNames;
+text: .text%ZIP_ReadEntry;
+text: .text%InflateFully;
+text: .text%inflateEnd;
+text: .text%Java_java_util_zip_Inflater_reset;
+text: .text%Java_java_util_zip_ZipFile_close;
+text: .text%ZIP_Close;
+text: .text%Java_java_util_zip_Inflater_end;
--- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -40,6 +40,7 @@
 import java.awt.peer.ComponentPeer;
 import java.awt.peer.ContainerPeer;
 
+import java.awt.peer.KeyboardFocusManagerPeer;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.lang.reflect.Field;
 import java.security.AccessController;
@@ -894,15 +895,15 @@
                             ", focusedWindowChangeAllowed=" + focusedWindowChangeAllowed +
                             ", time= " + time + ", cause=" + cause);
         }
-        if (LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                processSynchronousLightweightTransfer(getTarget(), lightweightChild, temporary,
-                        focusedWindowChangeAllowed, time)) {
+        if (LWKeyboardFocusManagerPeer.processSynchronousLightweightTransfer(
+                getTarget(), lightweightChild, temporary,
+                focusedWindowChangeAllowed, time)) {
             return true;
         }
 
-        int result = LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                shouldNativelyFocusHeavyweight(getTarget(), lightweightChild, temporary,
-                        focusedWindowChangeAllowed, time, cause);
+        int result = LWKeyboardFocusManagerPeer.shouldNativelyFocusHeavyweight(
+                getTarget(), lightweightChild, temporary,
+                focusedWindowChangeAllowed, time, cause);
         switch (result) {
             case LWKeyboardFocusManagerPeer.SNFH_FAILURE:
                 return false;
@@ -951,14 +952,13 @@
                     return false;
                 }
 
-                LWComponentPeer focusOwnerPeer =
-                    LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                        getFocusOwner();
-                Component focusOwner = (focusOwnerPeer != null) ? focusOwnerPeer.getTarget() : null;
+                KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
+                Component focusOwner = kfmPeer.getCurrentFocusOwner();
                 return LWKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                         getTarget(), temporary,
                         focusedWindowChangeAllowed,
                         time, cause, focusOwner);
+
             case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
                 return true;
         }
@@ -1251,9 +1251,6 @@
 
         if (!target.isFocusOwner() && LWKeyboardFocusManagerPeer.shouldFocusOnClick(target)) {
             LWKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
-        } else {
-            // Anyway request focus to the toplevel.
-            getWindowPeerOrSelf().requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
         }
     }
 
@@ -1263,8 +1260,8 @@
     protected void handleJavaFocusEvent(FocusEvent e) {
         // Note that the peer receives all the FocusEvents from
         // its lightweight children as well
-        LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                setFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? this : null);
+        KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
+        kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
     }
 
     /**
--- a/jdk/src/macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -26,85 +26,47 @@
 package sun.lwawt;
 
 import java.awt.Component;
-import java.awt.KeyboardFocusManager;
 import java.awt.Window;
-
-import java.util.Map;
-import java.util.HashMap;
-
-import sun.awt.AWTAccessor;
-import sun.awt.AppContext;
 import sun.awt.KeyboardFocusManagerPeerImpl;
 
 public class LWKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
-
-    private Object lock = new Object();
-    private LWWindowPeer focusedWindow;
-    private LWComponentPeer focusOwner;
+    private static final LWKeyboardFocusManagerPeer inst = new LWKeyboardFocusManagerPeer();
 
-    private static Map<KeyboardFocusManager, LWKeyboardFocusManagerPeer> instances =
-        new HashMap<KeyboardFocusManager, LWKeyboardFocusManagerPeer>();
+    private Window focusedWindow;
+    private Component focusOwner;
 
-    public static synchronized LWKeyboardFocusManagerPeer getInstance(AppContext ctx) {
-        return getInstance(AWTAccessor.getKeyboardFocusManagerAccessor().
-                           getCurrentKeyboardFocusManager(ctx));
+    public static LWKeyboardFocusManagerPeer getInstance() {
+        return inst;
     }
 
-    public static synchronized LWKeyboardFocusManagerPeer getInstance(KeyboardFocusManager manager) {
-        LWKeyboardFocusManagerPeer instance = instances.get(manager);
-        if (instance == null) {
-            instance = new LWKeyboardFocusManagerPeer(manager);
-            instances.put(manager, instance);
-        }
-        return instance;
+    private LWKeyboardFocusManagerPeer() {
     }
 
-    public LWKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
-        super(manager);
+    @Override
+    public void setCurrentFocusedWindow(Window win) {
+        synchronized (this) {
+            focusedWindow = win;
+        }
     }
 
     @Override
     public Window getCurrentFocusedWindow() {
-        synchronized (lock) {
-            return (focusedWindow != null) ? (Window)focusedWindow.getTarget() : null;
+        synchronized (this) {
+            return focusedWindow;
         }
     }
 
     @Override
     public Component getCurrentFocusOwner() {
-        synchronized (lock) {
-            return (focusOwner != null) ? focusOwner.getTarget() : null;
+        synchronized (this) {
+            return focusOwner;
         }
     }
 
     @Override
     public void setCurrentFocusOwner(Component comp) {
-        synchronized (lock) {
-            focusOwner = (comp != null) ? (LWComponentPeer)comp.getPeer() : null;
-        }
-    }
-
-    void setFocusedWindow(LWWindowPeer peer) {
-        synchronized (lock) {
-            focusedWindow = peer;
-        }
-    }
-
-    LWWindowPeer getFocusedWindow() {
-        synchronized (lock) {
-            return focusedWindow;
-        }
-    }
-
-    void setFocusOwner(LWComponentPeer peer) {
-        synchronized (lock) {
-            focusOwner = peer;
-        }
-    }
-
-    LWComponentPeer getFocusOwner() {
-        synchronized (lock) {
-            return focusOwner;
+        synchronized (this) {
+            focusOwner = comp;
         }
     }
 }
--- a/jdk/src/macosx/classes/sun/lwawt/LWToolkit.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWToolkit.java	Tue Sep 25 11:48:00 2012 -0700
@@ -415,8 +415,8 @@
     }
 
     @Override
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
-        return LWKeyboardFocusManagerPeer.getInstance(manager);
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
+        return LWKeyboardFocusManagerPeer.getInstance();
     }
 
     @Override
--- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -88,10 +88,16 @@
 
     private volatile int windowState = Frame.NORMAL;
 
+    // check that the mouse is over the window
+    private volatile boolean isMouseOver = false;
+
+    // A peer where the last mouse event came to. Used by cursor manager to
+    // find the component under cursor
+    private static volatile LWComponentPeer lastCommonMouseEventPeer = null;
+
     // A peer where the last mouse event came to. Used to generate
-    // MOUSE_ENTERED/EXITED notifications and by cursor manager to
-    // find the component under cursor
-    private static volatile LWComponentPeer lastMouseEventPeer = null;
+    // MOUSE_ENTERED/EXITED notifications
+    private volatile LWComponentPeer lastMouseEventPeer;
 
     // Peers where all dragged/released events should come to,
     // depending on what mouse button is being dragged according to Cocoa
@@ -232,8 +238,7 @@
         // TODO: update graphicsConfig, see 4868278
         platformWindow.setVisible(visible);
         if (isSimpleWindow()) {
-            LWKeyboardFocusManagerPeer manager = LWKeyboardFocusManagerPeer.
-                getInstance(getAppContext());
+            KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
 
             if (visible) {
                 if (!getTarget().isAutoRequestFocus()) {
@@ -242,7 +247,7 @@
                     requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
                 }
             // Focus the owner in case this window is focused.
-            } else if (manager.getCurrentFocusedWindow() == getTarget()) {
+            } else if (kfmPeer.getCurrentFocusedWindow() == getTarget()) {
                 // Transfer focus to the owner.
                 LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this);
                 if (owner != null) {
@@ -707,66 +712,65 @@
         Rectangle r = getBounds();
         // findPeerAt() expects parent coordinates
         LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y);
-        LWWindowPeer lastWindowPeer =
-            (lastMouseEventPeer != null) ? lastMouseEventPeer.getWindowPeerOrSelf() : null;
-        LWWindowPeer curWindowPeer =
-            (targetPeer != null) ? targetPeer.getWindowPeerOrSelf() : null;
 
         if (id == MouseEvent.MOUSE_EXITED) {
-            // Sometimes we may get MOUSE_EXITED after lastMouseEventPeer is switched
-            // to a peer from another window. So we must first check if this peer is
-            // the same as lastWindowPeer
-            if (lastWindowPeer == this) {
-                if (isEnabled()) {
+            isMouseOver = false;
+            if (lastMouseEventPeer != null) {
+                if (lastMouseEventPeer.isEnabled()) {
                     Point lp = lastMouseEventPeer.windowToLocal(x, y,
-                                                                lastWindowPeer);
+                            this);
                     postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
-                                             MouseEvent.MOUSE_EXITED, when,
-                                             modifiers, lp.x, lp.y, screenX,
-                                             screenY, clickCount, popupTrigger,
-                                             button));
+                            MouseEvent.MOUSE_EXITED, when,
+                            modifiers, lp.x, lp.y, screenX,
+                            screenY, clickCount, popupTrigger,
+                            button));
+                }
+
+                // Sometimes we may get MOUSE_EXITED after lastCommonMouseEventPeer is switched
+                // to a peer from another window. So we must first check if this peer is
+                // the same as lastWindowPeer
+                if (lastCommonMouseEventPeer != null && lastCommonMouseEventPeer.getWindowPeerOrSelf() == this) {
+                    lastCommonMouseEventPeer = null;
                 }
                 lastMouseEventPeer = null;
             }
-        } else {
-            if (targetPeer != lastMouseEventPeer) {
-
-                if (id != MouseEvent.MOUSE_DRAGGED || lastMouseEventPeer == null) {
-                    // lastMouseEventPeer may be null if mouse was out of Java windows
-                    if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) {
-                        // Sometimes, MOUSE_EXITED is not sent by delegate (or is sent a bit
-                        // later), in which case lastWindowPeer is another window
-                        if (lastWindowPeer != this) {
-                            Point oldp = lastMouseEventPeer.windowToLocal(x, y, lastWindowPeer);
-                            // Additionally translate from this to lastWindowPeer coordinates
-                            Rectangle lr = lastWindowPeer.getBounds();
-                            oldp.x += r.x - lr.x;
-                            oldp.y += r.y - lr.y;
-                            postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
-                                                     MouseEvent.MOUSE_EXITED,
-                                                     when, modifiers,
-                                                     oldp.x, oldp.y, screenX, screenY,
-                                                     clickCount, popupTrigger, button));
-                        } else {
-                            Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
-                            postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
-                                                     MouseEvent.MOUSE_EXITED,
-                                                     when, modifiers,
-                                                     oldp.x, oldp.y, screenX, screenY,
-                                                     clickCount, popupTrigger, button));
-                        }
-                    }
-                    if (targetPeer != null && targetPeer.isEnabled() && id != MouseEvent.MOUSE_ENTERED) {
-                        Point newp = targetPeer.windowToLocal(x, y, curWindowPeer);
+        } else if(id == MouseEvent.MOUSE_ENTERED) {
+            isMouseOver = true;
+            if (targetPeer != null) {
+                if (targetPeer.isEnabled()) {
+                    Point lp = targetPeer.windowToLocal(x, y, this);
                         postEvent(new MouseEvent(targetPeer.getTarget(),
-                                                 MouseEvent.MOUSE_ENTERED,
-                                                 when, modifiers,
-                                                 newp.x, newp.y, screenX, screenY,
-                                                 clickCount, popupTrigger, button));
-                    }
+                            MouseEvent.MOUSE_ENTERED, when,
+                            modifiers, lp.x, lp.y, screenX,
+                            screenY, clickCount, popupTrigger,
+                            button));
                 }
+                lastCommonMouseEventPeer = targetPeer;
                 lastMouseEventPeer = targetPeer;
             }
+        } else {
+            PlatformWindow topmostPlatforWindow =
+                    platformWindow.getTopmostPlatformWindowUnderMouse();
+
+            LWWindowPeer topmostWindowPeer =
+                    topmostPlatforWindow != null ? topmostPlatforWindow.getPeer() : null;
+
+            // topmostWindowPeer == null condition is added for the backward
+            // compatibility with applets. It can be removed when the
+            // getTopmostPlatformWindowUnderMouse() method will be properly
+            // implemented in CPlatformEmbeddedFrame class
+            if (topmostWindowPeer == this || topmostWindowPeer == null) {
+                generateMouseEnterExitEventsForComponents(when, button, x, y,
+                        screenX, screenY, modifiers, clickCount, popupTrigger,
+                        targetPeer);
+            } else {
+                LWComponentPeer topmostTargetPeer =
+                        topmostWindowPeer != null ? topmostWindowPeer.findPeerAt(r.x + x, r.y + y) : null;
+                topmostWindowPeer.generateMouseEnterExitEventsForComponents(when, button, x, y,
+                        screenX, screenY, modifiers, clickCount, popupTrigger,
+                        topmostTargetPeer);
+            }
+
             // TODO: fill "bdata" member of AWTEvent
 
             int eventButtonMask = (button > 0)? MouseEvent.getMaskForButton(button) : 0;
@@ -794,6 +798,14 @@
                     mouseClickButtons |= eventButtonMask;
                 }
 
+                // The window should be focused on mouse click. If it gets activated by the native platform,
+                // this request will be no op. It will take effect when:
+                // 1. A simple not focused window is clicked.
+                // 2. An active but not focused owner frame/dialog is clicked.
+                // The mouse event then will trigger a focus request "in window" to the component, so the window
+                // should gain focus before.
+                requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
+
                 mouseDownTarget[targetIdx] = targetPeer;
             } else if (id == MouseEvent.MOUSE_DRAGGED) {
                 // Cocoa dragged event has the information about which mouse
@@ -816,19 +828,13 @@
                 // mouseClickButtons is updated below, after MOUSE_CLICK is sent
             }
 
-            // check if we receive mouseEvent from outside the window's bounds
-            // it can be either mouseDragged or mouseReleased
-            if (curWindowPeer == null) {
-                //TODO This can happen if this window is invisible. this is correct behavior in this case?
-                curWindowPeer = this;
-            }
             if (targetPeer == null) {
                 //TODO This can happen if this window is invisible. this is correct behavior in this case?
                 targetPeer = this;
             }
 
 
-            Point lp = targetPeer.windowToLocal(x, y, curWindowPeer);
+            Point lp = targetPeer.windowToLocal(x, y, this);
             if (targetPeer.isEnabled()) {
                 MouseEvent event = new MouseEvent(targetPeer.getTarget(), id,
                                                   when, modifiers, lp.x, lp.y,
@@ -852,6 +858,38 @@
         notifyUpdateCursor();
     }
 
+    private void generateMouseEnterExitEventsForComponents(long when,
+            int button, int x, int y, int screenX, int screenY,
+            int modifiers, int clickCount, boolean popupTrigger,
+            LWComponentPeer targetPeer) {
+
+        if (!isMouseOver || targetPeer == lastMouseEventPeer) {
+            return;
+        }
+
+        // Generate Mouse Exit for components
+        if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) {
+            Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
+            postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
+                    MouseEvent.MOUSE_EXITED,
+                    when, modifiers,
+                    oldp.x, oldp.y, screenX, screenY,
+                    clickCount, popupTrigger, button));
+        }
+        lastCommonMouseEventPeer = targetPeer;
+        lastMouseEventPeer = targetPeer;
+
+        // Generate Mouse Enter for components
+        if (targetPeer != null && targetPeer.isEnabled()) {
+            Point newp = targetPeer.windowToLocal(x, y, this);
+            postEvent(new MouseEvent(targetPeer.getTarget(),
+                    MouseEvent.MOUSE_ENTERED,
+                    when, modifiers,
+                    newp.x, newp.y, screenX, screenY,
+                    clickCount, popupTrigger, button));
+        }
+    }
+
     public void dispatchMouseWheelEvent(long when, int x, int y, int modifiers,
                                         int scrollType, int scrollAmount,
                                         int wheelRotation, double preciseWheelRotation,
@@ -884,20 +922,16 @@
     public void dispatchKeyEvent(int id, long when, int modifiers,
                                  int keyCode, char keyChar, int keyLocation)
     {
-        LWComponentPeer focusOwner =
-            LWKeyboardFocusManagerPeer.getInstance(getAppContext()).
-                getFocusOwner();
+        LWKeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
+        Component focusOwner = kfmPeer.getCurrentFocusOwner();
 
-        // Null focus owner may receive key event when
-        // application hides the focused window upon ESC press
-        // (AWT transfers/clears the focus owner) and pending ESC release
-        // may come to already hidden window. This check eliminates NPE.
-        if (focusOwner != null) {
-            KeyEvent event =
-                new KeyEvent(focusOwner.getTarget(), id, when, modifiers,
-                             keyCode, keyChar, keyLocation);
-            focusOwner.postEvent(event);
+        if (focusOwner == null) {
+            focusOwner = kfmPeer.getCurrentFocusedWindow();
+            if (focusOwner == null) {
+                focusOwner = this.getTarget();
+            }
         }
+        postEvent(new KeyEvent(focusOwner, id, when, modifiers, keyCode, keyChar, keyLocation));
     }
 
 
@@ -1096,11 +1130,11 @@
     }
 
     public static LWWindowPeer getWindowUnderCursor() {
-        return lastMouseEventPeer != null ? lastMouseEventPeer.getWindowPeerOrSelf() : null;
+        return lastCommonMouseEventPeer != null ? lastCommonMouseEventPeer.getWindowPeerOrSelf() : null;
     }
 
     public static LWComponentPeer<?, ?> getPeerUnderCursor() {
-        return lastMouseEventPeer;
+        return lastCommonMouseEventPeer;
     }
 
     /*
@@ -1213,10 +1247,8 @@
             }
         }
 
-        LWKeyboardFocusManagerPeer manager = LWKeyboardFocusManagerPeer.
-            getInstance(getAppContext());
-
-        Window oppositeWindow = becomesFocused ? manager.getCurrentFocusedWindow() : null;
+        KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
+        Window oppositeWindow = becomesFocused ? kfmPeer.getCurrentFocusedWindow() : null;
 
         // Note, the method is not called:
         // - when the opposite (gaining focus) window is an owned/owner window.
@@ -1229,10 +1261,10 @@
             grabbingWindow.ungrab();
         }
 
-        manager.setFocusedWindow(becomesFocused ? LWWindowPeer.this : null);
+        kfmPeer.setCurrentFocusedWindow(becomesFocused ? getTarget() : null);
 
         int eventID = becomesFocused ? WindowEvent.WINDOW_GAINED_FOCUS : WindowEvent.WINDOW_LOST_FOCUS;
-        WindowEvent windowEvent = new WindowEvent(getTarget(), eventID, oppositeWindow);
+        WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, oppositeWindow, System.currentTimeMillis());
 
         // TODO: wrap in SequencedEvent
         postEvent(windowEvent);
--- a/jdk/src/macosx/classes/sun/lwawt/PlatformWindow.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/PlatformWindow.java	Tue Sep 25 11:48:00 2012 -0700
@@ -118,6 +118,8 @@
 
     public void setAlwaysOnTop(boolean value);
 
+    public PlatformWindow getTopmostPlatformWindowUnderMouse();
+
     public void updateFocusableWindowState();
 
     public boolean rejectFocusRequest(CausedFocusEvent.Cause cause);
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Tue Sep 25 11:48:00 2012 -0700
@@ -151,6 +151,10 @@
     @Override
     public void setAlwaysOnTop(boolean value) {}
 
+    // This method should be properly implemented for applets.
+    // It returns null just as a stub.
+    public PlatformWindow getTopmostPlatformWindowUnderMouse() { return null; }
+
     @Override
     public void updateFocusableWindowState() {}
 
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Tue Sep 25 11:48:00 2012 -0700
@@ -61,8 +61,9 @@
     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
     private static native void nativeSetNSWindowSecurityWarningPositioning(long nsWindowPtr, double x, double y, float biasX, float biasY);
     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
-    private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr);
+    private static native void nativeSynthesizeMouseEnteredExitedEvents();
     private static native void nativeDispose(long nsWindowPtr);
+    private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
 
     private static native int nativeGetNSWindowDisplayID_AppKitThread(long nsWindowPtr);
 
@@ -588,7 +589,7 @@
             }
         }
 
-        nativeSynthesizeMouseEnteredExitedEvents(nsWindowPtr);
+        nativeSynthesizeMouseEnteredExitedEvents();
 
         // Configure stuff #2
         updateFocusabilityForAutoRequestFocus(true);
@@ -729,6 +730,10 @@
         setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
     }
 
+    public PlatformWindow getTopmostPlatformWindowUnderMouse(){
+        return CPlatformWindow.nativeGetTopmostPlatformWindowUnderMouse();
+    }
+
     @Override
     public void setOpacity(float opacity) {
         CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
@@ -803,7 +808,7 @@
                 throw new RuntimeException("Unknown window state: " + windowState);
         }
 
-        nativeSynthesizeMouseEnteredExitedEvents(nsWindowPtr);
+        nativeSynthesizeMouseEnteredExitedEvents();
 
         // NOTE: the SWP.windowState field gets updated to the newWindowState
         //       value when the native notification comes to us
--- a/jdk/src/macosx/native/com/apple/laf/ScreenMenu.m	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/com/apple/laf/ScreenMenu.m	Tue Sep 25 11:48:00 2012 -0700
@@ -37,7 +37,11 @@
 #import "ThreadUtilities.h"
 #import "CMenuBar.h"
 
-
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__     
+#endif 
+ 
 static JNF_CLASS_CACHE(sjc_ScreenMenu, "com/apple/laf/ScreenMenu");
 
 static jint ns2awtModifiers(NSUInteger keyMods) {
@@ -97,7 +101,7 @@
 {
     if (self.javaObjectWrapper == nil) {
 #ifdef DEBUG
-        NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
+        NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
 #endif
         return;
     }
@@ -115,7 +119,7 @@
 {
     if (self.javaObjectWrapper == nil) {
 #ifdef DEBUG
-        NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
+        NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
 #endif
         return;
     }
@@ -133,7 +137,7 @@
 {
     if (self.javaObjectWrapper == nil) {
 #ifdef DEBUG
-        NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
+        NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
 #endif
         return;
     }
--- a/jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiOut.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiOut.c	Tue Sep 25 11:48:00 2012 -0700
@@ -26,6 +26,11 @@
 //#define USE_ERROR
 //#define USE_TRACE
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #if USE_PLATFORM_MIDI_OUT == TRUE
 
 #include "PLATFORM_API_MacOSX_MidiUtils.h"
@@ -128,7 +133,7 @@
                 case 0xF7:
                     // System exclusive
                     fprintf(stderr, "%s: %d->internal error: sysex message status=0x%X while sending short message\n",
-                            __FILE__, __LINE__, data[0]);
+                            THIS_FILE, __LINE__, data[0]);
                     byteIsInvalid = TRUE;
                     break;
 
@@ -154,7 +159,7 @@
                 default:
                     // Invalid message
                     fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
-                            __FILE__, __LINE__, data[0]);
+                            THIS_FILE, __LINE__, data[0]);
                     byteIsInvalid = TRUE;
                     break;
             }
@@ -164,7 +169,7 @@
         default:
             // This can't happen, but handle it anyway.
             fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
-                    __FILE__, __LINE__, data[0]);
+                    THIS_FILE, __LINE__, data[0]);
             byteIsInvalid = TRUE;
             break;
     }
--- a/jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiUtils.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiUtils.c	Tue Sep 25 11:48:00 2012 -0700
@@ -42,6 +42,11 @@
 //#define USE_ERROR
 //#define USE_TRACE
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #if (USE_PLATFORM_MIDI_IN == TRUE) || (USE_PLATFORM_MIDI_OUT == TRUE)
 
 #include "PLATFORM_API_MacOSX_MidiUtils.h"
@@ -317,7 +322,7 @@
                             packedMsg = pendingMessageStatus | pendingData[0] << 8;
                         } else {
                             fprintf(stderr, "%s: %d->internal error: pendingMessageStatus=0x%X, pendingDataLength=%d\n",
-                                    __FILE__, __LINE__, pendingMessageStatus, pendingDataLength);
+                                    THIS_FILE, __LINE__, pendingMessageStatus, pendingDataLength);
                             byteIsInvalid = TRUE;
                         }
                         pendingDataLength = 0;
--- a/jdk/src/macosx/native/sun/awt/AWTView.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTView.h	Tue Sep 25 11:48:00 2012 -0700
@@ -33,8 +33,8 @@
 @private
     jobject m_cPlatformView;
 
-    // Handler for the tracking rect needed for Enter/Exit events management.
-    NSTrackingRectTag rolloverTrackingRectTag;
+    // Handler for the tracking area needed for Enter/Exit events management.
+    NSTrackingArea* rolloverTrackingArea;
 
     // TODO: NSMenu *contextualMenu;
 
@@ -61,7 +61,7 @@
 
 - (id) initWithRect:(NSRect) rect platformView:(jobject)cPlatformView windowLayer:(CALayer*)windowLayer;
 - (void) deliverJavaMouseEvent: (NSEvent *) event;
-- (void) resetTrackingRect;
+- (void) resetTrackingArea;
 - (void) deliverJavaKeyEventHelper: (NSEvent *) event;
 - (jobject) awtComponent:(JNIEnv *)env;
 
--- a/jdk/src/macosx/native/sun/awt/AWTView.m	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTView.m	Tue Sep 25 11:48:00 2012 -0700
@@ -82,6 +82,7 @@
     fPAHNeedsToSelect = NO;
 
     mouseIsOver = NO;
+    [self resetTrackingArea];
 
     if (windowLayer != nil) {
         self.cglLayer = windowLayer;
@@ -146,7 +147,7 @@
         [[self window] makeFirstResponder: self];
     }];
     if ([self window] != NULL) {
-        [self resetTrackingRect];
+        [self resetTrackingArea];
     }
 }
 
@@ -368,30 +369,31 @@
     JNFCallVoidMethod(env, m_cPlatformView, jm_deliverMouseEvent, jEvent);
 }
 
-
-- (void) clearTrackingRect {
-    if (rolloverTrackingRectTag > 0) {
-        [self removeTrackingRect:rolloverTrackingRectTag];
-        rolloverTrackingRectTag = 0;
+- (void) resetTrackingArea {
+    if (rolloverTrackingArea != nil) {
+        [self removeTrackingArea:rolloverTrackingArea];
+        [rolloverTrackingArea release];
     }
-}
+
+    int options = (NSTrackingActiveInActiveApp | NSTrackingMouseEnteredAndExited |
+                   NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag);
 
-- (void) resetTrackingRect {
-    [self clearTrackingRect];
-    rolloverTrackingRectTag = [self addTrackingRect:[self visibleRect]
-                                              owner:self
-                                           userData:NULL
-                                       assumeInside:NO];
+    rolloverTrackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect]
+                                                        options: options
+                                                          owner:self
+                                                       userInfo:nil
+                            ];
+    [self addTrackingArea:rolloverTrackingArea];
 }
 
 - (void)updateTrackingAreas {
     [super updateTrackingAreas];
-    [self resetTrackingRect];
+    [self resetTrackingArea];
 }
 
 - (void) resetCursorRects {
     [super resetCursorRects];
-    [self resetTrackingRect];
+    [self resetTrackingArea];
 }
 
 -(void) deliverJavaKeyEventHelper: (NSEvent *) event {
@@ -402,7 +404,7 @@
     }
     [sLastKeyEvent release];
     sLastKeyEvent = [event retain];
-	
+
     [AWTToolkit eventCountPlusPlus];
     JNIEnv *env = [ThreadUtilities getJNIEnv];
 
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m	Tue Sep 25 11:48:00 2012 -0700
@@ -238,10 +238,12 @@
     return self;
 }
 
-// checks that this window is under the mouse cursor and this point is not overlapped by others windows
-- (BOOL) isTopmostWindowUnderMouse {
++ (BOOL) isAWTWindow:(NSWindow *)window {
+    return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
+}
 
-    int currentWinID = [self.nsWindow windowNumber];
+// returns id for the topmost window under mouse
++ (NSInteger) getTopmostWindowUnderMouseID {
 
     NSRect screenRect = [[NSScreen mainScreen] frame];
     NSPoint nsMouseLocation = [NSEvent mouseLocation];
@@ -249,53 +251,77 @@
 
     NSMutableArray *windows = (NSMutableArray *)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
 
-
     for (NSDictionary *window in windows) {
-        int layer = [[window objectForKey:(id)kCGWindowLayer] intValue];
+        NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue];
         if (layer == 0) {
-            int winID = [[window objectForKey:(id)kCGWindowNumber] intValue];
             CGRect rect;
             CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
             if (CGRectContainsPoint(rect, cgMouseLocation)) {
-                return currentWinID == winID;
-            } else if (currentWinID == winID) {
-                return NO;
+                return [[window objectForKey:(id)kCGWindowNumber] integerValue];
             }
         }
     }
-    return NO;
+    return -1;
+}
+
+// checks that this window is under the mouse cursor and this point is not overlapped by others windows
+- (BOOL) isTopmostWindowUnderMouse {
+    return [self.nsWindow windowNumber] == [AWTWindow getTopmostWindowUnderMouseID];
 }
 
-- (void) synthesizeMouseEnteredExitedEvents {
++ (AWTWindow *) getTopmostWindowUnderMouse {
+    NSEnumerator *windowEnumerator = [[NSApp windows] objectEnumerator];
+    NSWindow *window;
 
-    int eventType = 0;
-    BOOL isUnderMouse = [self isTopmostWindowUnderMouse];
-    BOOL mouseIsOver = [[self.nsWindow contentView] mouseIsOver];
+    NSInteger topmostWindowUnderMouseID = [AWTWindow getTopmostWindowUnderMouseID];
 
-    if (isUnderMouse && !mouseIsOver) {
-        eventType = NSMouseEntered;
-    } else if (!isUnderMouse && mouseIsOver) {
-        eventType = NSMouseExited;
-    } else {
-        return;
+    while ((window = [windowEnumerator nextObject]) != nil) {
+        if ([window windowNumber] == topmostWindowUnderMouseID) {
+            BOOL isAWTWindow = [AWTWindow isAWTWindow: window];
+            return isAWTWindow ? (AWTWindow *) [window delegate] : nil;
+        }
     }
+    return nil;
+}
+
++ (void) synthesizeMouseEnteredExitedEvents:(NSWindow*)window withType:(NSEventType)eventType {
 
     NSPoint screenLocation = [NSEvent mouseLocation];
-    NSPoint windowLocation = [self.nsWindow convertScreenToBase: screenLocation];
+    NSPoint windowLocation = [window convertScreenToBase: screenLocation];
     int modifierFlags = (eventType == NSMouseEntered) ? NSMouseEnteredMask : NSMouseExitedMask;
 
     NSEvent *mouseEvent = [NSEvent enterExitEventWithType: eventType
-                                                  location: windowLocation
-                                             modifierFlags: modifierFlags
-                                                 timestamp: 0
-                                              windowNumber: [self.nsWindow windowNumber]
-                                                   context: nil
-                                               eventNumber: 0
-                                            trackingNumber: 0
-                                                  userData: nil
-                            ];
+                                                 location: windowLocation
+                                            modifierFlags: modifierFlags
+                                                timestamp: 0
+                                             windowNumber: [window windowNumber]
+                                                  context: nil
+                                              eventNumber: 0
+                                           trackingNumber: 0
+                                                 userData: nil
+                           ];
+
+    [[window contentView] deliverJavaMouseEvent: mouseEvent];
+}
+
++ (void) synthesizeMouseEnteredExitedEventsForAllWindows {
 
-    [[self.nsWindow contentView] deliverJavaMouseEvent: mouseEvent];
+    NSInteger topmostWindowUnderMouseID = [AWTWindow getTopmostWindowUnderMouseID];
+    NSArray *windows = [NSApp windows];
+    NSWindow *window;
+
+    NSEnumerator *windowEnumerator = [windows objectEnumerator];
+    while ((window = [windowEnumerator nextObject]) != nil) {
+        if ([AWTWindow isAWTWindow: window]) {
+            BOOL isUnderMouse = ([window windowNumber] == topmostWindowUnderMouseID);
+            BOOL mouseIsOver = [[window contentView] mouseIsOver];
+            if (isUnderMouse && !mouseIsOver) {
+                [AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseEntered];
+            } else if (!isUnderMouse && mouseIsOver) {
+                [AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseExited];
+            }
+        }
+    }
 }
 
 - (void) dealloc {
@@ -825,7 +851,7 @@
         // (this will also re-enable screen updates, which were disabled above)
         // TODO: send PaintEvent
 
-        [window synthesizeMouseEnteredExitedEvents];
+        [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
     }];
 
 JNF_COCOA_EXIT(env);
@@ -1040,22 +1066,42 @@
 
 /*
  * Class:     sun_lwawt_macosx_CPlatformWindow
+ * Method:    nativeGetTopmostPlatformWindowUnderMouse
+ * Signature: (J)V
+ */
+JNIEXPORT jobject
+JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnderMouse
+(JNIEnv *env, jclass clazz)
+{
+    jobject topmostWindowUnderMouse = nil;
+
+    JNF_COCOA_ENTER(env);
+    AWT_ASSERT_APPKIT_THREAD;
+
+    AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse];
+    if (awtWindow != nil) {
+        topmostWindowUnderMouse = [awtWindow.javaPlatformWindow jObject];
+    }
+
+    JNF_COCOA_EXIT(env);
+
+    return topmostWindowUnderMouse;
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CPlatformWindow
  * Method:    nativeSynthesizeMouseEnteredExitedEvents
  * Signature: (J)V
  */
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents
-(JNIEnv *env, jclass clazz, jlong windowPtr)
+(JNIEnv *env, jclass clazz)
 {
     JNF_COCOA_ENTER(env);
     AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    NSWindow *nsWindow = OBJC(windowPtr);
     [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
         AWT_ASSERT_APPKIT_THREAD;
-
-        AWTWindow *window = (AWTWindow*)[nsWindow delegate];
-
-        [window synthesizeMouseEnteredExitedEvents];
+        [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
     }];
 
     JNF_COCOA_EXIT(env);
--- a/jdk/src/macosx/native/sun/awt/CSystemColors.m	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CSystemColors.m	Tue Sep 25 11:48:00 2012 -0700
@@ -33,6 +33,11 @@
 
 #import "ThreadUtilities.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 NSColor **sColors = nil;
 NSColor **appleColors = nil;
 
@@ -130,7 +135,7 @@
         result = (useAppleColor ? appleColors : sColors)[colorIndex];
     }
     else {
-        NSLog(@"%s: %s %sColor: %ld not found, returning black.", __FILE__, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
+        NSLog(@"%s: %s %sColor: %ld not found, returning black.", THIS_FILE, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
         result = [NSColor blackColor];
     }
 
--- a/jdk/src/macosx/native/sun/awt/CTextPipe.m	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m	Tue Sep 25 11:48:00 2012 -0700
@@ -36,6 +36,10 @@
 #import "QuartzSurfaceData.h"
 #include "AWTStrike.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
 
 static const CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
 
@@ -488,7 +492,7 @@
         if (glyphs == NULL || advances == NULL)
         {
             (*env)->DeleteLocalRef(env, glyphsArray);
-            [NSException raise:NSMallocException format:@"%s-%s:%d", __FILE__, __FUNCTION__, __LINE__];
+            [NSException raise:NSMallocException format:@"%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__];
             return;
         }
 
--- a/jdk/src/macosx/native/sun/awt/ImageSurfaceData.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/ImageSurfaceData.h	Tue Sep 25 11:48:00 2012 -0700
@@ -41,7 +41,7 @@
 // If there is an image present, this is a no-op
 void makeSureImageIsCreated(ImageSDOps* isdo);
 
-struct _ContextInfo
+typedef struct _ContextInfo
 {
     BOOL                useWindowContextReference;
     BOOL                canUseJavaPixelsAsContext;
@@ -50,10 +50,9 @@
     size_t                bytesPerRow;
     CGImageAlphaInfo    alphaInfo;
     CGColorSpaceRef        colorSpace;
-}
-typedef ContextInfo;
+} ContextInfo;
 
-struct _ImageInfo
+typedef struct _ImageInfo
 {
     size_t                bitsPerComponent;
     size_t                bitsPerPixel;
@@ -61,8 +60,7 @@
     size_t                bytesPerRow;
     CGImageAlphaInfo    alphaInfo;
     CGColorSpaceRef        colorSpace;
-}
-typedef ImageInfo;
+} ImageInfo;
 
 struct _ImageSDOps
 {
--- a/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m	Tue Sep 25 11:48:00 2012 -0700
@@ -53,10 +53,6 @@
 // for vImage framework headers
 #include <Accelerate/Accelerate.h>
 
-
-// private Quartz routines needed here
-CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
-
 static ContextInfo sDefaultContextInfo[sun_java2d_OSXOffScreenSurfaceData_TYPE_3BYTE_RGB+1] =
 {
     {YES,    YES,    8,        4,        0,        kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,    NULL},    // TYPE_CUSTOM            // special case
@@ -942,7 +938,6 @@
     // intitalize the context to match the Java coordinate system
 
     // BG, since the context is created above, we can just concat
-    //CGContextSetCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, -1, 0, isdo->height));
     CGContextConcatCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, -1, 0, isdo->height));
 
     CGContextSaveGState(qsdo->cgRef); // this will make sure we don't go pass device context settings
@@ -1114,7 +1109,10 @@
                 if (qsdo->cgRef != NULL)
                 {
                     CGContextSaveGState(qsdo->cgRef);
-                    CGContextSetCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, 1, 0, 0));
+                    CGAffineTransform currCTM = CGContextGetCTM(qsdo->cgRef);
+                    CGAffineTransform inverse = CGAffineTransformInvert(currCTM);
+                    CGContextConcatCTM(qsdo->cgRef, inverse);
+                    CGContextConcatCTM(qsdo->cgRef, CGAffineTransformMake(1, 0, 0, 1, 0, 0));
                     CGContextSetBlendMode(qsdo->cgRef, kCGBlendModeCopy);
                     CGContextSetAlpha(qsdo->cgRef, 1.0f);
                     CGContextDrawImage(qsdo->cgRef, CGRectMake(0, 0, width, height), javaImg);
--- a/jdk/src/macosx/native/sun/awt/QuartzRenderer.m	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/QuartzRenderer.m	Tue Sep 25 11:48:00 2012 -0700
@@ -50,9 +50,6 @@
 // same value as defined in Sun's own code
 #define XOR_ALPHA_CUTOFF 128
 
-// private Quartz routines needed here
-CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
-
 
 static CGFloat gRoundRectCtrlpts[10][12] =
 {
@@ -536,7 +533,7 @@
 
     makeSureImageIsCreated(isdo);
 
-    CGAffineTransform ctm = CGContextGetCTM(cgRef);
+    CGContextSaveGState(cgRef);
     CGContextConcatCTM(cgRef, CGAffineTransformMake(a, b, c, d, tx, ty));
     jint alphaInfo = isdo->contextInfo.alphaInfo & kCGBitmapAlphaInfoMask;
 
@@ -551,7 +548,7 @@
         CGImageRelease(subImg);
     }
 
-    CGContextSetCTM(cgRef, ctm);
+    CGContextRestoreGState(cgRef);
     UnlockImage(env, isdo);
 }
 
--- a/jdk/src/macosx/native/sun/awt/QuartzSurfaceData.m	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/QuartzSurfaceData.m	Tue Sep 25 11:48:00 2012 -0700
@@ -40,9 +40,6 @@
 #import <AppKit/AppKit.h>
 #import "ThreadUtilities.h"
 
-// private Quartz routines needed here
-CG_EXTERN void CGContextSetCTM(CGContextRef ref, CGAffineTransform tx);
-
 //#define DEBUG
 #if defined DEBUG
     #define PRINT(msg) {fprintf(stderr, "%s\n", msg);}
@@ -50,9 +47,6 @@
     #define PRINT(msg) {}
 #endif
 
-// from CGAffineTransformPrivate.h
-extern CGPoint CGPointApplyInverseAffineTransform(CGPoint point, CGAffineTransform t);
-
 #define kOffset (0.5f)
 
 BOOL gAdjustForJavaDrawing;
@@ -608,7 +602,8 @@
                 // We need to flip both y coefficeints to flip the offset point into the java coordinate system.
                 ctm.b = -ctm.b; ctm.d = -ctm.d; ctm.tx = 0.0f; ctm.ty = 0.0f;
                 CGPoint offsets = {kOffset, kOffset};
-                offsets = CGPointApplyInverseAffineTransform(offsets, ctm);
+                CGAffineTransform inverse = CGAffineTransformInvert(ctm);
+                offsets = CGPointApplyAffineTransform(offsets, inverse);
                 qsdo->graphicsStateInfo.offsetX = offsets.x;
                 qsdo->graphicsStateInfo.offsetY = offsets.y;
             }
--- a/jdk/src/macosx/native/sun/font/AWTStrike.m	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/macosx/native/sun/font/AWTStrike.m	Tue Sep 25 11:48:00 2012 -0700
@@ -33,6 +33,11 @@
 #import "CoreTextSupport.h"
 //#import "jni_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 @implementation AWTStrike
 
 static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
@@ -102,7 +107,7 @@
 #define AWT_FONT_CLEANUP_FINISH                                         \
     if (_fontThrowJavaException == YES) {                               \
         char s[512];                                                    \
-        sprintf(s, "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__);       \
+        sprintf(s, "%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__);       \
         [JNFException raise:env as:kRuntimeException reason:s];         \
     }
 
--- a/jdk/src/share/back/error_messages.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/back/error_messages.h	Tue Sep 25 11:48:00 2012 -0700
@@ -42,31 +42,36 @@
 const char * eventText(int);
 const char * jdwpErrorText(jdwpError);
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define EXIT_ERROR(error,msg) \
         { \
                 print_message(stderr, "JDWP exit error ", "\n", \
                         "%s(%d): %s [%s:%d]", \
                         jvmtiErrorText((jvmtiError)error), error, (msg==NULL?"":msg), \
-                        __FILE__, __LINE__); \
+                        THIS_FILE, __LINE__); \
                 debugInit_exit((jvmtiError)error, msg); \
         }
 
 #define JDI_ASSERT(expression)  \
 do {                            \
     if (gdata && gdata->assertOn && !(expression)) {            \
-        jdiAssertionFailed(__FILE__, __LINE__, #expression); \
+        jdiAssertionFailed(THIS_FILE, __LINE__, #expression); \
     }                                           \
 } while (0)
 
 #define JDI_ASSERT_MSG(expression, msg)  \
 do {                            \
     if (gdata && gdata->assertOn && !(expression)) {            \
-        jdiAssertionFailed(__FILE__, __LINE__, msg); \
+        jdiAssertionFailed(THIS_FILE, __LINE__, msg); \
     }                                           \
 } while (0)
 
 #define JDI_ASSERT_FAILED(msg)  \
-   jdiAssertionFailed(__FILE__, __LINE__, msg)
+   jdiAssertionFailed(THIS_FILE, __LINE__, msg)
 
 void do_pause(void);
 
--- a/jdk/src/share/back/log_messages.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/back/log_messages.h	Tue Sep 25 11:48:00 2012 -0700
@@ -33,11 +33,15 @@
 
 #define LOG_NULL ((void)0)
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #ifdef JDWP_LOGGING
 
-
     #define _LOG(flavor,args) \
-                (log_message_begin(flavor,__FILE__,__LINE__), \
+                (log_message_begin(flavor,THIS_FILE,__LINE__), \
                  log_message_end args)
 
     #define LOG_TEST(flag)  (gdata->log_flags & (flag))
--- a/jdk/src/share/bin/jli_util.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/bin/jli_util.h	Tue Sep 25 11:48:00 2012 -0700
@@ -68,12 +68,23 @@
 #define JLI_StrNCaseCmp(p1, p2, p3)     strnicmp((p1), (p2), (p3))
 #define JLI_Snprintf                    _snprintf
 void JLI_CmdToArgs(char *cmdline);
-#else
+#define JLI_Lseek                       _lseeki64
+#else  /* NIXES */
 #include <unistd.h>
 #include <strings.h>
 #define JLI_StrCaseCmp(p1, p2)          strcasecmp((p1), (p2))
 #define JLI_StrNCaseCmp(p1, p2, p3)     strncasecmp((p1), (p2), (p3))
 #define JLI_Snprintf                    snprintf
+#ifdef __solaris__
+#define JLI_Lseek                       llseek
+#endif
+#ifdef __linux__
+#define _LARGFILE64_SOURCE
+#define JLI_Lseek                       lseek64
+#endif
+#ifdef MACOSX
+#define JLI_Lseek                       lseek
+#endif
 #endif /* _WIN32 */
 
 /*
--- a/jdk/src/share/bin/manifest_info.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/bin/manifest_info.h	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,8 @@
 #define CENSIG 0x02014b50L          /* "PK\001\002" */
 #define ENDSIG 0x06054b50L          /* "PK\005\006" */
 
+#define ZIP64_ENDSIG 0x06064b50L    /* "PK\006\006" */
+#define ZIP64_LOCSIG 0x07064b50L    /* "PK\006\007" */
 /*
  * Header sizes including signatures
  */
@@ -45,12 +47,21 @@
 #define CENHDR 46
 #define ENDHDR 22
 
+#define ZIP64_ENDHDR 56       // ZIP64 end header size
+#define ZIP64_LOCHDR 20       // ZIP64 end loc header size
+#define ZIP64_EXTHDR 24       // EXT header size
+#define ZIP64_EXTID   1       // Extra field Zip64 header ID
+
+#define ZIP64_MAGICVAL 0xffffffffLL
+#define ZIP64_MAGICCOUNT 0xffff
+
 /*
  * Header field access macros
  */
 #define CH(b, n) (((unsigned char *)(b))[n])
 #define SH(b, n) (CH(b, n) | (CH(b, n+1) << 8))
-#define LG(b, n) (SH(b, n) | (SH(b, n+2) << 16))
+#define LG(b, n) ((SH(b, n) | (SH(b, n+2) << 16)) &0xffffffffUL)
+#define LL(b, n) (((jlong)LG(b, n)) | (((jlong)LG(b, n+4)) << 32))
 #define GETSIG(b) LG(b, 0)
 
 /*
@@ -102,6 +113,26 @@
 #define ENDCOM(b) SH(b, 20)         /* size of zip file comment */
 
 /*
+ * Macros for getting Zip64 end of central directory header fields
+ */
+#define ZIP64_ENDLEN(b) LL(b, 4)      /* size of zip64 end of central dir */
+#define ZIP64_ENDVEM(b) SH(b, 12)     /* version made by */
+#define ZIP64_ENDVER(b) SH(b, 14)     /* version needed to extract */
+#define ZIP64_ENDNMD(b) LG(b, 16)     /* number of this disk */
+#define ZIP64_ENDDSK(b) LG(b, 20)     /* disk number of start */
+#define ZIP64_ENDTOD(b) LL(b, 24)     /* total number of entries on this disk */
+#define ZIP64_ENDTOT(b) LL(b, 32)     /* total number of entries */
+#define ZIP64_ENDSIZ(b) LL(b, 40)     /* central directory size in bytes */
+#define ZIP64_ENDOFF(b) LL(b, 48)     /* offset of first CEN header */
+
+/*
+ * Macros for getting Zip64 end of central directory locator fields
+ */
+#define ZIP64_LOCDSK(b) LG(b, 4)      /* disk number start */
+#define ZIP64_LOCOFF(b) LL(b, 8)      /* offset of zip64 end */
+#define ZIP64_LOCTOT(b) LG(b, 16)     /* total number of disks */
+
+/*
  * A comment of maximum length of 64kb can follow the END record. This
  * is the furthest the END record can be from the end of the file.
  */
@@ -119,7 +150,7 @@
 typedef struct zentry { /* Zip file entry */
     size_t      isize;  /* size of inflated data */
     size_t      csize;  /* size of compressed data (zero if uncompressed) */
-    off_t       offset; /* position of compressed data */
+    jlong       offset; /* position of compressed data */
     int         how;    /* compression method (if any) */
 } zentry;
 
--- a/jdk/src/share/bin/parse_manifest.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/bin/parse_manifest.c	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,7 @@
 
     if (entry->csize == (size_t) -1 || entry->isize == (size_t) -1 )
         return (NULL);
-    if (lseek(fd, entry->offset, SEEK_SET) < (off_t)0)
+    if (JLI_Lseek(fd, entry->offset, SEEK_SET) < (jlong)0)
         return (NULL);
     if ((in = malloc(entry->csize + 1)) == NULL)
         return (NULL);
@@ -110,6 +110,38 @@
         return (NULL);
 }
 
+static jboolean zip64_present = JNI_FALSE;
+
+/*
+ * Checks to see if we have ZIP64 archive, and save
+ * the check for later use
+ */
+static int
+haveZIP64(Byte *p) {
+    jlong cenlen, cenoff, centot;
+    cenlen = ENDSIZ(p);
+    cenoff = ENDOFF(p);
+    centot = ENDTOT(p);
+    zip64_present = (cenlen == ZIP64_MAGICVAL ||
+                     cenoff == ZIP64_MAGICVAL ||
+                     centot == ZIP64_MAGICCOUNT);
+    return zip64_present;
+}
+
+static jlong
+find_end64(int fd, Byte *ep, jlong pos)
+{
+    jlong end64pos;
+    jlong bytes;
+    if ((end64pos = JLI_Lseek(fd, pos - ZIP64_LOCHDR, SEEK_SET)) < (jlong)0)
+        return -1;
+    if ((bytes = read(fd, ep, ZIP64_LOCHDR)) < 0)
+        return -1;
+    if (GETSIG(ep) == ZIP64_LOCSIG)
+       return end64pos;
+    return -1;
+}
+
 /*
  * A very little used routine to handle the case that zip file has
  * a comment at the end. Believe it or not, the only way to find the
@@ -122,12 +154,12 @@
  * Returns the offset of the END record in the file on success,
  * -1 on failure.
  */
-static off_t
+static jlong
 find_end(int fd, Byte *eb)
 {
-    off_t   len;
-    off_t   pos;
-    off_t   flen;
+    jlong   len;
+    jlong   pos;
+    jlong   flen;
     int     bytes;
     Byte    *cp;
     Byte    *endpos;
@@ -136,14 +168,16 @@
     /*
      * 99.44% (or more) of the time, there will be no comment at the
      * end of the zip file.  Try reading just enough to read the END
-     * record from the end of the file.
+     * record from the end of the file, at this time we should also
+     * check to see if we have a ZIP64 archive.
      */
-    if ((pos = lseek(fd, -ENDHDR, SEEK_END)) < (off_t)0)
+    if ((pos = JLI_Lseek(fd, -ENDHDR, SEEK_END)) < (jlong)0)
         return (-1);
     if ((bytes = read(fd, eb, ENDHDR)) < 0)
         return (-1);
-    if (GETSIG(eb) == ENDSIG)
-        return (pos);
+    if (GETSIG(eb) == ENDSIG) {
+        return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
+    }
 
     /*
      * Shucky-Darn,... There is a comment at the end of the zip file.
@@ -151,10 +185,10 @@
      * Allocate and fill a buffer with enough of the zip file
      * to meet the specification for a maximal comment length.
      */
-    if ((flen = lseek(fd, 0, SEEK_END)) < (off_t)0)
+    if ((flen = JLI_Lseek(fd, 0, SEEK_END)) < (jlong)0)
         return (-1);
     len = (flen < END_MAXLEN) ? flen : END_MAXLEN;
-    if (lseek(fd, -len, SEEK_END) < (off_t)0)
+    if (JLI_Lseek(fd, -len, SEEK_END) < (jlong)0)
         return (-1);
     if ((buffer = malloc(END_MAXLEN)) == NULL)
         return (-1);
@@ -175,12 +209,92 @@
           (cp + ENDHDR + ENDCOM(cp) == endpos)) {
             (void) memcpy(eb, cp, ENDHDR);
             free(buffer);
-            return (flen - (endpos - cp));
+            pos = flen - (endpos - cp);
+            return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
         }
     free(buffer);
     return (-1);
 }
 
+#define BUFSIZE (3 * 65536 + CENHDR + SIGSIZ)
+#define MINREAD 1024
+
+/*
+ * Computes and positions at the start of the CEN header, ie. the central
+ * directory, this will also return the offset if there is a zip file comment
+ * at the end of the archive, for most cases this would be 0.
+ */
+static jlong
+compute_cen(int fd, Byte *bp)
+{
+    int bytes;
+    Byte *p;
+    jlong base_offset;
+    jlong offset;
+    char buffer[MINREAD];
+    p = buffer;
+    /*
+     * Read the END Header, which is the starting point for ZIP files.
+     * (Clearly designed to make writing a zip file easier than reading
+     * one. Now isn't that precious...)
+     */
+    if ((base_offset = find_end(fd, bp)) == -1) {
+        return (-1);
+    }
+    p = bp;
+    /*
+     * There is a historical, but undocumented, ability to allow for
+     * additional "stuff" to be prepended to the zip/jar file. It seems
+     * that this has been used to prepend an actual java launcher
+     * executable to the jar on Windows.  Although this is just another
+     * form of statically linking a small piece of the JVM to the
+     * application, we choose to continue to support it.  Note that no
+     * guarantees have been made (or should be made) to the customer that
+     * this will continue to work.
+     *
+     * Therefore, calculate the base offset of the zip file (within the
+     * expanded file) by assuming that the central directory is followed
+     * immediately by the end record.
+     */
+    if (zip64_present) {
+        if ((offset = ZIP64_LOCOFF(p)) < (jlong)0) {
+            return -1;
+        }
+        if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong) 0) {
+            return (-1);
+        }
+        if ((bytes = read(fd, buffer, MINREAD)) < 0) {
+            return (-1);
+        }
+        if (GETSIG(buffer) != ZIP64_ENDSIG) {
+            return -1;
+        }
+        if ((offset = ZIP64_ENDOFF(buffer)) < (jlong)0) {
+            return -1;
+        }
+        if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong)0) {
+            return (-1);
+        }
+        p = buffer;
+        base_offset = base_offset - ZIP64_ENDSIZ(p) - ZIP64_ENDOFF(p) - ZIP64_ENDHDR;
+    } else {
+        base_offset = base_offset - ENDSIZ(p) - ENDOFF(p);
+        /*
+         * The END Header indicates the start of the Central Directory
+         * Headers. Remember that the desired Central Directory Header (CEN)
+         * will almost always be the second one and the first one is a small
+         * directory entry ("META-INF/"). Keep the code optimized for
+         * that case.
+         *
+         * Seek to the beginning of the Central Directory.
+         */
+        if (JLI_Lseek(fd, base_offset + ENDOFF(p), SEEK_SET) < (jlong) 0) {
+            return (-1);
+        }
+    }
+    return base_offset;
+}
+
 /*
  * Locate the manifest file with the zip/jar file.
  *
@@ -208,9 +322,6 @@
  * a typical jar file (META-INF and META-INF/MANIFEST.MF). Keep this factoid
  * in mind when optimizing this code.
  */
-#define BUFSIZE (3 * 65536 + CENHDR + SIGSIZ)
-#define MINREAD 1024
-
 static int
 find_file(int fd, zentry *entry, const char *file_name)
 {
@@ -218,7 +329,7 @@
     int     res;
     int     entry_size;
     int     read_size;
-    int     base_offset;
+    jlong   base_offset;
     Byte    *p;
     Byte    *bp;
     Byte    *buffer;
@@ -228,54 +339,18 @@
         return(-1);
     }
 
-    p = buffer;
     bp = buffer;
-
-    /*
-     * Read the END Header, which is the starting point for ZIP files.
-     * (Clearly designed to make writing a zip file easier than reading
-     * one. Now isn't that precious...)
-     */
-    if ((base_offset = find_end(fd, bp)) == -1) {
+    base_offset = compute_cen(fd, bp);
+    if (base_offset == -1) {
         free(buffer);
-        return (-1);
+        return -1;
     }
 
-    /*
-     * There is a historical, but undocumented, ability to allow for
-     * additional "stuff" to be prepended to the zip/jar file. It seems
-     * that this has been used to prepend an actual java launcher
-     * executable to the jar on Windows.  Although this is just another
-     * form of statically linking a small piece of the JVM to the
-     * application, we choose to continue to support it.  Note that no
-     * guarantees have been made (or should be made) to the customer that
-     * this will continue to work.
-     *
-     * Therefore, calculate the base offset of the zip file (within the
-     * expanded file) by assuming that the central directory is followed
-     * immediately by the end record.
-     */
-    base_offset = base_offset - ENDSIZ(p) - ENDOFF(p);
-
-    /*
-     * The END Header indicates the start of the Central Directory
-     * Headers. Remember that the desired Central Directory Header (CEN)
-     * will almost always be the second one and the first one is a small
-     * directory entry ("META-INF/"). Keep the code optimized for
-     * that case.
-     *
-     * Begin by seeking to the beginning of the Central Directory and
-     * reading in the first buffer full of bits.
-     */
-    if (lseek(fd, base_offset + ENDOFF(p), SEEK_SET) < (off_t)0) {
-        free(buffer);
-        return (-1);
-    }
     if ((bytes = read(fd, bp, MINREAD)) < 0) {
         free(buffer);
         return (-1);
     }
-
+    p = bp;
     /*
      * Loop through the Central Directory Headers. Note that a valid zip/jar
      * must have an ENDHDR (with ENDSIG) after the Central Directory.
@@ -319,7 +394,7 @@
          */
         if ((size_t)CENNAM(p) == JLI_StrLen(file_name) &&
           memcmp((p + CENHDR), file_name, JLI_StrLen(file_name)) == 0) {
-            if (lseek(fd, base_offset + CENOFF(p), SEEK_SET) < (off_t)0) {
+            if (JLI_Lseek(fd, base_offset + CENOFF(p), SEEK_SET) < (jlong)0) {
                 free(buffer);
                 return (-1);
             }
@@ -487,6 +562,9 @@
     char    *splashscreen_name = NULL;
 
     if ((fd = open(jarfile, O_RDONLY
+#ifdef O_LARGEFILE
+        | O_LARGEFILE /* large file mode on solaris */
+#endif
 #ifdef O_BINARY
         | O_BINARY /* use binary mode on windows */
 #endif
--- a/jdk/src/share/classes/com/sun/crypto/provider/AESCipher.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/com/sun/crypto/provider/AESCipher.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,18 +47,122 @@
  * @see OutputFeedback
  */
 
-public final class AESCipher extends CipherSpi {
+abstract class AESCipher extends CipherSpi {
+    public static final class General extends AESCipher {
+        public General() {
+            super(-1);
+        }
+    }
+    abstract static class OidImpl extends AESCipher {
+        protected OidImpl(int keySize, String mode, String padding) {
+            super(keySize);
+            try {
+                engineSetMode(mode);
+                engineSetPadding(padding);
+            } catch (GeneralSecurityException gse) {
+                // internal error; re-throw as provider exception
+                ProviderException pe =new ProviderException("Internal Error");
+                pe.initCause(gse);
+                throw pe;
+            }
+        }
+    }
+    public static final class AES128_ECB_NoPadding extends OidImpl {
+        public AES128_ECB_NoPadding() {
+            super(16, "ECB", "NOPADDING");
+        }
+    }
+    public static final class AES192_ECB_NoPadding extends OidImpl {
+        public AES192_ECB_NoPadding() {
+            super(24, "ECB", "NOPADDING");
+        }
+    }
+    public static final class AES256_ECB_NoPadding extends OidImpl {
+        public AES256_ECB_NoPadding() {
+            super(32, "ECB", "NOPADDING");
+        }
+    }
+    public static final class AES128_CBC_NoPadding extends OidImpl {
+        public AES128_CBC_NoPadding() {
+            super(16, "CBC", "NOPADDING");
+        }
+    }
+    public static final class AES192_CBC_NoPadding extends OidImpl {
+        public AES192_CBC_NoPadding() {
+            super(24, "CBC", "NOPADDING");
+        }
+    }
+    public static final class AES256_CBC_NoPadding extends OidImpl {
+        public AES256_CBC_NoPadding() {
+            super(32, "CBC", "NOPADDING");
+        }
+    }
+    public static final class AES128_OFB_NoPadding extends OidImpl {
+        public AES128_OFB_NoPadding() {
+            super(16, "OFB", "NOPADDING");
+        }
+    }
+    public static final class AES192_OFB_NoPadding extends OidImpl {
+        public AES192_OFB_NoPadding() {
+            super(24, "OFB", "NOPADDING");
+        }
+    }
+    public static final class AES256_OFB_NoPadding extends OidImpl {
+        public AES256_OFB_NoPadding() {
+            super(32, "OFB", "NOPADDING");
+        }
+    }
+    public static final class AES128_CFB_NoPadding extends OidImpl {
+        public AES128_CFB_NoPadding() {
+            super(16, "CFB", "NOPADDING");
+        }
+    }
+    public static final class AES192_CFB_NoPadding extends OidImpl {
+        public AES192_CFB_NoPadding() {
+            super(24, "CFB", "NOPADDING");
+        }
+    }
+    public static final class AES256_CFB_NoPadding extends OidImpl {
+        public AES256_CFB_NoPadding() {
+            super(32, "CFB", "NOPADDING");
+        }
+    }
+
+    // utility method used by AESCipher and AESWrapCipher
+    static final void checkKeySize(Key key, int fixedKeySize)
+        throws InvalidKeyException {
+        if (fixedKeySize != -1) {
+            if (key == null) {
+                throw new InvalidKeyException("The key must not be null");
+            }
+            byte[] value = key.getEncoded();
+            if (value == null) {
+                throw new InvalidKeyException("Key encoding must not be null");
+            } else if (value.length != fixedKeySize) {
+                throw new InvalidKeyException("The key must be " +
+                    fixedKeySize*8 + " bits");
+            }
+        }
+    }
+
     /*
      * internal CipherCore object which does the real work.
      */
     private CipherCore core = null;
 
+    /*
+     * needed to support AES oids which associates a fixed key size
+     * to the cipher object.
+     */
+    private final int fixedKeySize; // in bytes, -1 if no restriction
+
     /**
      * Creates an instance of AES cipher with default ECB mode and
      * PKCS5Padding.
      */
-    public AESCipher() {
+    protected AESCipher(int keySize) {
         core = new CipherCore(new AESCrypt(), AESConstants.AES_BLOCK_SIZE);
+        fixedKeySize = keySize;
     }
 
     /**
@@ -183,6 +287,7 @@
      */
     protected void engineInit(int opmode, Key key, SecureRandom random)
         throws InvalidKeyException {
+        checkKeySize(key, fixedKeySize);
         core.init(opmode, key, random);
     }
 
@@ -214,6 +319,7 @@
                               AlgorithmParameterSpec params,
                               SecureRandom random)
         throws InvalidKeyException, InvalidAlgorithmParameterException {
+        checkKeySize(key, fixedKeySize);
         core.init(opmode, key, params, random);
     }
 
@@ -221,6 +327,7 @@
                               AlgorithmParameters params,
                               SecureRandom random)
         throws InvalidKeyException, InvalidAlgorithmParameterException {
+        checkKeySize(key, fixedKeySize);
         core.init(opmode, key, params, random);
     }
 
--- a/jdk/src/share/classes/com/sun/crypto/provider/AESWrapCipher.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/com/sun/crypto/provider/AESWrapCipher.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,8 +43,27 @@
  *
  * @see AESCipher
  */
-public final class AESWrapCipher extends CipherSpi {
-
+abstract class AESWrapCipher extends CipherSpi {
+    public static final class General extends AESWrapCipher {
+        public General() {
+            super(-1);
+        }
+    }
+    public static final class AES128 extends AESWrapCipher {
+        public AES128() {
+            super(16);
+        }
+    }
+    public static final class AES192 extends AESWrapCipher {
+        public AES192() {
+            super(24);
+        }
+    }
+    public static final class AES256 extends AESWrapCipher {
+        public AES256() {
+            super(32);
+        }
+    }
     private static final byte[] IV = {
         (byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6,
         (byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6
@@ -62,12 +81,20 @@
      */
     private boolean decrypting = false;
 
+    /*
+     * needed to support AES oids which associates a fixed key size
+     * to the cipher object.
+     */
+    private final int fixedKeySize; // in bytes, -1 if no restriction
+
     /**
      * Creates an instance of AES KeyWrap cipher with default
      * mode, i.e. "ECB" and padding scheme, i.e. "NoPadding".
      */
-    public AESWrapCipher() {
+    public AESWrapCipher(int keySize) {
         cipher = new AESCrypt();
+        fixedKeySize = keySize;
+
     }
 
     /**
@@ -170,6 +197,7 @@
             throw new UnsupportedOperationException("This cipher can " +
                 "only be used for key wrapping and unwrapping");
         }
+        AESCipher.checkKeySize(key, fixedKeySize);
         cipher.init(decrypting, key.getAlgorithm(), key.getEncoded());
     }
 
--- a/jdk/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -80,10 +80,10 @@
      * @param random the source of randomness
      */
     public void initialize(int keysize, SecureRandom random) {
-        if ((keysize < 512) || (keysize > 1024) || (keysize % 64 != 0)) {
+        if ((keysize < 512) || (keysize > 2048) || (keysize % 64 != 0)) {
             throw new InvalidParameterException("Keysize must be multiple "
                                                 + "of 64, and can only range "
-                                                + "from 512 to 1024 "
+                                                + "from 512 to 2048 "
                                                 + "(inclusive)");
         }
         this.pSize = keysize;
@@ -115,11 +115,11 @@
 
         params = (DHParameterSpec)algParams;
         pSize = params.getP().bitLength();
-        if ((pSize < 512) || (pSize > 1024) ||
+        if ((pSize < 512) || (pSize > 2048) ||
             (pSize % 64 != 0)) {
             throw new InvalidAlgorithmParameterException
                 ("Prime size must be multiple of 64, and can only range "
-                 + "from 512 to 1024 (inclusive)");
+                 + "from 512 to 2048 (inclusive)");
         }
 
         // exponent size is optional, could be 0
@@ -156,10 +156,11 @@
         BigInteger g = params.getG();
 
         if (lSize <= 0) {
+            lSize = pSize >> 1;
             // use an exponent size of (pSize / 2) but at least 384 bits
-            lSize = Math.max(384, pSize >> 1);
-            // if lSize is larger than pSize, limit by pSize
-            lSize = Math.min(lSize, pSize);
+            if (lSize < 384) {
+                lSize = 384;
+            }
         }
 
         BigInteger x;
--- a/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,10 +67,10 @@
      * @param random the source of randomness
      */
     protected void engineInit(int keysize, SecureRandom random) {
-        if ((keysize < 512) || (keysize > 1024) || (keysize % 64 != 0)) {
+        if ((keysize < 512) || (keysize > 2048) || (keysize % 64 != 0)) {
             throw new InvalidParameterException("Keysize must be multiple "
                                                 + "of 64, and can only range "
-                                                + "from 512 to 1024 "
+                                                + "from 512 to 2048 "
                                                 + "(inclusive)");
         }
         this.primeSize = keysize;
@@ -99,10 +99,10 @@
             DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec;
 
             primeSize = dhParamSpec.getPrimeSize();
-            if ((primeSize<512) || (primeSize>1024) || (primeSize%64 != 0)) {
+            if ((primeSize<512) || (primeSize>2048) || (primeSize%64 != 0)) {
                 throw new InvalidAlgorithmParameterException
                     ("Modulus size must be multiple of 64, and can only range "
-                     + "from 512 to 1024 (inclusive)");
+                     + "from 512 to 2048 (inclusive)");
             }
 
             exponentSize = dhParamSpec.getExponentSize();
--- a/jdk/src/share/classes/com/sun/crypto/provider/SunJCE.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/com/sun/crypto/provider/SunJCE.java	Tue Sep 25 11:48:00 2012 -0700
@@ -167,17 +167,67 @@
                     put("Cipher.Blowfish SupportedPaddings", BLOCK_PADS);
                     put("Cipher.Blowfish SupportedKeyFormats", "RAW");
 
-                    put("Cipher.AES", "com.sun.crypto.provider.AESCipher");
+                    put("Cipher.AES", "com.sun.crypto.provider.AESCipher$General");
                     put("Alg.Alias.Cipher.Rijndael", "AES");
                     put("Cipher.AES SupportedModes", BLOCK_MODES128);
                     put("Cipher.AES SupportedPaddings", BLOCK_PADS);
                     put("Cipher.AES SupportedKeyFormats", "RAW");
 
-                    put("Cipher.AESWrap", "com.sun.crypto.provider.AESWrapCipher");
+                    put("Cipher.AES_128/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_ECB_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding");
+                    put("Cipher.AES_128/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_CBC_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding");
+                    put("Cipher.AES_128/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_OFB_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding");
+                    put("Cipher.AES_128/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_CFB_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding");
+
+                    put("Cipher.AES_192/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_ECB_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding");
+                    put("Cipher.AES_192/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_CBC_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding");
+                    put("Cipher.AES_192/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_OFB_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding");
+                    put("Cipher.AES_192/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_CFB_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding");
+
+
+                    put("Cipher.AES_256/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_ECB_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding");
+                    put("Cipher.AES_256/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_CBC_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding");
+                    put("Cipher.AES_256/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_OFB_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding");
+                    put("Cipher.AES_256/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_CFB_NoPadding");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding");
+
+                    put("Cipher.AESWrap", "com.sun.crypto.provider.AESWrapCipher$General");
                     put("Cipher.AESWrap SupportedModes", "ECB");
                     put("Cipher.AESWrap SupportedPaddings", "NOPADDING");
                     put("Cipher.AESWrap SupportedKeyFormats", "RAW");
 
+                    put("Cipher.AESWrap_128", "com.sun.crypto.provider.AESWrapCipher$AES128");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.5", "AESWrap_128");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.5", "AESWrap_128");
+                    put("Cipher.AESWrap_192", "com.sun.crypto.provider.AESWrapCipher$AES192");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.25", "AESWrap_192");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.25", "AESWrap_192");
+                    put("Cipher.AESWrap_256", "com.sun.crypto.provider.AESWrapCipher$AES256");
+                    put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.45", "AESWrap_256");
+                    put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.45", "AESWrap_256");
+
                     put("Cipher.RC2",
                         "com.sun.crypto.provider.RC2Cipher");
                     put("Cipher.RC2 SupportedModes", BLOCK_MODES);
@@ -192,7 +242,7 @@
                     put("Cipher.ARCFOUR SupportedKeyFormats", "RAW");
 
                     /*
-                     *  Key(pair) Generator engines
+                     * Key(pair) Generator engines
                      */
                     put("KeyGenerator.DES",
                         "com.sun.crypto.provider.DESKeyGenerator");
@@ -221,6 +271,8 @@
 
                     put("KeyGenerator.HmacSHA1",
                         "com.sun.crypto.provider.HmacSHA1KeyGenerator");
+                    put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.7", "HmacSHA1");
+                    put("Alg.Alias.KeyGenerator.1.2.840.113549.2.7", "HmacSHA1");
 
                     put("KeyGenerator.HmacSHA224",
                         "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA224");
@@ -326,14 +378,12 @@
                         "com.sun.crypto.provider.AESParameters");
                     put("Alg.Alias.AlgorithmParameters.Rijndael", "AES");
 
-
                     put("AlgorithmParameters.RC2",
                         "com.sun.crypto.provider.RC2Parameters");
 
                     put("AlgorithmParameters.OAEP",
                         "com.sun.crypto.provider.OAEPParameters");
 
-
                     /*
                      * Key factories
                      */
@@ -403,6 +453,8 @@
                      */
                     put("Mac.HmacMD5", "com.sun.crypto.provider.HmacMD5");
                     put("Mac.HmacSHA1", "com.sun.crypto.provider.HmacSHA1");
+                    put("Alg.Alias.Mac.OID.1.2.840.113549.2.7", "HmacSHA1");
+                    put("Alg.Alias.Mac.1.2.840.113549.2.7", "HmacSHA1");
                     put("Mac.HmacSHA224",
                         "com.sun.crypto.provider.HmacCore$HmacSHA224");
                     put("Alg.Alias.Mac.OID.1.2.840.113549.2.8", "HmacSHA224");
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java	Tue Sep 25 11:48:00 2012 -0700
@@ -30,6 +30,8 @@
 import java.awt.Event;
 import java.awt.KeyEventPostProcessor;
 import java.awt.Window;
+import java.awt.Toolkit;
+import sun.awt.SunToolkit;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
@@ -125,7 +127,19 @@
                 }
                 JMenu menu = mbar != null ? mbar.getMenu(0) : null;
 
-                if (menu != null) {
+                // It might happen that the altRelease event is processed
+                // with a reasonable delay since it has been generated.
+                // Here we check the last deactivation time of the containing
+                // window. If this time appears to be greater than the altRelease
+                // event time the event is skipped to avoid unexpected menu
+                // activation. See 7121442.
+                boolean skip = false;
+                Toolkit tk = Toolkit.getDefaultToolkit();
+                if (tk instanceof SunToolkit) {
+                    skip = ev.getWhen() <= ((SunToolkit)tk).getWindowDeactivationTime(winAncestor);
+                }
+
+                if (menu != null && !skip) {
                     MenuElement[] path = new MenuElement[2];
                     path[0] = mbar;
                     path[1] = menu;
--- a/jdk/src/share/classes/java/awt/Component.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/awt/Component.java	Tue Sep 25 11:48:00 2012 -0700
@@ -4710,7 +4710,10 @@
         /*
          * 0. Set timestamp and modifiers of current event.
          */
-        EventQueue.setCurrentEventAndMostRecentTime(e);
+        if (!(e instanceof KeyEvent)) {
+            // Timestamp of a key event is set later in DKFM.preDispatchKeyEvent(KeyEvent).
+            EventQueue.setCurrentEventAndMostRecentTime(e);
+        }
 
         /*
          * 1. Pre-dispatchers. Do any necessary retargeting/reordering here
@@ -7606,13 +7609,33 @@
                                      boolean focusedWindowChangeAllowed,
                                      CausedFocusEvent.Cause cause)
     {
+        // 1) Check if the event being dispatched is a system-generated mouse event.
+        AWTEvent currentEvent = EventQueue.getCurrentEvent();
+        if (currentEvent instanceof MouseEvent &&
+            SunToolkit.isSystemGenerated(currentEvent))
+        {
+            // 2) Sanity check: if the mouse event component source belongs to the same containing window.
+            Component source = ((MouseEvent)currentEvent).getComponent();
+            if (source == null || source.getContainingWindow() == getContainingWindow()) {
+                focusLog.finest("requesting focus by mouse event \"in window\"");
+
+                // If both the conditions are fulfilled the focus request should be strictly
+                // bounded by the toplevel window. It's assumed that the mouse event activates
+                // the window (if it wasn't active) and this makes it possible for a focus
+                // request with a strong in-window requirement to change focus in the bounds
+                // of the toplevel. If, by any means, due to asynchronous nature of the event
+                // dispatching mechanism, the window happens to be natively inactive by the time
+                // this focus request is eventually handled, it should not re-activate the
+                // toplevel. Otherwise the result may not meet user expectations. See 6981400.
+                focusedWindowChangeAllowed = false;
+            }
+        }
         if (!isRequestFocusAccepted(temporary, focusedWindowChangeAllowed, cause)) {
             if (focusLog.isLoggable(PlatformLogger.FINEST)) {
                 focusLog.finest("requestFocus is not accepted");
             }
             return false;
         }
-
         // Update most-recent map
         KeyboardFocusManager.setMostRecentFocusOwner(this);
 
@@ -7645,7 +7668,15 @@
         }
 
         // Focus this Component
-        long time = EventQueue.getMostRecentEventTime();
+        long time = 0;
+        if (EventQueue.isDispatchThread()) {
+            time = Toolkit.getEventQueue().getMostRecentKeyEventTime();
+        } else {
+            // A focus request made from outside EDT should not be associated with any event
+            // and so its time stamp is simply set to the current time.
+            time = System.currentTimeMillis();
+        }
+
         boolean success = peer.requestFocus
             (this, temporary, focusedWindowChangeAllowed, time, cause);
         if (!success) {
--- a/jdk/src/share/classes/java/awt/Container.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/awt/Container.java	Tue Sep 25 11:48:00 2012 -0700
@@ -2863,7 +2863,7 @@
 
         // keep the KeyEvents from being dispatched
         // until the focus has been transfered
-        long time = Toolkit.getEventQueue().getMostRecentEventTime();
+        long time = Toolkit.getEventQueue().getMostRecentKeyEventTime();
         Component predictedFocusOwner = (Component.isInstanceOf(this, "javax.swing.JInternalFrame")) ? ((javax.swing.JInternalFrame)(this)).getMostRecentFocusOwner() : null;
         if (predictedFocusOwner != null) {
             KeyboardFocusManager.getCurrentKeyboardFocusManager().
--- a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Tue Sep 25 11:48:00 2012 -0700
@@ -41,6 +41,7 @@
 import sun.awt.SunToolkit;
 import sun.awt.AWTAccessor;
 import sun.awt.CausedFocusEvent;
+import sun.awt.TimedWindowEvent;
 
 /**
  * The default KeyboardFocusManager for AWT applications. Focus traversal is
@@ -72,8 +73,8 @@
     private WeakReference<Window> realOppositeWindowWR = NULL_WINDOW_WR;
     private WeakReference<Component> realOppositeComponentWR = NULL_COMPONENT_WR;
     private int inSendMessage;
-    private LinkedList enqueuedKeyEvents = new LinkedList(),
-        typeAheadMarkers = new LinkedList();
+    private LinkedList<KeyEvent> enqueuedKeyEvents = new LinkedList<KeyEvent>();
+    private LinkedList<TypeAheadMarker> typeAheadMarkers = new LinkedList<TypeAheadMarker>();
     private boolean consumeNextKeyTyped;
 
     static {
@@ -269,6 +270,31 @@
         return se.dispatched;
     }
 
+    /*
+     * Checks if the focus window event follows key events waiting in the type-ahead
+     * queue (if any). This may happen when a user types ahead in the window, the client
+     * listeners hang EDT for a while, and the user switches b/w toplevels. In that
+     * case the focus window events may be dispatched before the type-ahead events
+     * get handled. This may lead to wrong focus behavior and in order to avoid it,
+     * the focus window events are reposted to the end of the event queue. See 6981400.
+     */
+    private boolean repostIfFollowsKeyEvents(WindowEvent e) {
+        if (!(e instanceof TimedWindowEvent)) {
+            return false;
+        }
+        TimedWindowEvent we = (TimedWindowEvent)e;
+        long time = we.getWhen();
+        synchronized (this) {
+            for (KeyEvent ke: enqueuedKeyEvents) {
+                if (time >= ke.getWhen()) {
+                    SunToolkit.postEvent(AppContext.getAppContext(), new SequencedEvent(e));
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     /**
      * This method is called by the AWT event dispatcher requesting that the
      * current KeyboardFocusManager dispatch the specified event on its behalf.
@@ -287,6 +313,10 @@
         if (focusLog.isLoggable(PlatformLogger.FINE) && (e instanceof WindowEvent || e instanceof FocusEvent)) focusLog.fine("" + e);
         switch (e.getID()) {
             case WindowEvent.WINDOW_GAINED_FOCUS: {
+                if (repostIfFollowsKeyEvents((WindowEvent)e)) {
+                    break;
+                }
+
                 WindowEvent we = (WindowEvent)e;
                 Window oldFocusedWindow = getGlobalFocusedWindow();
                 Window newFocusedWindow = we.getWindow();
@@ -646,6 +676,10 @@
             }
 
             case WindowEvent.WINDOW_LOST_FOCUS: {
+                if (repostIfFollowsKeyEvents((WindowEvent)e)) {
+                    break;
+                }
+
                 WindowEvent we = (WindowEvent)e;
                 Window currentFocusedWindow = getGlobalFocusedWindow();
                 Window losingFocusWindow = we.getWindow();
@@ -825,10 +859,9 @@
             ke = null;
             synchronized (this) {
                 if (enqueuedKeyEvents.size() != 0) {
-                    ke = (KeyEvent)enqueuedKeyEvents.getFirst();
+                    ke = enqueuedKeyEvents.getFirst();
                     if (typeAheadMarkers.size() != 0) {
-                        TypeAheadMarker marker = (TypeAheadMarker)
-                            typeAheadMarkers.getFirst();
+                        TypeAheadMarker marker = typeAheadMarkers.getFirst();
                         // Fixed 5064013: may appears that the events have the same time
                         // if (ke.getWhen() >= marker.after) {
                         // The fix is rolled out.
@@ -857,9 +890,9 @@
             focusLog.finest(">>> Markers dump, time: {0}", System.currentTimeMillis());
             synchronized (this) {
                 if (typeAheadMarkers.size() != 0) {
-                    Iterator iter = typeAheadMarkers.iterator();
+                    Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator();
                     while (iter.hasNext()) {
-                        TypeAheadMarker marker = (TypeAheadMarker)iter.next();
+                        TypeAheadMarker marker = iter.next();
                         focusLog.finest("    {0}", marker);
                     }
                 }
@@ -881,8 +914,7 @@
                 KeyEvent ke = (KeyEvent)e;
                 synchronized (this) {
                     if (e.isPosted && typeAheadMarkers.size() != 0) {
-                        TypeAheadMarker marker = (TypeAheadMarker)
-                            typeAheadMarkers.getFirst();
+                        TypeAheadMarker marker = typeAheadMarkers.getFirst();
                         // Fixed 5064013: may appears that the events have the same time
                         // if (ke.getWhen() >= marker.after) {
                         // The fix is rolled out.
@@ -915,12 +947,10 @@
                 synchronized (this) {
                     boolean found = false;
                     if (hasMarker(target)) {
-                        for (Iterator iter = typeAheadMarkers.iterator();
+                        for (Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator();
                              iter.hasNext(); )
                         {
-                            if (((TypeAheadMarker)iter.next()).untilFocused ==
-                                target)
-                            {
+                            if (iter.next().untilFocused == target) {
                                 found = true;
                             } else if (found) {
                                 break;
@@ -955,8 +985,8 @@
      * @since 1.5
      */
     private boolean hasMarker(Component comp) {
-        for (Iterator iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
-            if (((TypeAheadMarker)iter.next()).untilFocused == comp) {
+        for (Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
+            if (iter.next().untilFocused == comp) {
                 return true;
             }
         }
@@ -982,11 +1012,10 @@
             return true;
         }
 
-        // Explicitly set the current event and most recent timestamp here in
-        // addition to the call in Component.dispatchEventImpl. Because
-        // KeyEvents can be delivered in response to a FOCUS_GAINED event, the
-        // current timestamp may be incorrect. We need to set it here so that
-        // KeyEventDispatchers will use the correct time.
+        // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
+        // - A key event is anyway passed to this method which starts its actual dispatching.
+        // - If a key event is put to the type ahead queue, its time stamp should not be registered
+        //   until its dispatching actually starts (by this method).
         EventQueue.setCurrentEventAndMostRecentTime(ke);
 
         /**
@@ -1174,10 +1203,10 @@
 
         int insertionIndex = 0,
             i = typeAheadMarkers.size();
-        ListIterator iter = typeAheadMarkers.listIterator(i);
+        ListIterator<TypeAheadMarker> iter = typeAheadMarkers.listIterator(i);
 
         for (; i > 0; i--) {
-            TypeAheadMarker marker = (TypeAheadMarker)iter.previous();
+            TypeAheadMarker marker = iter.previous();
             if (marker.after <= after) {
                 insertionIndex = i;
                 break;
@@ -1213,12 +1242,12 @@
                        after, untilFocused);
 
         TypeAheadMarker marker;
-        ListIterator iter = typeAheadMarkers.listIterator
+        ListIterator<TypeAheadMarker> iter = typeAheadMarkers.listIterator
             ((after >= 0) ? typeAheadMarkers.size() : 0);
 
         if (after < 0) {
             while (iter.hasNext()) {
-                marker = (TypeAheadMarker)iter.next();
+                marker = iter.next();
                 if (marker.untilFocused == untilFocused)
                 {
                     iter.remove();
@@ -1227,7 +1256,7 @@
             }
         } else {
             while (iter.hasPrevious()) {
-                marker = (TypeAheadMarker)iter.previous();
+                marker = iter.previous();
                 if (marker.untilFocused == untilFocused &&
                     marker.after == after)
                 {
@@ -1255,8 +1284,8 @@
 
         long start = -1;
 
-        for (Iterator iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
-            TypeAheadMarker marker = (TypeAheadMarker)iter.next();
+        for (Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
+            TypeAheadMarker marker = iter.next();
             Component toTest = marker.untilFocused;
             boolean match = (toTest == comp);
             while (!match && toTest != null && !(toTest instanceof Window)) {
@@ -1287,8 +1316,8 @@
             return;
         }
 
-        for (Iterator iter = enqueuedKeyEvents.iterator(); iter.hasNext(); ) {
-            KeyEvent ke = (KeyEvent)iter.next();
+        for (Iterator<KeyEvent> iter = enqueuedKeyEvents.iterator(); iter.hasNext(); ) {
+            KeyEvent ke = iter.next();
             long time = ke.getWhen();
 
             if (start < time && (end < 0 || time <= end)) {
--- a/jdk/src/share/classes/java/awt/Dialog.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/awt/Dialog.java	Tue Sep 25 11:48:00 2012 -0700
@@ -924,7 +924,7 @@
                     isEnabled() && !isModalBlocked()) {
                     // keep the KeyEvents from being dispatched
                     // until the focus has been transfered
-                    time.set(Toolkit.getEventQueue().getMostRecentEventTimeEx());
+                    time.set(Toolkit.getEventQueue().getMostRecentKeyEventTime());
                     KeyboardFocusManager.getCurrentKeyboardFocusManager().
                         enqueueKeyEvents(time.get(), toFocus);
                 }
--- a/jdk/src/share/classes/java/awt/EventQueue.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/awt/EventQueue.java	Tue Sep 25 11:48:00 2012 -0700
@@ -162,6 +162,11 @@
      */
     private long mostRecentEventTime = System.currentTimeMillis();
 
+    /*
+     * The time stamp of the last KeyEvent .
+     */
+    private long mostRecentKeyEventTime = System.currentTimeMillis();
+
     /**
      * The modifiers field of the current event, if the current event is an
      * InputEvent or ActionEvent.
@@ -1142,6 +1147,15 @@
         }
     }
 
+    synchronized long getMostRecentKeyEventTime() {
+        pushPopLock.lock();
+        try {
+            return mostRecentKeyEventTime;
+        } finally {
+            pushPopLock.unlock();
+        }
+    }
+
     static void setCurrentEventAndMostRecentTime(AWTEvent e) {
         Toolkit.getEventQueue().setCurrentEventAndMostRecentTimeImpl(e);
     }
@@ -1166,6 +1180,9 @@
             if (e instanceof InputEvent) {
                 InputEvent ie = (InputEvent)e;
                 mostRecentEventTime2 = ie.getWhen();
+                if (e instanceof KeyEvent) {
+                    mostRecentKeyEventTime = ie.getWhen();
+                }
             } else if (e instanceof InputMethodEvent) {
                 InputMethodEvent ime = (InputMethodEvent)e;
                 mostRecentEventTime2 = ime.getWhen();
--- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java	Tue Sep 25 11:48:00 2012 -0700
@@ -445,7 +445,7 @@
     private void initPeer() {
         Toolkit tk = Toolkit.getDefaultToolkit();
         KeyboardFocusManagerPeerProvider peerProvider = (KeyboardFocusManagerPeerProvider)tk;
-        peer = peerProvider.createKeyboardFocusManagerPeer(this);
+        peer = peerProvider.getKeyboardFocusManagerPeer();
     }
 
     /**
--- a/jdk/src/share/classes/java/awt/SequencedEvent.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/awt/SequencedEvent.java	Tue Sep 25 11:48:00 2012 -0700
@@ -26,6 +26,7 @@
 package java.awt;
 
 import java.util.LinkedList;
+import sun.awt.AWTAccessor;
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
 
@@ -54,6 +55,17 @@
     private AppContext appContext;
     private boolean disposed;
 
+    static {
+        AWTAccessor.setSequencedEventAccessor(new AWTAccessor.SequencedEventAccessor() {
+            public AWTEvent getNested(AWTEvent sequencedEvent) {
+                return ((SequencedEvent)sequencedEvent).nested;
+            }
+            public boolean isSequencedEvent(AWTEvent event) {
+                return event instanceof SequencedEvent;
+            }
+        });
+    }
+
     /**
      * Constructs a new SequencedEvent which will dispatch the specified
      * nested event.
--- a/jdk/src/share/classes/java/awt/peer/KeyboardFocusManagerPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/awt/peer/KeyboardFocusManagerPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -34,6 +34,14 @@
 public interface KeyboardFocusManagerPeer {
 
     /**
+     * Sets the window that should become the focused window.
+     *
+     * @param win the window that should become the focused window
+     *
+     */
+    void setCurrentFocusedWindow(Window win);
+
+    /**
      * Returns the currently focused window.
      *
      * @return the currently focused window
--- a/jdk/src/share/classes/java/beans/Introspector.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/beans/Introspector.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1460,7 +1460,7 @@
     private PropertyDescriptor[] properties;
     private int defaultProperty;
     private MethodDescriptor[] methods;
-    private final Reference<BeanInfo> targetBeanInfoRef;
+    private Reference<BeanInfo> targetBeanInfoRef;
 
     public GenericBeanInfo(BeanDescriptor beanDescriptor,
                 EventSetDescriptor[] events, int defaultEvent,
@@ -1472,7 +1472,9 @@
         this.properties = properties;
         this.defaultProperty = defaultProperty;
         this.methods = methods;
-        this.targetBeanInfoRef = new SoftReference<>(targetBeanInfo);
+        this.targetBeanInfoRef = (targetBeanInfo != null)
+                ? new SoftReference<>(targetBeanInfo)
+                : null;
     }
 
     /**
@@ -1539,10 +1541,25 @@
     }
 
     public java.awt.Image getIcon(int iconKind) {
-        BeanInfo targetBeanInfo = this.targetBeanInfoRef.get();
+        BeanInfo targetBeanInfo = getTargetBeanInfo();
         if (targetBeanInfo != null) {
             return targetBeanInfo.getIcon(iconKind);
         }
         return super.getIcon(iconKind);
     }
+
+    private BeanInfo getTargetBeanInfo() {
+        if (this.targetBeanInfoRef == null) {
+            return null;
+        }
+        BeanInfo targetBeanInfo = this.targetBeanInfoRef.get();
+        if (targetBeanInfo == null) {
+            targetBeanInfo = ThreadGroupContext.getContext().getBeanInfoFinder()
+                    .find(this.beanDescriptor.getBeanClass());
+            if (targetBeanInfo != null) {
+                this.targetBeanInfoRef = new SoftReference<>(targetBeanInfo);
+            }
+        }
+        return targetBeanInfo;
+    }
 }
--- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java	Tue Sep 25 11:48:00 2012 -0700
@@ -109,6 +109,10 @@
         if (writeMethodName != null && getWriteMethod() == null) {
             throw new IntrospectionException("Method not found: " + writeMethodName);
         }
+        boundInitialization(beanClass);
+    }
+
+    private void boundInitialization(Class<?> beanClass) {
         // If this class or one of its base classes allow PropertyChangeListener,
         // then we assume that any properties we discover are "bound".
         // See Introspector.getTargetPropertyInfo() method.
@@ -159,6 +163,7 @@
         setReadMethod(read);
         setWriteMethod(write);
         this.baseName = base;
+        boundInitialization(bean);
     }
 
     /**
@@ -588,7 +593,7 @@
         Method yw = y.getWriteMethod();
 
         try {
-            if (yw != null && yw.getDeclaringClass() == getClass0()) {
+            if (yw != null) {
                 setWriteMethod(yw);
             } else {
                 setWriteMethod(xw);
--- a/jdk/src/share/classes/java/beans/XMLEncoder.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/beans/XMLEncoder.java	Tue Sep 25 11:48:00 2012 -0700
@@ -631,7 +631,12 @@
         }
 
         if (d.name != null) {
-            outputXML(isArgument ? "object" : "void", " idref=" + quote(d.name), value);
+            if (isArgument) {
+                writeln("<object idref=" + quote(d.name) + "/>");
+            }
+            else {
+                outputXML("void", " idref=" + quote(d.name), value);
+            }
         }
         else if (d.exp != null) {
             outputStatement(d.exp, outer, isArgument);
@@ -710,12 +715,14 @@
         }
         else {
             d.refs = 2;
-            getValueData(target).refs++;
-            List<Statement> statements = statementList(target);
-            if (!statements.contains(exp)) {
-                statements.add(exp);
+            if (d.name == null) {
+                getValueData(target).refs++;
+                List<Statement> statements = statementList(target);
+                if (!statements.contains(exp)) {
+                    statements.add(exp);
+                }
+                outputValue(target, outer, false);
             }
-            outputValue(target, outer, false);
             if (expression) {
                 outputValue(value, outer, isArgument);
             }
--- a/jdk/src/share/classes/java/io/ByteArrayOutputStream.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/io/ByteArrayOutputStream.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -210,21 +210,21 @@
 
     /**
      * Converts the buffer's contents into a string by decoding the bytes using
-     * the specified {@link java.nio.charset.Charset charsetName}. The length of
-     * the new <tt>String</tt> is a function of the charset, and hence may not be
-     * equal to the length of the byte array.
+     * the named {@link java.nio.charset.Charset charset}. The length of the new
+     * <tt>String</tt> is a function of the charset, and hence may not be equal
+     * to the length of the byte array.
      *
      * <p> This method always replaces malformed-input and unmappable-character
      * sequences with this charset's default replacement string. The {@link
      * java.nio.charset.CharsetDecoder} class should be used when more control
      * over the decoding process is required.
      *
-     * @param  charsetName  the name of a supported
-     *              {@linkplain java.nio.charset.Charset </code>charset<code>}
-     * @return String decoded from the buffer's contents.
+     * @param      charsetName  the name of a supported
+     *             {@link java.nio.charset.Charset charset}
+     * @return     String decoded from the buffer's contents.
      * @exception  UnsupportedEncodingException
      *             If the named charset is not supported
-     * @since   JDK1.1
+     * @since      JDK1.1
      */
     public synchronized String toString(String charsetName)
         throws UnsupportedEncodingException
--- a/jdk/src/share/classes/java/io/InputStreamReader.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/io/InputStreamReader.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -86,7 +86,7 @@
      *
      * @param  charsetName
      *         The name of a supported
-     *         {@link java.nio.charset.Charset </code>charset<code>}
+     *         {@link java.nio.charset.Charset charset}
      *
      * @exception  UnsupportedEncodingException
      *             If the named charset is not supported
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/lang/annotation/ContainerFor.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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.annotation;
+
+/**
+ * Indicates that an annotation type is a container for repeated
+ * instances of annotations of the type of the value of the
+ * {@code ContainerFor}'s value element.
+ *
+ * @since 1.8
+ * @jls 9.6 Annotation Types
+ * @jls 9.7 Annotations
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface ContainerFor {
+    /**
+     * The repeating annotation type that the annotation type
+     * annotated with this annotation is a container for.
+     */
+    Class<? extends Annotation> value();
+}
--- a/jdk/src/share/classes/java/security/interfaces/DSAKeyPairGenerator.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/security/interfaces/DSAKeyPairGenerator.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,6 +62,9 @@
  * interface is all that is needed when you accept defaults for algorithm-specific
  * parameters.
  *
+ * <p>Note: Some earlier implementations of this interface may not support
+ * larger sizes of DSA parameters such as 2048 and 3072-bit.
+ *
  * @see java.security.KeyPairGenerator
  */
 public interface DSAKeyPairGenerator {
@@ -78,7 +81,7 @@
      * can be null.
      *
      * @exception InvalidParameterException if the <code>params</code>
-     * value is invalid or null.
+     * value is invalid, null, or unsupported.
      */
    public void initialize(DSAParams params, SecureRandom random)
    throws InvalidParameterException;
@@ -97,7 +100,7 @@
      * default parameters for modulus lengths of 512 and 1024 bits.
      *
      * @param modlen the modulus length in bits. Valid values are any
-     * multiple of 8 between 512 and 1024, inclusive.
+     * multiple of 64 between 512 and 1024, inclusive, 2048, and 3072.
      *
      * @param random the random bit source to use to generate key bits;
      * can be null.
@@ -105,10 +108,9 @@
      * @param genParams whether or not to generate new parameters for
      * the modulus length requested.
      *
-     * @exception InvalidParameterException if <code>modlen</code> is not
-     * between 512 and 1024, or if <code>genParams</code> is false and
-     * there are no precomputed parameters for the requested modulus
-     * length.
+     * @exception InvalidParameterException if <code>modlen</code> is
+     * invalid, or unsupported, or if <code>genParams</code> is false and there
+     * are no precomputed parameters for the requested modulus length.
      */
     public void initialize(int modlen, boolean genParams, SecureRandom random)
     throws InvalidParameterException;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/security/spec/DSAGenParameterSpec.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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.security.spec;
+
+/**
+ * This immutable class specifies the set of parameters used for
+ * generating DSA parameters as specified in
+ * <a href="http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf">FIPS 186-3 Digital Signature Standard (DSS)</a>.
+ *
+ * @see AlgorithmParameterSpec
+ *
+ * @since 8
+ */
+public final class DSAGenParameterSpec implements AlgorithmParameterSpec {
+
+    private final int pLen;
+    private final int qLen;
+    private final int seedLen;
+
+    /**
+     * Creates a domain parameter specification for DSA parameter
+     * generation using <code>primePLen</code> and <code>subprimeQLen</code>.
+     * The value of <code>subprimeQLen</code> is also used as the default
+     * length of the domain parameter seed in bits.
+     * @param primePLen the desired length of the prime P in bits.
+     * @param subprimeQLen the desired length of the sub-prime Q in bits.
+     * @exception IllegalArgumentException if <code>primePLen</code>
+     * or <code>subprimeQLen</code> is illegal per the specification of
+     * FIPS 186-3.
+     */
+    public DSAGenParameterSpec(int primePLen, int subprimeQLen) {
+        this(primePLen, subprimeQLen, subprimeQLen);
+    }
+
+    /**
+     * Creates a domain parameter specification for DSA parameter
+     * generation using <code>primePLen</code>, <code>subprimeQLen</code>,
+     * and <code>seedLen</code>.
+     * @param primePLen the desired length of the prime P in bits.
+     * @param subprimeQLen the desired length of the sub-prime Q in bits.
+     * @param seedLen the desired length of the domain parameter seed in bits,
+     * shall be equal to or greater than <code>subprimeQLen</code>.
+     * @exception IllegalArgumentException if <code>primePLenLen</code>,
+     * <code>subprimeQLen</code>, or <code>seedLen</code> is illegal per the
+     * specification of FIPS 186-3.
+     */
+    public DSAGenParameterSpec(int primePLen, int subprimeQLen, int seedLen) {
+        switch (primePLen) {
+        case 1024:
+            if (subprimeQLen != 160) {
+                throw new IllegalArgumentException
+                    ("subprimeQLen must be 160 when primePLen=1024");
+            }
+            break;
+        case 2048:
+            if (subprimeQLen != 224 && subprimeQLen != 256) {
+               throw new IllegalArgumentException
+                   ("subprimeQLen must be 224 or 256 when primePLen=2048");
+            }
+            break;
+        case 3072:
+            if (subprimeQLen != 256) {
+                throw new IllegalArgumentException
+                    ("subprimeQLen must be 256 when primePLen=3072");
+            }
+            break;
+        default:
+            throw new IllegalArgumentException
+                ("primePLen must be 1024, 2048, or 3072");
+        }
+        if (seedLen < subprimeQLen) {
+            throw new IllegalArgumentException
+                ("seedLen must be equal to or greater than subprimeQLen");
+        }
+        this.pLen = primePLen;
+        this.qLen = subprimeQLen;
+        this.seedLen = seedLen;
+    }
+
+    /**
+     * Returns the desired length of the prime P of the
+     * to-be-generated DSA domain parameters in bits.
+     * @return the length of the prime P.
+     */
+    public int getPrimePLength() {
+        return pLen;
+    }
+
+    /**
+     * Returns the desired length of the sub-prime Q of the
+     * to-be-generated DSA domain parameters in bits.
+     * @return the length of the sub-prime Q.
+     */
+    public int getSubprimeQLength() {
+        return qLen;
+    }
+
+    /**
+     * Returns the desired length of the domain parameter seed in bits.
+     * @return the length of the domain parameter seed.
+     */
+    public int getSeedLength() {
+        return seedLen;
+    }
+}
--- a/jdk/src/share/classes/java/sql/DriverManager.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/java/sql/DriverManager.java	Tue Sep 25 11:48:00 2012 -0700
@@ -510,7 +510,7 @@
             public Void run() {
 
                 ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class);
-                Iterator driversIterator = loadedDrivers.iterator();
+                Iterator<Driver> driversIterator = loadedDrivers.iterator();
 
                 /* Load these drivers, so that they can be instantiated.
                  * It may be the case that the driver class may not be there
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java	Tue Sep 25 11:48:00 2012 -0700
@@ -667,6 +667,21 @@
     }
 
     /*
+     * An accessor for the SequencedEventAccessor class
+     */
+    public interface SequencedEventAccessor {
+        /*
+         * Returns the nested event.
+         */
+        AWTEvent getNested(AWTEvent sequencedEvent);
+
+        /*
+         * Returns true if the event is an instances of SequencedEvent.
+         */
+        boolean isSequencedEvent(AWTEvent event);
+    }
+
+    /*
      * Accessor instances are initialized in the static initializers of
      * corresponding AWT classes by using setters defined below.
      */
@@ -692,6 +707,7 @@
     private static SystemTrayAccessor systemTrayAccessor;
     private static TrayIconAccessor trayIconAccessor;
     private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor;
+    private static SequencedEventAccessor sequencedEventAccessor;
 
     /*
      * Set an accessor object for the java.awt.Component class.
@@ -1069,4 +1085,20 @@
         }
         return defaultKeyboardFocusManagerAccessor;
     }
+    /*
+     * Set an accessor object for the java.awt.SequencedEvent class.
+     */
+    public static void setSequencedEventAccessor(SequencedEventAccessor sea) {
+        sequencedEventAccessor = sea;
+    }
+
+    /*
+     * Get the accessor object for the java.awt.SequencedEvent class.
+     */
+    public static SequencedEventAccessor getSequencedEventAccessor() {
+        // The class is not public. So we can't ensure it's initialized.
+        // Null returned value means it's not initialized
+        // (so not a single instance of the event has been created).
+        return sequencedEventAccessor;
+    }
 }
--- a/jdk/src/share/classes/sun/awt/HToolkit.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/awt/HToolkit.java	Tue Sep 25 11:48:00 2012 -0700
@@ -44,6 +44,14 @@
 public class HToolkit extends SunToolkit
     implements ComponentFactory {
 
+    private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
+        public void setCurrentFocusedWindow(Window win) {}
+        public Window getCurrentFocusedWindow() { return null; }
+        public void setCurrentFocusOwner(Component comp) {}
+        public Component getCurrentFocusOwner() { return null; }
+        public void clearGlobalFocusOwner(Window activeWindow) {}
+    };
+
     public HToolkit() {
     }
 
@@ -152,15 +160,9 @@
         throw new HeadlessException();
     }
 
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
         // See 6833019.
-        return
-            new KeyboardFocusManagerPeer() {
-                public Window getCurrentFocusedWindow() { return null; }
-                public void setCurrentFocusOwner(Component comp) {}
-                public Component getCurrentFocusOwner() { return null; }
-                public void clearGlobalFocusOwner(Window activeWindow) {}
-            };
+        return kfmPeer;
     }
 
     public TrayIconPeer createTrayIcon(TrayIcon target)
--- a/jdk/src/share/classes/sun/awt/HeadlessToolkit.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/awt/HeadlessToolkit.java	Tue Sep 25 11:48:00 2012 -0700
@@ -30,22 +30,25 @@
 import java.awt.dnd.peer.DragSourceContextPeer;
 import java.awt.event.*;
 import java.awt.im.InputMethodHighlight;
-import java.awt.im.spi.InputMethodDescriptor;
 import java.awt.image.*;
 import java.awt.datatransfer.Clipboard;
 import java.awt.peer.*;
 import java.beans.PropertyChangeListener;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.util.Map;
 import java.util.Properties;
-import sun.awt.im.InputContext;
-import sun.awt.image.ImageRepresentation;
 
 public class HeadlessToolkit extends Toolkit
     implements ComponentFactory, KeyboardFocusManagerPeerProvider {
 
+    private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
+        public void setCurrentFocusedWindow(Window win) {}
+        public Window getCurrentFocusedWindow() { return null; }
+        public void setCurrentFocusOwner(Component comp) {}
+        public Component getCurrentFocusOwner() { return null; }
+        public void clearGlobalFocusOwner(Window activeWindow) {}
+    };
+
     private Toolkit tk;
     private ComponentFactory componentFactory;
 
@@ -179,15 +182,9 @@
         throw new HeadlessException();
     }
 
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
         // See 6833019.
-        return
-            new KeyboardFocusManagerPeer() {
-                public Window getCurrentFocusedWindow() { return null; }
-                public void setCurrentFocusOwner(Component comp) {}
-                public Component getCurrentFocusOwner() { return null; }
-                public void clearGlobalFocusOwner(Window activeWindow) {}
-            };
+        return kfmPeer;
     }
 
     public TrayIconPeer createTrayIcon(TrayIcon target)
--- a/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java	Tue Sep 25 11:48:00 2012 -0700
@@ -53,12 +53,6 @@
     public static final int SNFH_SUCCESS_HANDLED = 1;
     public static final int SNFH_SUCCESS_PROCEED = 2;
 
-    protected KeyboardFocusManager manager;
-
-    public KeyboardFocusManagerPeerImpl(KeyboardFocusManager manager) {
-        this.manager = manager;
-    }
-
     @Override
     public void clearGlobalFocusOwner(Window activeWindow) {
         if (activeWindow != null) {
@@ -134,7 +128,7 @@
 
             if (focusLog.isLoggable(PlatformLogger.FINER))
                 focusLog.finer("Posting focus event: " + fl);
-            SunToolkit.postPriorityEvent(fl);
+            SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl);
         }
 
         FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
@@ -142,7 +136,7 @@
 
         if (focusLog.isLoggable(PlatformLogger.FINER))
             focusLog.finer("Posting focus event: " + fg);
-        SunToolkit.postPriorityEvent(fg);
+        SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg);
         return true;
     }
 
--- a/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerProvider.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerProvider.java	Tue Sep 25 11:48:00 2012 -0700
@@ -25,20 +25,19 @@
 
 package sun.awt;
 
-import java.awt.KeyboardFocusManager;
 import java.awt.peer.KeyboardFocusManagerPeer;
 
 /**
  * {@link KeyboardFocusManagerPeerProvider} is required to be implemented by
  * the currently used {@link java.awt.Toolkit} instance. In order to initialize
- * {@link java.awt.KeyboardFocusManager}, an instance of {@link KeyboardFocusManagerPeer}
- * is needed. To create that instance, the {@link #createKeyboardFocusManagerPeer}
+ * {@link java.awt.KeyboardFocusManager}, a singleton instance of {@link KeyboardFocusManagerPeer}
+ * is needed. To obtain that instance, the {@link #getKeyboardFocusManagerPeer}
  * method of the current toolkit is called.
  */
 public interface KeyboardFocusManagerPeerProvider {
 
     /**
-     * Creates a KeyboardFocusManagerPeer for the specified KeyboardFocusManager.
+     * Gets a singleton KeyboardFocusManagerPeer instance.
      */
-    KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager);
+    KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 }
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Tue Sep 25 11:48:00 2012 -0700
@@ -197,7 +197,7 @@
     public abstract RobotPeer createRobot(Robot target, GraphicsDevice screen)
         throws AWTException;
 
-    public abstract KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager)
+    public abstract KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
         throws HeadlessException;
 
     /**
@@ -463,6 +463,19 @@
         if (event == null) {
             throw new NullPointerException();
         }
+
+        AWTAccessor.SequencedEventAccessor sea = AWTAccessor.getSequencedEventAccessor();
+        if (sea != null && sea.isSequencedEvent(event)) {
+            AWTEvent nested = sea.getNested(event);
+            if (nested.getID() == WindowEvent.WINDOW_LOST_FOCUS &&
+                nested instanceof TimedWindowEvent)
+            {
+                TimedWindowEvent twe = (TimedWindowEvent)nested;
+                ((SunToolkit)Toolkit.getDefaultToolkit()).
+                    setWindowDeactivationTime((Window)twe.getSource(), twe.getWhen());
+            }
+        }
+
         // All events posted via this method are system-generated.
         // Placing the following call here reduces considerably the
         // number of places throughout the toolkit that would
@@ -1863,6 +1876,28 @@
         return false;
     }
 
+    private static final Object DEACTIVATION_TIMES_MAP_KEY = new Object();
+
+    public synchronized void setWindowDeactivationTime(Window w, long time) {
+        AppContext ctx = getAppContext(w);
+        WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
+        if (map == null) {
+            map = new WeakHashMap<Window, Long>();
+            ctx.put(DEACTIVATION_TIMES_MAP_KEY, map);
+        }
+        map.put(w, time);
+    }
+
+    public synchronized long getWindowDeactivationTime(Window w) {
+        AppContext ctx = getAppContext(w);
+        WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
+        if (map == null) {
+            return -1;
+        }
+        Long time = map.get(w);
+        return time == null ? -1 : time;
+    }
+
     // Cosntant alpha
     public boolean isWindowOpacitySupported() {
         return false;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/awt/TimedWindowEvent.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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.awt;
+
+import java.awt.event.WindowEvent;
+import java.awt.Window;
+
+public class TimedWindowEvent extends WindowEvent {
+
+    private long time;
+
+    public long getWhen() {
+        return time;
+    }
+
+    public TimedWindowEvent(Window source, int id, Window opposite, long time) {
+        super(source, id, opposite);
+        this.time = time;
+    }
+
+    public TimedWindowEvent(Window source, int id, Window opposite,
+                            int oldState, int newState, long time)
+    {
+        super(source, id, opposite, oldState, newState);
+        this.time = time;
+    }
+}
+
--- a/jdk/src/share/classes/sun/security/ec/ECKeyFactory.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/ec/ECKeyFactory.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,33 +51,21 @@
  */
 public final class ECKeyFactory extends KeyFactorySpi {
 
-    // Used by translateKey() and the SunPKCS11 provider
-    public final static KeyFactory INSTANCE;
-
-    // Internal provider object we can obtain the KeyFactory and
-    // AlgorithmParameters from. Used by ECParameters and AlgorithmId.
-    // This can go away once we have EC always available in the SUN provider.
-    // Used by ECParameters and AlgorithmId.
-    public final static Provider ecInternalProvider;
+    // Used by translateKey()
+    private static KeyFactory instance;
 
-    static {
-        final Provider p = new Provider("SunEC-Internal", 1.0d, null) {
-            private static final long serialVersionUID = 970685700309471261L;
-        };
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            public Void run() {
-                p.put("KeyFactory.EC", "sun.security.ec.ECKeyFactory");
-                p.put("AlgorithmParameters.EC", "sun.security.ec.ECParameters");
-                p.put("Alg.Alias.AlgorithmParameters.1.2.840.10045.2.1", "EC");
-                return null;
+    private static KeyFactory getInstance() {
+        if (instance == null) {
+            try {
+                instance = KeyFactory.getInstance("EC", "SunEC");
+            } catch (NoSuchProviderException e) {
+                throw new RuntimeException(e);
+            } catch (NoSuchAlgorithmException e) {
+                throw new RuntimeException(e);
             }
-        });
-        try {
-            INSTANCE = KeyFactory.getInstance("EC", p);
-        } catch (NoSuchAlgorithmException e) {
-            throw new RuntimeException(e);
         }
-        ecInternalProvider = p;
+
+        return instance;
     }
 
     public ECKeyFactory() {
@@ -102,7 +90,12 @@
             checkKey(ecKey);
             return ecKey;
         } else {
-            return (ECKey)INSTANCE.translateKey(key);
+            /*
+             * We don't call the engineTranslateKey method directly
+             * because KeyFactory.translateKey adds code to loop through
+             * all key factories.
+             */
+            return (ECKey)getInstance().translateKey(key);
         }
     }
 
--- a/jdk/src/share/classes/sun/security/ec/ECParameters.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/ec/ECParameters.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -276,8 +276,8 @@
     static AlgorithmParameters getAlgorithmParameters(ECParameterSpec spec)
             throws InvalidKeyException {
         try {
-            AlgorithmParameters params = AlgorithmParameters.getInstance
-                                        ("EC", ECKeyFactory.ecInternalProvider);
+            AlgorithmParameters params =
+                AlgorithmParameters.getInstance("EC", "SunEC");
             params.init(spec);
             return params;
         } catch (GeneralSecurityException e) {
--- a/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java	Tue Sep 25 11:48:00 2012 -0700
@@ -96,8 +96,13 @@
      */
     @SuppressWarnings("deprecation")
     protected void parseKeyBits() throws InvalidKeyException {
+        AlgorithmParameters algParams = this.algid.getParameters();
+        if (algParams == null) {
+            throw new InvalidKeyException("EC domain parameters must be " +
+                "encoded in the algorithm identifier");
+        }
+
         try {
-            AlgorithmParameters algParams = this.algid.getParameters();
             params = algParams.getParameterSpec(ECParameterSpec.class);
             w = ECParameters.decodePoint(key, params.getCurve());
         } catch (IOException e) {
--- a/jdk/src/share/classes/sun/security/ec/SunECEntries.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/ec/SunECEntries.java	Tue Sep 25 11:48:00 2012 -0700
@@ -54,6 +54,7 @@
          */
         map.put("AlgorithmParameters.EC", "sun.security.ec.ECParameters");
         map.put("Alg.Alias.AlgorithmParameters.EllipticCurve", "EC");
+        map.put("Alg.Alias.AlgorithmParameters.1.2.840.10045.2.1", "EC");
 
         map.put("AlgorithmParameters.EC KeySize", "256");
 
@@ -133,6 +134,9 @@
             "sun.security.ec.ECDSASignature$Raw");
         map.put("Signature.SHA1withECDSA",
             "sun.security.ec.ECDSASignature$SHA1");
+        map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.1", "SHA1withECDSA");
+        map.put("Alg.Alias.Signature.1.2.840.10045.4.1", "SHA1withECDSA");
+
         map.put("Signature.SHA224withECDSA",
             "sun.security.ec.ECDSASignature$SHA224");
         map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.3.1", "SHA224withECDSA");
--- a/jdk/src/share/classes/sun/security/krb5/Config.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/krb5/Config.java	Tue Sep 25 11:48:00 2012 -0700
@@ -115,7 +115,12 @@
 
     private static boolean isMacosLionOrBetter() {
         // split the "10.x.y" version number
-        String osVersion = System.getProperty("os.version");
+        String osname = getProperty("os.name");
+        if (!osname.contains("OS X")) {
+            return false;
+        }
+
+        String osVersion = getProperty("os.version");
         String[] fragments = osVersion.split("\\.");
 
         // sanity check the "10." part of the version
@@ -140,20 +145,14 @@
         /*
          * If either one system property is specified, we throw exception.
          */
-        String tmp =
-            java.security.AccessController.doPrivileged(
-                new sun.security.action.GetPropertyAction
-                    ("java.security.krb5.kdc"));
+        String tmp = getProperty("java.security.krb5.kdc");
         if (tmp != null) {
             // The user can specify a list of kdc hosts separated by ":"
             defaultKDC = tmp.replace(':', ' ');
         } else {
             defaultKDC = null;
         }
-        defaultRealm =
-            java.security.AccessController.doPrivileged(
-                new sun.security.action.GetPropertyAction
-                    ("java.security.krb5.realm"));
+        defaultRealm = getProperty("java.security.krb5.realm");
         if ((defaultKDC == null && defaultRealm != null) ||
             (defaultRealm == null && defaultKDC != null)) {
             throw new KrbException
@@ -165,11 +164,34 @@
         // Always read the Kerberos configuration file
         try {
             Vector<String> configFile;
-            configFile = loadConfigFile();
-            if (configFile == null && isMacosLionOrBetter()) {
-                stanzaTable = SCDynamicStoreConfig.getConfig();
+            String fileName = getJavaFileName();
+            if (fileName != null) {
+                configFile = loadConfigFile(fileName);
+                stanzaTable = parseStanzaTable(configFile);
+                if (DEBUG) {
+                    System.out.println("Loaded from Java config");
+                }
             } else {
-                stanzaTable = parseStanzaTable(configFile);
+                boolean found = false;
+                if (isMacosLionOrBetter()) {
+                    try {
+                        stanzaTable = SCDynamicStoreConfig.getConfig();
+                        if (DEBUG) {
+                            System.out.println("Loaded from SCDynamicStoreConfig");
+                        }
+                        found = true;
+                    } catch (IOException ioe) {
+                        // OK. Will go on with file
+                    }
+                }
+                if (!found) {
+                    fileName = getNativeFileName();
+                    configFile = loadConfigFile(fileName);
+                    stanzaTable = parseStanzaTable(configFile);
+                    if (DEBUG) {
+                        System.out.println("Loaded from native config");
+                    }
+                }
             }
         } catch (IOException ioe) {
             // No krb5.conf, no problem. We'll use DNS or system property etc.
@@ -546,10 +568,13 @@
      * [domain_realm]
      *          blue.sample.com = TEST.SAMPLE.COM
      *          .backup.com     = EXAMPLE.COM
+     *
+     * @params fileName the conf file, cannot be null
+     * @return the content, null if fileName is empty
+     * @throws IOException if there is an I/O or format error
      */
-    private Vector<String> loadConfigFile() throws IOException {
+    private Vector<String> loadConfigFile(final String fileName) throws IOException {
         try {
-            final String fileName = getFileName();
             if (!fileName.equals("")) {
                 BufferedReader br = new BufferedReader(new InputStreamReader(
                 java.security.AccessController.doPrivileged(
@@ -668,97 +693,106 @@
     }
 
     /**
-     * Gets the default configuration file name. This method will never
-     * return null.
+     * Gets the default Java configuration file name.
      *
      * If the system property "java.security.krb5.conf" is defined, we'll
-     * use its value, no matter if the file exists or not. Otherwise,
-     * the file will be searched in a list of possible loations in the
-     * following order:
+     * use its value, no matter if the file exists or not. Otherwise, we
+     * will look at $JAVA_HOME/lib/security directory with "krb5.conf" name,
+     * and return it if the file exists.
      *
-     * 1. at Java home lib\security directory with "krb5.conf" name,
-     * 2. at windows directory with the name of "krb5.ini" for Windows,
-     * /etc/krb5/krb5.conf for Solaris, /etc/krb5.conf otherwise.
+     * The method returns null if it cannot find a Java config file.
+     */
+    private String getJavaFileName() {
+        String name = getProperty("java.security.krb5.conf");
+        if (name == null) {
+            name = getProperty("java.home") + File.separator +
+                                "lib" + File.separator + "security" +
+                                File.separator + "krb5.conf";
+            if (!fileExists(name)) {
+                name = null;
+            }
+        }
+        if (DEBUG) {
+            System.out.println("Java config name: " + name);
+        }
+        return name;
+    }
+
+    /**
+     * Gets the default native configuration file name.
+     *
+     * Depending on the OS type, the method returns the default native
+     * kerberos config file name, which is at windows directory with
+     * the name of "krb5.ini" for Windows, /etc/krb5/krb5.conf for Solaris,
+     * /etc/krb5.conf otherwise. Mac OSX X has a different file name.
      *
      * Note: When the Terminal Service is started in Windows (from 2003),
      * there are two kinds of Windows directories: A system one (say,
      * C:\Windows), and a user-private one (say, C:\Users\Me\Windows).
      * We will first look for krb5.ini in the user-private one. If not
      * found, try the system one instead.
+     *
+     * This method will always return a non-null non-empty file name,
+     * even if that file does not exist.
      */
-    private String getFileName() {
-        String name =
-            java.security.AccessController.doPrivileged(
-                                new sun.security.action.
-                                GetPropertyAction("java.security.krb5.conf"));
-        if (name == null) {
-            name = java.security.AccessController.doPrivileged(
-                        new sun.security.action.
-                        GetPropertyAction("java.home")) + File.separator +
-                                "lib" + File.separator + "security" +
-                                File.separator + "krb5.conf";
-            if (!fileExists(name)) {
-                name = null;
-                String osname =
-                        java.security.AccessController.doPrivileged(
-                        new sun.security.action.GetPropertyAction("os.name"));
-                if (osname.startsWith("Windows")) {
-                    try {
-                        Credentials.ensureLoaded();
-                    } catch (Exception e) {
-                        // ignore exceptions
+    private String getNativeFileName() {
+        String name = null;
+        String osname = getProperty("os.name");
+        if (osname.startsWith("Windows")) {
+            try {
+                Credentials.ensureLoaded();
+            } catch (Exception e) {
+                // ignore exceptions
+            }
+            if (Credentials.alreadyLoaded) {
+                String path = getWindowsDirectory(false);
+                if (path != null) {
+                    if (path.endsWith("\\")) {
+                        path = path + "krb5.ini";
+                    } else {
+                        path = path + "\\krb5.ini";
                     }
-                    if (Credentials.alreadyLoaded) {
-                        String path = getWindowsDirectory(false);
-                        if (path != null) {
-                            if (path.endsWith("\\")) {
-                                path = path + "krb5.ini";
-                            } else {
-                                path = path + "\\krb5.ini";
-                            }
-                            if (fileExists(path)) {
-                                name = path;
-                            }
+                    if (fileExists(path)) {
+                        name = path;
+                    }
+                }
+                if (name == null) {
+                    path = getWindowsDirectory(true);
+                    if (path != null) {
+                        if (path.endsWith("\\")) {
+                            path = path + "krb5.ini";
+                        } else {
+                            path = path + "\\krb5.ini";
                         }
-                        if (name == null) {
-                            path = getWindowsDirectory(true);
-                            if (path != null) {
-                                if (path.endsWith("\\")) {
-                                    path = path + "krb5.ini";
-                                } else {
-                                    path = path + "\\krb5.ini";
-                                }
-                                name = path;
-                            }
-                        }
+                        name = path;
                     }
-                    if (name == null) {
-                        name = "c:\\winnt\\krb5.ini";
-                    }
-                } else if (osname.startsWith("SunOS")) {
-                    name =  "/etc/krb5/krb5.conf";
-                } else if (osname.contains("OS X")) {
-                    if (isMacosLionOrBetter()) return "";
-                    name = findMacosConfigFile();
-                } else {
-                    name =  "/etc/krb5.conf";
                 }
             }
+            if (name == null) {
+                name = "c:\\winnt\\krb5.ini";
+            }
+        } else if (osname.startsWith("SunOS")) {
+            name =  "/etc/krb5/krb5.conf";
+        } else if (osname.contains("OS X")) {
+            name = findMacosConfigFile();
+        } else {
+            name =  "/etc/krb5.conf";
         }
         if (DEBUG) {
-            System.out.println("Config name: " + name);
+            System.out.println("Native config name: " + name);
         }
         return name;
     }
 
-    private String getProperty(String property) {
-        return java.security.AccessController.doPrivileged(new sun.security.action.GetPropertyAction(property));
+    private static String getProperty(String property) {
+        return java.security.AccessController.doPrivileged(
+                new sun.security.action.GetPropertyAction(property));
     }
 
     private String findMacosConfigFile() {
         String userHome = getProperty("user.home");
         final String PREF_FILE = "/Library/Preferences/edu.mit.Kerberos";
-        String userPrefs=userHome + PREF_FILE;
+        String userPrefs = userHome + PREF_FILE;
 
         if (fileExists(userPrefs)) {
             return userPrefs;
@@ -768,11 +802,7 @@
             return PREF_FILE;
         }
 
-        if (fileExists("/etc/krb5.conf")) {
-            return "/etc/krb5.conf";
-        }
-
-        return "";
+        return "/etc/krb5.conf";
     }
 
     private static String trimmed(String s) {
@@ -1344,32 +1374,52 @@
         }
     }
 
+    // Shows the content of the Config object for debug purpose.
+    //
+    // {
+    //      libdefaults = {
+    //          default_realm = R
+    //      }
+    //      realms = {
+    //          R = {
+    //              kdc = [k1,k2]
+    //          }
+    //      }
+    // }
+
     @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
-        toStringIndented("", stanzaTable, sb);
+        toStringInternal("", stanzaTable, sb);
         return sb.toString();
     }
-    private static void toStringIndented(String prefix, Object obj,
+    private static void toStringInternal(String prefix, Object obj,
             StringBuffer sb) {
         if (obj instanceof String) {
-            sb.append(prefix);
-            sb.append(obj);
-            sb.append('\n');
+            // A string value, just print it
+            sb.append(obj).append('\n');
         } else if (obj instanceof Hashtable) {
+            // A table, start a new sub-section...
             Hashtable<?, ?> tab = (Hashtable<?, ?>)obj;
+            sb.append("{\n");
             for (Object o: tab.keySet()) {
-                sb.append(prefix);
+                // ...indent, print "key = ", and
+                sb.append(prefix).append("    ").append(o).append(" = ");
+                // ...go recursively into value
+                toStringInternal(prefix + "    ", tab.get(o), sb);
+            }
+            sb.append(prefix).append("}\n");
+        } else if (obj instanceof Vector) {
+            // A vector of strings, print them inside [ and ]
+            Vector<?> v = (Vector<?>)obj;
+            sb.append("[");
+            boolean first = true;
+            for (Object o: v.toArray()) {
+                if (!first) sb.append(",");
                 sb.append(o);
-                sb.append(" = {\n");
-                toStringIndented(prefix + "    ", tab.get(o), sb);
-                sb.append(prefix + "}\n");
+                first = false;
             }
-        } else if (obj instanceof Vector) {
-            Vector<?> v = (Vector<?>)obj;
-            for (Object o: v.toArray()) {
-                toStringIndented(prefix + "    ", o, sb);
-            }
+            sb.append("]\n");
         }
     }
 }
--- a/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java	Tue Sep 25 11:48:00 2012 -0700
@@ -164,6 +164,10 @@
     // if we do the padding
     private int bytesBuffered;
 
+    // length of key size in bytes; currently only used by AES given its oid
+    // specification mandates a fixed size of the key
+    private int fixedKeySize = -1;
+
     P11Cipher(Token token, String algorithm, long mechanism)
             throws PKCS11Exception, NoSuchAlgorithmException {
         super();
@@ -172,19 +176,26 @@
         this.mechanism = mechanism;
 
         String algoParts[] = algorithm.split("/");
-        keyAlgorithm = algoParts[0];
 
-        if (keyAlgorithm.equals("AES")) {
+        if (algoParts[0].startsWith("AES")) {
             blockSize = 16;
-        } else if (keyAlgorithm.equals("RC4") ||
-                keyAlgorithm.equals("ARCFOUR")) {
-            blockSize = 0;
-        } else { // DES, DESede, Blowfish
-            blockSize = 8;
+            int index = algoParts[0].indexOf('_');
+            if (index != -1) {
+                // should be well-formed since we specify what we support
+                fixedKeySize = Integer.parseInt(algoParts[0].substring(index+1))/8;
+            }
+            keyAlgorithm = "AES";
+        } else {
+            keyAlgorithm = algoParts[0];
+            if (keyAlgorithm.equals("RC4") ||
+                    keyAlgorithm.equals("ARCFOUR")) {
+                blockSize = 0;
+            } else { // DES, DESede, Blowfish
+                blockSize = 8;
+            }
+            this.blockMode =
+                (algoParts.length > 1 ? parseMode(algoParts[1]) : MODE_ECB);
         }
-        this.blockMode =
-                (algoParts.length > 1 ? parseMode(algoParts[1]) : MODE_ECB);
-
         String defPadding = (blockSize == 0 ? "NoPadding" : "PKCS5Padding");
         String paddingStr =
                 (algoParts.length > 2 ? algoParts[2] : defPadding);
@@ -333,6 +344,9 @@
             SecureRandom random)
             throws InvalidKeyException, InvalidAlgorithmParameterException {
         cancelOperation();
+        if (fixedKeySize != -1 && key.getEncoded().length != fixedKeySize) {
+            throw new InvalidKeyException("Key size is invalid");
+        }
         switch (opmode) {
             case Cipher.ENCRYPT_MODE:
                 encrypt = true;
--- a/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -304,7 +304,7 @@
     }
 
     KeyFactory implGetSoftwareFactory() throws GeneralSecurityException {
-        return sun.security.ec.ECKeyFactory.INSTANCE;
+        return KeyFactory.getInstance("EC", "SunEC");
     }
 
 }
--- a/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java	Tue Sep 25 11:48:00 2012 -0700
@@ -399,12 +399,8 @@
         return System.identityHashCode(this);
     }
 
-    private static String[] s(String s1) {
-        return new String[] {s1};
-    }
-
-    private static String[] s(String s1, String s2) {
-        return new String[] {s1, s2};
+    private static String[] s(String ...aliases) {
+        return aliases;
     }
 
     private static final class Descriptor {
@@ -521,7 +517,8 @@
                 m(CKM_MD2));
         d(MD, "MD5",            P11Digest,
                 m(CKM_MD5));
-        d(MD, "SHA1",           P11Digest, s("SHA", "SHA-1"),
+        d(MD, "SHA1",           P11Digest,
+                s("SHA", "SHA-1", "1.3.14.3.2.26", "OID.1.3.14.3.2.26"),
                 m(CKM_SHA_1));
 
         d(MD, "SHA-224",        P11Digest,
@@ -540,6 +537,7 @@
         d(MAC, "HmacMD5",       P11MAC,
                 m(CKM_MD5_HMAC));
         d(MAC, "HmacSHA1",      P11MAC,
+                s("1.2.840.113549.2.7", "OID.1.2.840.113549.2.7"),
                 m(CKM_SHA_1_HMAC));
         d(MAC, "HmacSHA224",    P11MAC,
                 s("1.2.840.113549.2.8", "OID.1.2.840.113549.2.8"),
@@ -561,6 +559,7 @@
         d(KPG, "RSA",           P11KeyPairGenerator,
                 m(CKM_RSA_PKCS_KEY_PAIR_GEN));
         d(KPG, "DSA",           P11KeyPairGenerator,
+                s("1.3.14.3.2.12", "1.2.840.10040.4.1", "OID.1.2.840.10040.4.1"),
                 m(CKM_DSA_KEY_PAIR_GEN));
         d(KPG, "DH",            P11KeyPairGenerator,    s("DiffieHellman"),
                 m(CKM_DH_PKCS_KEY_PAIR_GEN));
@@ -583,6 +582,7 @@
         d(KF, "RSA",            P11RSAKeyFactory,
                 m(CKM_RSA_PKCS_KEY_PAIR_GEN, CKM_RSA_PKCS, CKM_RSA_X_509));
         d(KF, "DSA",            P11DSAKeyFactory,
+                s("1.3.14.3.2.12", "1.2.840.10040.4.1", "OID.1.2.840.10040.4.1"),
                 m(CKM_DSA_KEY_PAIR_GEN, CKM_DSA, CKM_DSA_SHA1));
         d(KF, "DH",             P11DHKeyFactory,        s("DiffieHellman"),
                 m(CKM_DH_PKCS_KEY_PAIR_GEN, CKM_DH_PKCS_DERIVE));
@@ -609,6 +609,7 @@
         d(SKF, "DESede",        P11SecretKeyFactory,
                 m(CKM_DES3_CBC));
         d(SKF, "AES",           P11SecretKeyFactory,
+                s("2.16.840.1.101.3.4.1", "OID.2.16.840.1.101.3.4.1"),
                 m(CKM_AES_CBC));
         d(SKF, "Blowfish",      P11SecretKeyFactory,
                 m(CKM_BLOWFISH_CBC));
@@ -635,10 +636,28 @@
                 m(CKM_DES3_ECB));
         d(CIP, "AES/CBC/NoPadding",             P11Cipher,
                 m(CKM_AES_CBC));
+        d(CIP, "AES_128/CBC/NoPadding",          P11Cipher,
+                s("2.16.840.1.101.3.4.1.2", "OID.2.16.840.1.101.3.4.1.2"),
+                m(CKM_AES_CBC));
+        d(CIP, "AES_192/CBC/NoPadding",          P11Cipher,
+                s("2.16.840.1.101.3.4.1.22", "OID.2.16.840.1.101.3.4.1.22"),
+                m(CKM_AES_CBC));
+        d(CIP, "AES_256/CBC/NoPadding",          P11Cipher,
+                s("2.16.840.1.101.3.4.1.42", "OID.2.16.840.1.101.3.4.1.42"),
+                m(CKM_AES_CBC));
         d(CIP, "AES/CBC/PKCS5Padding",          P11Cipher,
                 m(CKM_AES_CBC_PAD, CKM_AES_CBC));
         d(CIP, "AES/ECB/NoPadding",             P11Cipher,
                 m(CKM_AES_ECB));
+        d(CIP, "AES_128/ECB/NoPadding",          P11Cipher,
+                s("2.16.840.1.101.3.4.1.1", "OID.2.16.840.1.101.3.4.1.1"),
+                m(CKM_AES_ECB));
+        d(CIP, "AES_192/ECB/NoPadding",          P11Cipher,
+                s("2.16.840.1.101.3.4.1.21", "OID.2.16.840.1.101.3.4.1.21"),
+                m(CKM_AES_ECB));
+        d(CIP, "AES_256/ECB/NoPadding",          P11Cipher,
+                s("2.16.840.1.101.3.4.1.41", "OID.2.16.840.1.101.3.4.1.41"),
+                m(CKM_AES_ECB));
         d(CIP, "AES/ECB/PKCS5Padding",          P11Cipher,      s("AES"),
                 m(CKM_AES_ECB));
         d(CIP, "AES/CTR/NoPadding",             P11Cipher,
@@ -654,13 +673,16 @@
         d(CIP, "RSA/ECB/NoPadding",             P11RSACipher,
                 m(CKM_RSA_X_509));
 
-        d(SIG, "RawDSA",        P11Signature,           s("NONEwithDSA"),
+        d(SIG, "RawDSA",        P11Signature,   s("NONEwithDSA"),
                 m(CKM_DSA));
-        d(SIG, "DSA",           P11Signature,           s("SHA1withDSA"),
+        d(SIG, "DSA",           P11Signature,
+                s("SHA1withDSA", "1.3.14.3.2.13", "1.3.14.3.2.27",
+                  "1.2.840.10040.4.3", "OID.1.2.840.10040.4.3"),
                 m(CKM_DSA_SHA1, CKM_DSA));
         d(SIG, "NONEwithECDSA", P11Signature,
                 m(CKM_ECDSA));
-        d(SIG, "SHA1withECDSA", P11Signature,           s("ECDSA"),
+        d(SIG, "SHA1withECDSA", P11Signature,
+                s("ECDSA", "1.2.840.10045.4.1", "OID.1.2.840.10045.4.1"),
                 m(CKM_ECDSA_SHA1, CKM_ECDSA));
         d(SIG, "SHA224withECDSA",       P11Signature,
                 s("1.2.840.10045.4.3.1", "OID.1.2.840.10045.4.3.1"),
@@ -675,10 +697,14 @@
                 s("1.2.840.10045.4.3.4", "OID.1.2.840.10045.4.3.4"),
                 m(CKM_ECDSA));
         d(SIG, "MD2withRSA",    P11Signature,
+                s("1.2.840.113549.1.1.2", "OID.1.2.840.113549.1.1.2"),
                 m(CKM_MD2_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
         d(SIG, "MD5withRSA",    P11Signature,
+                s("1.2.840.113549.1.1.4", "OID.1.2.840.113549.1.1.4"),
                 m(CKM_MD5_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
         d(SIG, "SHA1withRSA",   P11Signature,
+                s("1.2.840.113549.1.1.5", "OID.1.2.840.113549.1.1.5",
+                  "1.3.14.3.2.29"),
                 m(CKM_SHA1_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
         d(SIG, "SHA224withRSA", P11Signature,
                 s("1.2.840.113549.1.1.14", "OID.1.2.840.113549.1.1.14"),
--- a/jdk/src/share/classes/sun/security/provider/DSA.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/provider/DSA.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,14 +45,15 @@
 
 /**
  * The Digital Signature Standard (using the Digital Signature
- * Algorithm), as described in fips186 of the National Instute of
- * Standards and Technology (NIST), using fips180-1 (SHA-1).
+ * Algorithm), as described in fips186-3 of the National Instute of
+ * Standards and Technology (NIST), using SHA digest algorithms
+ * from FIPS180-3.
  *
  * This file contains both the signature implementation for the
- * commonly used SHA1withDSA (DSS) as well as RawDSA, used by TLS
- * among others. RawDSA expects the 20 byte SHA-1 digest as input
- * via update rather than the original data like other signature
- * implementations.
+ * commonly used SHA1withDSA (DSS), SHA224withDSA, SHA256withDSA,
+ * as well as RawDSA, used by TLS among others. RawDSA expects
+ * the 20 byte SHA-1 digest as input via update rather than the
+ * original data like other signature implementations.
  *
  * @author Benjamin Renaud
  *
@@ -78,129 +79,19 @@
     /* The private key, if any */
     private BigInteger presetX;
 
-    /* The random seed used to generate k */
-    private int[] Kseed;
-
-    /* The random seed used to generate k (specified by application) */
-    private byte[] KseedAsByteArray;
-
-    /*
-     * The random seed used to generate k
-     * (prevent the same Kseed from being used twice in a row
-     */
-    private int[] previousKseed;
-
     /* The RNG used to output a seed for generating k */
     private SecureRandom signingRandom;
 
+    /* The message digest object used */
+    private final MessageDigest md;
+
     /**
      * Construct a blank DSA object. It must be
      * initialized before being usable for signing or verifying.
      */
-    DSA() {
+    DSA(MessageDigest md) {
         super();
-    }
-
-    /**
-     * Return the 20 byte hash value and reset the digest.
-     */
-    abstract byte[] getDigest() throws SignatureException;
-
-    /**
-     * Reset the digest.
-     */
-    abstract void resetDigest();
-
-    /**
-     * Standard SHA1withDSA implementation.
-     */
-    public static final class SHA1withDSA extends DSA {
-
-        /* The SHA hash for the data */
-        private final MessageDigest dataSHA;
-
-        public SHA1withDSA() throws NoSuchAlgorithmException {
-            dataSHA = MessageDigest.getInstance("SHA-1");
-        }
-
-        /**
-         * Update a byte to be signed or verified.
-         */
-        protected void engineUpdate(byte b) {
-            dataSHA.update(b);
-        }
-
-        /**
-         * Update an array of bytes to be signed or verified.
-         */
-        protected void engineUpdate(byte[] data, int off, int len) {
-            dataSHA.update(data, off, len);
-        }
-
-        protected void engineUpdate(ByteBuffer b) {
-            dataSHA.update(b);
-        }
-
-        byte[] getDigest() {
-            return dataSHA.digest();
-        }
-
-        void resetDigest() {
-            dataSHA.reset();
-        }
-    }
-
-    /**
-     * RawDSA implementation.
-     *
-     * RawDSA requires the data to be exactly 20 bytes long. If it is
-     * not, a SignatureException is thrown when sign()/verify() is called
-     * per JCA spec.
-     */
-    public static final class RawDSA extends DSA {
-
-        // length of the SHA-1 digest (20 bytes)
-        private final static int SHA1_LEN = 20;
-
-        // 20 byte digest buffer
-        private final byte[] digestBuffer;
-
-        // offset into the buffer
-        private int ofs;
-
-        public RawDSA() {
-            digestBuffer = new byte[SHA1_LEN];
-        }
-
-        protected void engineUpdate(byte b) {
-            if (ofs == SHA1_LEN) {
-                ofs = SHA1_LEN + 1;
-                return;
-            }
-            digestBuffer[ofs++] = b;
-        }
-
-        protected void engineUpdate(byte[] data, int off, int len) {
-            if (ofs + len > SHA1_LEN) {
-                ofs = SHA1_LEN + 1;
-                return;
-            }
-            System.arraycopy(data, off, digestBuffer, ofs, len);
-            ofs += len;
-        }
-
-        byte[] getDigest() throws SignatureException {
-            if (ofs != SHA1_LEN) {
-                throw new SignatureException
-                        ("Data for RawDSA must be exactly 20 bytes long");
-            }
-            ofs = 0;
-            return digestBuffer;
-        }
-
-        void resetDigest() {
-            ofs = 0;
-        }
+        this.md = md;
     }
 
     /**
@@ -217,13 +108,25 @@
             throw new InvalidKeyException("not a DSA private key: " +
                                           privateKey);
         }
+
         java.security.interfaces.DSAPrivateKey priv =
             (java.security.interfaces.DSAPrivateKey)privateKey;
+
+        // check for algorithm specific constraints before doing initialization
+        DSAParams params = priv.getParams();
+        if (params == null) {
+            throw new InvalidKeyException("DSA private key lacks parameters");
+        }
+        checkKey(params);
+
+        this.params = params;
         this.presetX = priv.getX();
         this.presetY = null;
-        initialize(priv.getParams());
+        this.presetP = params.getP();
+        this.presetQ = params.getQ();
+        this.presetG = params.getG();
+        this.md.reset();
     }
-
     /**
      * Initialize the DSA object with a DSA public key.
      *
@@ -240,17 +143,43 @@
         }
         java.security.interfaces.DSAPublicKey pub =
             (java.security.interfaces.DSAPublicKey)publicKey;
+
+        // check for algorithm specific constraints before doing initialization
+        DSAParams params = pub.getParams();
+        if (params == null) {
+            throw new InvalidKeyException("DSA public key lacks parameters");
+        }
+        checkKey(params);
+
+        this.params = params;
         this.presetY = pub.getY();
         this.presetX = null;
-        initialize(pub.getParams());
+        this.presetP = params.getP();
+        this.presetQ = params.getQ();
+        this.presetG = params.getG();
+        this.md.reset();
     }
 
-    private void initialize(DSAParams params) throws InvalidKeyException {
-        resetDigest();
-        setParams(params);
+    /**
+     * Update a byte to be signed or verified.
+     */
+    protected void engineUpdate(byte b) {
+        md.update(b);
     }
 
     /**
+     * Update an array of bytes to be signed or verified.
+     */
+    protected void engineUpdate(byte[] data, int off, int len) {
+        md.update(data, off, len);
+    }
+
+    protected void engineUpdate(ByteBuffer b) {
+        md.update(b);
+    }
+
+
+    /**
      * Sign all the data thus far updated. The signature is formatted
      * according to the Canonical Encoding Rules, returned as a DER
      * sequence of Integer, r and s.
@@ -352,23 +281,51 @@
         }
     }
 
+    @Deprecated
+    protected void engineSetParameter(String key, Object param) {
+        throw new InvalidParameterException("No parameter accepted");
+    }
+
+    @Deprecated
+    protected Object engineGetParameter(String key) {
+        return null;
+    }
+
+    protected void checkKey(DSAParams params) throws InvalidKeyException {
+        // FIPS186-3 states in sec4.2 that a hash function which provides
+        // a lower security strength than the (L, N) pair ordinarily should
+        // not be used.
+        int valueN = params.getQ().bitLength();
+        if (valueN > md.getDigestLength()*8) {
+            throw new InvalidKeyException("Key is too strong for this signature algorithm");
+        }
+    }
+
     private BigInteger generateR(BigInteger p, BigInteger q, BigInteger g,
                          BigInteger k) {
         BigInteger temp = g.modPow(k, p);
-        return temp.remainder(q);
-   }
+        return temp.mod(q);
+    }
 
     private BigInteger generateS(BigInteger x, BigInteger q,
             BigInteger r, BigInteger k) throws SignatureException {
 
-        byte[] s2 = getDigest();
-        BigInteger temp = new BigInteger(1, s2);
+        byte[] s2;
+        try {
+            s2 = md.digest();
+        } catch (RuntimeException re) {
+            // Only for RawDSA due to its 20-byte length restriction
+            throw new SignatureException(re.getMessage());
+        }
+        // get the leftmost min(N, outLen) bits of the digest value
+        int nBytes = q.bitLength()/8;
+        if (nBytes < s2.length) {
+            s2 = Arrays.copyOfRange(s2, 0, nBytes);
+        }
+        BigInteger z = new BigInteger(1, s2);
         BigInteger k1 = k.modInverse(q);
 
-        BigInteger s = x.multiply(r);
-        s = temp.add(s);
-        s = k1.multiply(s);
-        return s.remainder(q);
+        return x.multiply(r).add(z).multiply(k1).mod(q);
     }
 
     private BigInteger generateW(BigInteger p, BigInteger q,
@@ -380,54 +337,41 @@
              BigInteger q, BigInteger g, BigInteger w, BigInteger r)
              throws SignatureException {
 
-        byte[] s2 = getDigest();
-        BigInteger temp = new BigInteger(1, s2);
+        byte[] s2;
+        try {
+            s2 = md.digest();
+        } catch (RuntimeException re) {
+            // Only for RawDSA due to its 20-byte length restriction
+            throw new SignatureException(re.getMessage());
+        }
+        // get the leftmost min(N, outLen) bits of the digest value
+        int nBytes = q.bitLength()/8;
+        if (nBytes < s2.length) {
+            s2 = Arrays.copyOfRange(s2, 0, nBytes);
+        }
+        BigInteger z = new BigInteger(1, s2);
 
-        temp = temp.multiply(w);
-        BigInteger u1 = temp.remainder(q);
-
-        BigInteger u2 = (r.multiply(w)).remainder(q);
+        BigInteger u1 = z.multiply(w).mod(q);
+        BigInteger u2 = (r.multiply(w)).mod(q);
 
         BigInteger t1 = g.modPow(u1,p);
         BigInteger t2 = y.modPow(u2,p);
         BigInteger t3 = t1.multiply(t2);
-        BigInteger t5 = t3.remainder(p);
-        return t5.remainder(q);
+        BigInteger t5 = t3.mod(p);
+        return t5.mod(q);
     }
 
-    /*
-     * Please read bug report 4044247 for an alternative, faster,
-     * NON-FIPS approved method to generate K
-     */
-    private BigInteger generateK(BigInteger q) {
-
-        BigInteger k = null;
-
-        // The application specified a Kseed for us to use.
-        // Note that we do not allow usage of the same Kseed twice in a row
-        if (Kseed != null && !Arrays.equals(Kseed, previousKseed)) {
-            k = generateK(Kseed, q);
-            if (k.signum() > 0 && k.compareTo(q) < 0) {
-                previousKseed = new int [Kseed.length];
-                System.arraycopy(Kseed, 0, previousKseed, 0, Kseed.length);
-                return k;
-            }
-        }
-
-        // The application did not specify a Kseed for us to use.
-        // We'll generate a new Kseed by getting random bytes from
-        // a SecureRandom object.
+    // NOTE: This following impl is defined in FIPS 186-3 AppendixB.2.2.
+    // Original DSS algos such as SHA1withDSA and RawDSA uses a different
+    // algorithm defined in FIPS 186-1 Sec3.2, and thus need to override this.
+    protected BigInteger generateK(BigInteger q) {
         SecureRandom random = getSigningRandom();
+        byte[] kValue = new byte[q.bitLength()/8];
 
         while (true) {
-            int[] seed = new int[5];
-
-            for (int i = 0; i < 5; i++)
-                seed[i] = random.nextInt();
-            k = generateK(seed, q);
+            random.nextBytes(kValue);
+            BigInteger k = new BigInteger(1, kValue).mod(q);
             if (k.signum() > 0 && k.compareTo(q) < 0) {
-                previousKseed = new int [seed.length];
-                System.arraycopy(seed, 0, previousKseed, 0, seed.length);
                 return k;
             }
         }
@@ -435,7 +379,7 @@
 
     // Use the application-specified SecureRandom Object if provided.
     // Otherwise, use our default SecureRandom Object.
-    private SecureRandom getSigningRandom() {
+    protected SecureRandom getSigningRandom() {
         if (signingRandom == null) {
             if (appRandom != null) {
                 signingRandom = appRandom;
@@ -447,171 +391,6 @@
     }
 
     /**
-     * Compute k for a DSA signature.
-     *
-     * @param seed the seed for generating k. This seed should be
-     * secure. This is what is refered to as the KSEED in the DSA
-     * specification.
-     *
-     * @param g the g parameter from the DSA key pair.
-     */
-    private BigInteger generateK(int[] seed, BigInteger q) {
-
-        // check out t in the spec.
-        int[] t = { 0xEFCDAB89, 0x98BADCFE, 0x10325476,
-                    0xC3D2E1F0, 0x67452301 };
-        //
-        int[] tmp = DSA.SHA_7(seed, t);
-        byte[] tmpBytes = new byte[tmp.length * 4];
-        for (int i = 0; i < tmp.length; i++) {
-            int k = tmp[i];
-            for (int j = 0; j < 4; j++) {
-                tmpBytes[(i * 4) + j] = (byte) (k >>> (24 - (j * 8)));
-            }
-        }
-        BigInteger k = new BigInteger(1, tmpBytes).mod(q);
-        return k;
-    }
-
-   // Constants for each round
-    private static final int round1_kt = 0x5a827999;
-    private static final int round2_kt = 0x6ed9eba1;
-    private static final int round3_kt = 0x8f1bbcdc;
-    private static final int round4_kt = 0xca62c1d6;
-
-   /**
-    * Computes set 1 thru 7 of SHA-1 on m1. */
-   static int[] SHA_7(int[] m1, int[] h) {
-
-       int[] W = new int[80];
-       System.arraycopy(m1,0,W,0,m1.length);
-       int temp = 0;
-
-        for (int t = 16; t <= 79; t++){
-            temp = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16];
-            W[t] = ((temp << 1) | (temp >>>(32 - 1)));
-        }
-
-       int a = h[0],b = h[1],c = h[2], d = h[3], e = h[4];
-       for (int i = 0; i < 20; i++) {
-            temp = ((a<<5) | (a>>>(32-5))) +
-                ((b&c)|((~b)&d))+ e + W[i] + round1_kt;
-            e = d;
-            d = c;
-            c = ((b<<30) | (b>>>(32-30)));
-            b = a;
-            a = temp;
-        }
-
-        // Round 2
-        for (int i = 20; i < 40; i++) {
-            temp = ((a<<5) | (a>>>(32-5))) +
-                (b ^ c ^ d) + e + W[i] + round2_kt;
-            e = d;
-            d = c;
-            c = ((b<<30) | (b>>>(32-30)));
-            b = a;
-            a = temp;
-        }
-
-        // Round 3
-        for (int i = 40; i < 60; i++) {
-            temp = ((a<<5) | (a>>>(32-5))) +
-                ((b&c)|(b&d)|(c&d)) + e + W[i] + round3_kt;
-            e = d;
-            d = c;
-            c = ((b<<30) | (b>>>(32-30)));
-            b = a;
-            a = temp;
-        }
-
-        // Round 4
-        for (int i = 60; i < 80; i++) {
-            temp = ((a<<5) | (a>>>(32-5))) +
-                (b ^ c ^ d) + e + W[i] + round4_kt;
-            e = d;
-            d = c;
-            c = ((b<<30) | (b>>>(32-30)));
-            b = a;
-            a = temp;
-        }
-       int[] md = new int[5];
-       md[0] = h[0] + a;
-       md[1] = h[1] + b;
-       md[2] = h[2] + c;
-       md[3] = h[3] + d;
-       md[4] = h[4] + e;
-       return md;
-   }
-
-
-    /**
-     * This implementation recognizes the following parameter:<dl>
-     *
-     * <dt><tt>Kseed</tt>
-     *
-     * <dd>a byte array.
-     *
-     * </dl>
-     *
-     * @deprecated
-     */
-    @Deprecated
-    protected void engineSetParameter(String key, Object param) {
-        if (key.equals("KSEED")) {
-            if (param instanceof byte[]) {
-                Kseed = byteArray2IntArray((byte[])param);
-                KseedAsByteArray = (byte[])param;
-            } else {
-                debug("unrecognized param: " + key);
-                throw new InvalidParameterException("Kseed not a byte array");
-            }
-        } else {
-            throw new InvalidParameterException("invalid parameter");
-        }
-    }
-
-    /**
-     * Return the value of the requested parameter. Recognized
-     * parameters are:
-     *
-     * <dl>
-     *
-     * <dt><tt>Kseed</tt>
-     *
-     * <dd>a byte array.
-     *
-     * </dl>
-     *
-     * @return the value of the requested parameter.
-     *
-     * @see java.security.SignatureEngine
-     *
-     * @deprecated
-     */
-    @Deprecated
-    protected Object engineGetParameter(String key) {
-        if (key.equals("KSEED")) {
-            return KseedAsByteArray;
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Set the algorithm object.
-     */
-    private void setParams(DSAParams params) throws InvalidKeyException {
-        if (params == null) {
-            throw new InvalidKeyException("DSA public key lacks parameters");
-        }
-        this.params = params;
-        this.presetP = params.getP();
-        this.presetQ = params.getQ();
-        this.presetG = params.getG();
-    }
-
-    /**
      * Return a human readable rendition of the engine.
      */
     public String toString() {
@@ -632,38 +411,6 @@
         return printable;
     }
 
-    /*
-     * Utility routine for converting a byte array into an int array
-     */
-    private int[] byteArray2IntArray(byte[] byteArray) {
-
-        int j = 0;
-        byte[] newBA;
-        int mod = byteArray.length % 4;
-
-        // guarantee that the incoming byteArray is a multiple of 4
-        // (pad with 0's)
-        switch (mod) {
-            case 3:     newBA = new byte[byteArray.length + 1]; break;
-            case 2:     newBA = new byte[byteArray.length + 2]; break;
-            case 1:     newBA = new byte[byteArray.length + 3]; break;
-            default:    newBA = new byte[byteArray.length + 0]; break;
-        }
-        System.arraycopy(byteArray, 0, newBA, 0, byteArray.length);
-
-        // copy each set of 4 bytes in the byte array into an integer
-        int[] newSeed = new int[newBA.length / 4];
-        for (int i = 0; i < newBA.length; i += 4) {
-            newSeed[j] = newBA[i + 3] & 0xFF;
-            newSeed[j] |= (newBA[i + 2] << 8) & 0xFF00;
-            newSeed[j] |= (newBA[i + 1] << 16) & 0xFF0000;
-            newSeed[j] |= (newBA[i + 0] << 24) & 0xFF000000;
-            j++;
-        }
-
-        return newSeed;
-    }
-
     private static void debug(Exception e) {
         if (debug) {
             e.printStackTrace();
@@ -675,4 +422,325 @@
             System.err.println(s);
         }
     }
+
+    /**
+     * Standard SHA224withDSA implementation as defined in FIPS186-3.
+     */
+    public static final class SHA224withDSA extends DSA {
+        public SHA224withDSA() throws NoSuchAlgorithmException {
+            super(MessageDigest.getInstance("SHA-224"));
+        }
+    }
+
+    /**
+     * Standard SHA256withDSA implementation as defined in FIPS186-3.
+     */
+    public static final class SHA256withDSA extends DSA {
+        public SHA256withDSA() throws NoSuchAlgorithmException {
+            super(MessageDigest.getInstance("SHA-256"));
+        }
+    }
+
+    static class LegacyDSA extends DSA {
+        /* The random seed used to generate k */
+        private int[] kSeed;
+        /* The random seed used to generate k (specified by application) */
+        private byte[] kSeedAsByteArray;
+        /*
+         * The random seed used to generate k
+         * (prevent the same Kseed from being used twice in a row
+         */
+        private int[] kSeedLast;
+
+        public LegacyDSA(MessageDigest md) throws NoSuchAlgorithmException {
+            super(md);
+        }
+
+        @Deprecated
+        protected void engineSetParameter(String key, Object param) {
+            if (key.equals("KSEED")) {
+                if (param instanceof byte[]) {
+                    kSeed = byteArray2IntArray((byte[])param);
+                    kSeedAsByteArray = (byte[])param;
+                } else {
+                    debug("unrecognized param: " + key);
+                    throw new InvalidParameterException("kSeed not a byte array");
+                }
+            } else {
+                throw new InvalidParameterException("Unsupported parameter");
+            }
+        }
+
+        @Deprecated
+        protected Object engineGetParameter(String key) {
+           if (key.equals("KSEED")) {
+               return kSeedAsByteArray;
+           } else {
+               return null;
+           }
+        }
+
+        @Override
+        protected void checkKey(DSAParams params) throws InvalidKeyException {
+            int valueL = params.getP().bitLength();
+            if (valueL > 1024) {
+                throw new InvalidKeyException("Key is too long for this algorithm");
+            }
+        }
+
+        /*
+         * Please read bug report 4044247 for an alternative, faster,
+         * NON-FIPS approved method to generate K
+         */
+        @Override
+        protected BigInteger generateK(BigInteger q) {
+            BigInteger k = null;
+
+            // The application specified a kSeed for us to use.
+            // Note: we dis-allow usage of the same Kseed twice in a row
+            if (kSeed != null && !Arrays.equals(kSeed, kSeedLast)) {
+                k = generateKUsingKSeed(kSeed, q);
+                if (k.signum() > 0 && k.compareTo(q) < 0) {
+                    kSeedLast = kSeed.clone();
+                    return k;
+                }
+            }
+
+            // The application did not specify a Kseed for us to use.
+            // We'll generate a new Kseed by getting random bytes from
+            // a SecureRandom object.
+            SecureRandom random = getSigningRandom();
+
+            while (true) {
+                int[] seed = new int[5];
+
+                for (int i = 0; i < 5; i++) seed[i] = random.nextInt();
+
+                k = generateKUsingKSeed(seed, q);
+                if (k.signum() > 0 && k.compareTo(q) < 0) {
+                    kSeedLast = seed;
+                    return k;
+                }
+            }
+        }
+
+        /**
+         * Compute k for the DSA signature as defined in the original DSS,
+         * i.e. FIPS186.
+         *
+         * @param seed the seed for generating k. This seed should be
+         * secure. This is what is refered to as the KSEED in the DSA
+         * specification.
+         *
+         * @param g the g parameter from the DSA key pair.
+         */
+        private BigInteger generateKUsingKSeed(int[] seed, BigInteger q) {
+
+            // check out t in the spec.
+            int[] t = { 0xEFCDAB89, 0x98BADCFE, 0x10325476,
+                        0xC3D2E1F0, 0x67452301 };
+            //
+            int[] tmp = SHA_7(seed, t);
+            byte[] tmpBytes = new byte[tmp.length * 4];
+            for (int i = 0; i < tmp.length; i++) {
+                int k = tmp[i];
+                for (int j = 0; j < 4; j++) {
+                    tmpBytes[(i * 4) + j] = (byte) (k >>> (24 - (j * 8)));
+                }
+            }
+            BigInteger k = new BigInteger(1, tmpBytes).mod(q);
+            return k;
+        }
+
+        // Constants for each round
+        private static final int round1_kt = 0x5a827999;
+        private static final int round2_kt = 0x6ed9eba1;
+        private static final int round3_kt = 0x8f1bbcdc;
+        private static final int round4_kt = 0xca62c1d6;
+
+        /**
+         * Computes set 1 thru 7 of SHA-1 on m1. */
+        static int[] SHA_7(int[] m1, int[] h) {
+
+            int[] W = new int[80];
+            System.arraycopy(m1,0,W,0,m1.length);
+            int temp = 0;
+
+            for (int t = 16; t <= 79; t++){
+                temp = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16];
+                W[t] = ((temp << 1) | (temp >>>(32 - 1)));
+            }
+
+            int a = h[0],b = h[1],c = h[2], d = h[3], e = h[4];
+            for (int i = 0; i < 20; i++) {
+                temp = ((a<<5) | (a>>>(32-5))) +
+                    ((b&c)|((~b)&d))+ e + W[i] + round1_kt;
+                e = d;
+                d = c;
+                c = ((b<<30) | (b>>>(32-30)));
+                b = a;
+                a = temp;
+            }
+
+            // Round 2
+            for (int i = 20; i < 40; i++) {
+                temp = ((a<<5) | (a>>>(32-5))) +
+                    (b ^ c ^ d) + e + W[i] + round2_kt;
+                e = d;
+                d = c;
+                c = ((b<<30) | (b>>>(32-30)));
+                b = a;
+                a = temp;
+            }
+
+            // Round 3
+            for (int i = 40; i < 60; i++) {
+                temp = ((a<<5) | (a>>>(32-5))) +
+                    ((b&c)|(b&d)|(c&d)) + e + W[i] + round3_kt;
+                e = d;
+                d = c;
+                c = ((b<<30) | (b>>>(32-30)));
+                b = a;
+                a = temp;
+            }
+
+            // Round 4
+            for (int i = 60; i < 80; i++) {
+                temp = ((a<<5) | (a>>>(32-5))) +
+                    (b ^ c ^ d) + e + W[i] + round4_kt;
+                e = d;
+                d = c;
+                c = ((b<<30) | (b>>>(32-30)));
+                b = a;
+                a = temp;
+            }
+            int[] md = new int[5];
+            md[0] = h[0] + a;
+            md[1] = h[1] + b;
+            md[2] = h[2] + c;
+            md[3] = h[3] + d;
+            md[4] = h[4] + e;
+            return md;
+        }
+
+        /*
+         * Utility routine for converting a byte array into an int array
+         */
+        private int[] byteArray2IntArray(byte[] byteArray) {
+
+            int j = 0;
+            byte[] newBA;
+            int mod = byteArray.length % 4;
+
+            // guarantee that the incoming byteArray is a multiple of 4
+            // (pad with 0's)
+            switch (mod) {
+            case 3:     newBA = new byte[byteArray.length + 1]; break;
+            case 2:     newBA = new byte[byteArray.length + 2]; break;
+            case 1:     newBA = new byte[byteArray.length + 3]; break;
+            default:    newBA = new byte[byteArray.length + 0]; break;
+            }
+            System.arraycopy(byteArray, 0, newBA, 0, byteArray.length);
+
+            // copy each set of 4 bytes in the byte array into an integer
+            int[] newSeed = new int[newBA.length / 4];
+            for (int i = 0; i < newBA.length; i += 4) {
+                newSeed[j] = newBA[i + 3] & 0xFF;
+                newSeed[j] |= (newBA[i + 2] << 8) & 0xFF00;
+                newSeed[j] |= (newBA[i + 1] << 16) & 0xFF0000;
+                newSeed[j] |= (newBA[i + 0] << 24) & 0xFF000000;
+                j++;
+            }
+
+            return newSeed;
+        }
+    }
+
+    public static final class SHA1withDSA extends LegacyDSA {
+        public SHA1withDSA() throws NoSuchAlgorithmException {
+            super(MessageDigest.getInstance("SHA-1"));
+        }
+    }
+
+    /**
+     * RawDSA implementation.
+     *
+     * RawDSA requires the data to be exactly 20 bytes long. If it is
+     * not, a SignatureException is thrown when sign()/verify() is called
+     * per JCA spec.
+     */
+    public static final class RawDSA extends LegacyDSA {
+        // Internal special-purpose MessageDigest impl for RawDSA
+        // Only override whatever methods used
+        // NOTE: no clone support
+        public static final class NullDigest20 extends MessageDigest {
+            // 20 byte digest buffer
+            private final byte[] digestBuffer = new byte[20];
+
+            // offset into the buffer; use Integer.MAX_VALUE to indicate
+            // out-of-bound condition
+            private int ofs = 0;
+
+            protected NullDigest20() {
+                super("NullDigest20");
+            }
+            protected void engineUpdate(byte input) {
+                if (ofs == digestBuffer.length) {
+                    ofs = Integer.MAX_VALUE;
+                } else {
+                    digestBuffer[ofs++] = input;
+                }
+            }
+            protected void engineUpdate(byte[] input, int offset, int len) {
+                if (ofs + len > digestBuffer.length) {
+                    ofs = Integer.MAX_VALUE;
+                } else {
+                    System.arraycopy(input, offset, digestBuffer, ofs, len);
+                    ofs += len;
+                }
+            }
+            protected final void engineUpdate(ByteBuffer input) {
+                int inputLen = input.remaining();
+                if (ofs + inputLen > digestBuffer.length) {
+                    ofs = Integer.MAX_VALUE;
+                } else {
+                    input.get(digestBuffer, ofs, inputLen);
+                    ofs += inputLen;
+                }
+            }
+            protected byte[] engineDigest() throws RuntimeException {
+                if (ofs != digestBuffer.length) {
+                    throw new RuntimeException
+                        ("Data for RawDSA must be exactly 20 bytes long");
+                }
+                reset();
+                return digestBuffer;
+            }
+            protected int engineDigest(byte[] buf, int offset, int len)
+                throws DigestException {
+                if (ofs != digestBuffer.length) {
+                    throw new DigestException
+                        ("Data for RawDSA must be exactly 20 bytes long");
+                }
+                if (len < digestBuffer.length) {
+                    throw new DigestException
+                        ("Output buffer too small; must be at least 20 bytes");
+                }
+                System.arraycopy(digestBuffer, 0, buf, offset, digestBuffer.length);
+                reset();
+                return digestBuffer.length;
+            }
+
+            protected void engineReset() {
+                ofs = 0;
+            }
+            protected final int engineGetDigestLength() {
+                return digestBuffer.length;
+            }
+        }
+
+        public RawDSA() throws NoSuchAlgorithmException {
+            super(new NullDigest20());
+        }
+    }
 }
--- a/jdk/src/share/classes/sun/security/provider/DSAKeyPairGenerator.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/provider/DSAKeyPairGenerator.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,8 +48,9 @@
 public class DSAKeyPairGenerator extends KeyPairGenerator
 implements java.security.interfaces.DSAKeyPairGenerator {
 
-    /* The modulus length */
-    private int modlen;
+    /* Length for prime P and subPrime Q in bits */
+    private int plen;
+    private int qlen;
 
     /* whether to force new parameters to be generated for each KeyPair */
     private boolean forceNewParameters;
@@ -65,20 +66,23 @@
         initialize(1024, null);
     }
 
-    private static void checkStrength(int strength) {
-        if ((strength < 512) || (strength > 1024) || (strength % 64 != 0)) {
+    private static void checkStrength(int sizeP, int sizeQ) {
+        if ((sizeP >= 512) && (sizeP <= 1024) && (sizeP % 64 == 0)
+            && sizeQ == 160) {
+            // traditional - allow for backward compatibility
+            // L=multiples of 64 and between 512 and 1024 (inclusive)
+            // N=160
+        } else if (sizeP == 2048 && (sizeQ == 224 || sizeQ == 256)) {
+            // L=2048, N=224 or 256
+        } else {
             throw new InvalidParameterException
-                ("Modulus size must range from 512 to 1024 "
-                 + "and be a multiple of 64");
+                ("Unsupported prime and subprime size combination: " +
+                 sizeP + ", " + sizeQ);
         }
     }
 
     public void initialize(int modlen, SecureRandom random) {
-        checkStrength(modlen);
-        this.random = random;
-        this.modlen = modlen;
-        this.params = null;
-        this.forceNewParameters = false;
+        initialize(modlen, false, random);
     }
 
     /**
@@ -86,18 +90,27 @@
      * is false, a set of pre-computed parameters is used.
      */
     public void initialize(int modlen, boolean genParams, SecureRandom random) {
-        checkStrength(modlen);
+        int subPrimeLen = -1;
+        if (modlen <= 1024) {
+            subPrimeLen = 160;
+        } else if (modlen == 2048) {
+            subPrimeLen = 224;
+        }
+        checkStrength(modlen, subPrimeLen);
         if (genParams) {
             params = null;
         } else {
-            params = ParameterCache.getCachedDSAParameterSpec(modlen);
+            params = ParameterCache.getCachedDSAParameterSpec(modlen,
+                subPrimeLen);
             if (params == null) {
                 throw new InvalidParameterException
                     ("No precomputed parameters for requested modulus size "
                      + "available");
             }
+
         }
-        this.modlen = modlen;
+        this.plen = modlen;
+        this.qlen = subPrimeLen;
         this.random = random;
         this.forceNewParameters = genParams;
     }
@@ -136,9 +149,11 @@
     }
 
     private void initialize0(DSAParameterSpec params, SecureRandom random) {
-        int modlen = params.getP().bitLength();
-        checkStrength(modlen);
-        this.modlen = modlen;
+        int sizeP = params.getP().bitLength();
+        int sizeQ = params.getQ().bitLength();
+        checkStrength(sizeP, sizeQ);
+        this.plen = sizeP;
+        this.qlen = sizeQ;
         this.params = params;
         this.random = random;
         this.forceNewParameters = false;
@@ -156,11 +171,11 @@
         try {
             if (forceNewParameters) {
                 // generate new parameters each time
-                spec = ParameterCache.getNewDSAParameterSpec(modlen, random);
+                spec = ParameterCache.getNewDSAParameterSpec(plen, qlen, random);
             } else {
                 if (params == null) {
                     params =
-                        ParameterCache.getDSAParameterSpec(modlen, random);
+                        ParameterCache.getDSAParameterSpec(plen, qlen, random);
                 }
                 spec = params;
             }
@@ -203,43 +218,14 @@
      */
     private BigInteger generateX(SecureRandom random, BigInteger q) {
         BigInteger x = null;
+        byte[] temp = new byte[qlen];
         while (true) {
-            int[] seed = new int[5];
-            for (int i = 0; i < 5; i++) {
-                seed[i] = random.nextInt();
-            }
-            x = generateX(seed, q);
+            random.nextBytes(temp);
+            x = new BigInteger(1, temp).mod(q);
             if (x.signum() > 0 && (x.compareTo(q) < 0)) {
-                break;
+                return x;
             }
         }
-        return x;
-    }
-
-    /**
-     * Given a seed, generate the private key component of the key
-     * pair. In the terminology used in the DSA specification
-     * (FIPS-186) seed is the XSEED quantity.
-     *
-     * @param seed the seed to use to generate the private key.
-     */
-    BigInteger generateX(int[] seed, BigInteger q) {
-
-        // check out t in the spec.
-        int[] t = { 0x67452301, 0xEFCDAB89, 0x98BADCFE,
-                    0x10325476, 0xC3D2E1F0 };
-        //
-
-        int[] tmp = DSA.SHA_7(seed, t);
-        byte[] tmpBytes = new byte[tmp.length * 4];
-        for (int i = 0; i < tmp.length; i++) {
-            int k = tmp[i];
-            for (int j = 0; j < 4; j++) {
-                tmpBytes[(i * 4) + j] = (byte) (k >>> (24 - (j * 8)));
-            }
-        }
-        BigInteger x = new BigInteger(1, tmpBytes).mod(q);
-        return x;
     }
 
     /**
--- a/jdk/src/share/classes/sun/security/provider/DSAParameterGenerator.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/provider/DSAParameterGenerator.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,10 +32,12 @@
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
 import java.security.InvalidParameterException;
+import java.security.MessageDigest;
 import java.security.SecureRandom;
 import java.security.spec.AlgorithmParameterSpec;
 import java.security.spec.InvalidParameterSpecException;
 import java.security.spec.DSAParameterSpec;
+import java.security.spec.DSAGenParameterSpec;
 
 /**
  * This class generates parameters for the DSA algorithm. It uses a default
@@ -54,8 +56,14 @@
 
 public class DSAParameterGenerator extends AlgorithmParameterGeneratorSpi {
 
-    // the modulus length
-    private int modLen = 1024; // default
+    // the default parameters
+    private static final DSAGenParameterSpec DEFAULTS =
+        new DSAGenParameterSpec(1024, 160, 160);
+
+    // the length of prime P, subPrime Q, and seed in bits
+    private int valueL = -1;
+    private int valueN = -1;
+    private int seedLen = -1;
 
     // the source of randomness
     private SecureRandom random;
@@ -65,11 +73,7 @@
     private static final BigInteger ONE = BigInteger.valueOf(1);
     private static final BigInteger TWO = BigInteger.valueOf(2);
 
-    // Make a SHA-1 hash function
-    private SHA sha;
-
     public DSAParameterGenerator() {
-        this.sha = new SHA();
     }
 
     /**
@@ -80,19 +84,18 @@
      * @param random the source of randomness
      */
     protected void engineInit(int strength, SecureRandom random) {
-        /*
-         * Bruce Schneier, "Applied Cryptography", 2nd Edition,
-         * Description of DSA:
-         * [...] The algorithm uses the following parameter:
-         * p=a prime number L bits long, when L ranges from 512 to 1024 and is
-         * a multiple of 64. [...]
-         */
-        if ((strength < 512) || (strength > 1024) || (strength % 64 != 0)) {
+        if ((strength >= 512) && (strength <= 1024) && (strength % 64 == 0)) {
+            this.valueN = 160;
+        } else if (strength == 2048) {
+            this.valueN = 224;
+//      } else if (strength == 3072) {
+//          this.valueN = 256;
+        } else {
             throw new InvalidParameterException
-                ("Prime size must range from 512 to 1024 "
-                 + "and be a multiple of 64");
+                ("Prime size should be 512 - 1024, or 2048");
         }
-        this.modLen = strength;
+        this.valueL = strength;
+        this.seedLen = valueN;
         this.random = random;
     }
 
@@ -100,7 +103,7 @@
      * Initializes this parameter generator with a set of
      * algorithm-specific parameter generation values.
      *
-     * @param params the set of algorithm-specific parameter generation values
+     * @param genParamSpec the set of algorithm-specific parameter generation values
      * @param random the source of randomness
      *
      * @exception InvalidAlgorithmParameterException if the given parameter
@@ -109,7 +112,19 @@
     protected void engineInit(AlgorithmParameterSpec genParamSpec,
                               SecureRandom random)
         throws InvalidAlgorithmParameterException {
+        if (!(genParamSpec instanceof DSAGenParameterSpec)) {
             throw new InvalidAlgorithmParameterException("Invalid parameter");
+        }
+        DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec) genParamSpec;
+        if (dsaGenParams.getPrimePLength() > 2048) {
+            throw new InvalidParameterException
+                ("Prime size should be 512 - 1024, or 2048");
+        }
+        // directly initialize using the already validated values
+        this.valueL = dsaGenParams.getPrimePLength();
+        this.valueN = dsaGenParams.getSubprimeQLength();
+        this.seedLen = dsaGenParams.getSeedLength();
+        this.random = random;
     }
 
     /**
@@ -123,15 +138,21 @@
             if (this.random == null) {
                 this.random = new SecureRandom();
             }
-
-            BigInteger[] pAndQ = generatePandQ(this.random, this.modLen);
+            if (valueL == -1) {
+                try {
+                    engineInit(DEFAULTS, this.random);
+                } catch (InvalidAlgorithmParameterException iape) {
+                    // should never happen
+                }
+            }
+            BigInteger[] pAndQ = generatePandQ(this.random, valueL,
+                                               valueN, seedLen);
             BigInteger paramP = pAndQ[0];
             BigInteger paramQ = pAndQ[1];
             BigInteger paramG = generateG(paramP, paramQ);
 
-            DSAParameterSpec dsaParamSpec = new DSAParameterSpec(paramP,
-                                                                 paramQ,
-                                                                 paramG);
+            DSAParameterSpec dsaParamSpec =
+                new DSAParameterSpec(paramP, paramQ, paramG);
             algParams = AlgorithmParameters.getInstance("DSA", "SUN");
             algParams.init(dsaParamSpec);
         } catch (InvalidParameterSpecException e) {
@@ -156,102 +177,98 @@
      *
      * @param random the source of randomness to generate the
      * seed
-     * @param L the size of <code>p</code>, in bits.
+     * @param valueL the size of <code>p</code>, in bits.
+     * @param valueN the size of <code>q</code>, in bits.
+     * @param seedLen the length of <code>seed</code>, in bits.
      *
      * @return an array of BigInteger, with <code>p</code> at index 0 and
-     * <code>q</code> at index 1.
+     * <code>q</code> at index 1, the seed at index 2, and the counter value
+     * at index 3.
      */
-    BigInteger[] generatePandQ(SecureRandom random, int L) {
-        BigInteger[] result = null;
-        byte[] seed = new byte[20];
-
-        while(result == null) {
-            for (int i = 0; i < 20; i++) {
-                seed[i] = (byte)random.nextInt();
-            }
-            result = generatePandQ(seed, L);
+    private static BigInteger[] generatePandQ(SecureRandom random, int valueL,
+                                              int valueN, int seedLen) {
+        String hashAlg = null;
+        if (valueN == 160) {
+            hashAlg = "SHA";
+        } else if (valueN == 224) {
+            hashAlg = "SHA-224";
+        } else if (valueN == 256) {
+            hashAlg = "SHA-256";
         }
-        return result;
-    }
+        MessageDigest hashObj = null;
+        try {
+            hashObj = MessageDigest.getInstance(hashAlg);
+        } catch (NoSuchAlgorithmException nsae) {
+            // should never happen
+            nsae.printStackTrace();
+        }
 
-    /*
-     * Generates the prime and subprime parameters for DSA.
-     *
-     * <p>The seed parameter corresponds to the <code>SEED</code> parameter
-     * referenced in the FIPS specification of the DSA algorithm,
-     * and L is the size of <code>p</code>, in bits.
-     *
-     * @param seed the seed to generate the parameters
-     * @param L the size of <code>p</code>, in bits.
-     *
-     * @return an array of BigInteger, with <code>p</code> at index 0,
-     * <code>q</code> at index 1, the seed at index 2, and the counter value
-     * at index 3, or null if the seed does not yield suitable numbers.
-     */
-    BigInteger[] generatePandQ(byte[] seed, int L) {
+        /* Step 3, 4: Useful variables */
+        int outLen = hashObj.getDigestLength()*8;
+        int n = (valueL - 1) / outLen;
+        int b = (valueL - 1) % outLen;
+        byte[] seedBytes = new byte[seedLen/8];
+        BigInteger twoSl = TWO.pow(seedLen);
+        int primeCertainty = 80; // for 1024-bit prime P
+        if (valueL == 2048) {
+            primeCertainty = 112;
+            //} else if (valueL == 3072) {
+            //    primeCertainty = 128;
+        }
 
-        /* Useful variables */
-        int g = seed.length * 8;
-        int n = (L - 1) / 160;
-        int b = (L - 1) % 160;
-
-        BigInteger SEED = new BigInteger(1, seed);
-        BigInteger TWOG = TWO.pow(2 * g);
-
-        /* Step 2 (Step 1 is getting seed). */
-        byte[] U1 = SHA(seed);
-        byte[] U2 = SHA(toByteArray((SEED.add(ONE)).mod(TWOG)));
-
-        xor(U1, U2);
-        byte[] U = U1;
+        BigInteger resultP, resultQ, seed = null;
+        int counter;
+        while (true) {
+            do {
+                /* Step 5 */
+                random.nextBytes(seedBytes);
+                seed = new BigInteger(1, seedBytes);
 
-        /* Step 3: For q by setting the msb and lsb to 1 */
-        U[0] |= 0x80;
-        U[19] |= 1;
-        BigInteger q = new BigInteger(1, U);
-
-        /* Step 5 */
-         if (!q.isProbablePrime(80)) {
-             return null;
+                /* Step 6 */
+                BigInteger U = new BigInteger(1, hashObj.digest(seedBytes)).
+                    mod(TWO.pow(valueN - 1));
 
-         } else {
-             BigInteger V[] = new BigInteger[n + 1];
-             BigInteger offset = TWO;
-
-             /* Step 6 */
-             for (int counter = 0; counter < 4096; counter++) {
-
-                 /* Step 7 */
-                 for (int k = 0; k <= n; k++) {
-                     BigInteger K = BigInteger.valueOf(k);
-                     BigInteger tmp = (SEED.add(offset).add(K)).mod(TWOG);
-                     V[k] = new BigInteger(1, SHA(toByteArray(tmp)));
-                 }
+                /* Step 7 */
+                resultQ = TWO.pow(valueN - 1).add(U).add(ONE). subtract(U.mod(TWO));
+            } while (!resultQ.isProbablePrime(primeCertainty));
 
-                 /* Step 8 */
-                 BigInteger W = V[0];
-                 for (int i = 1; i < n; i++) {
-                     W = W.add(V[i].multiply(TWO.pow(i * 160)));
-                 }
-                 W = W.add((V[n].mod(TWO.pow(b))).multiply(TWO.pow(n * 160)));
-
-                 BigInteger TWOLm1 = TWO.pow(L - 1);
-                 BigInteger X = W.add(TWOLm1);
+            /* Step 10 */
+            BigInteger offset = ONE;
+            /* Step 11 */
+            for (counter = 0; counter < 4*valueL; counter++) {
+                BigInteger V[] = new BigInteger[n + 1];
+                /* Step 11.1 */
+                for (int j = 0; j <= n; j++) {
+                    BigInteger J = BigInteger.valueOf(j);
+                    BigInteger tmp = (seed.add(offset).add(J)).mod(twoSl);
+                    byte[] vjBytes = hashObj.digest(toByteArray(tmp));
+                    V[j] = new BigInteger(1, vjBytes);
+                }
+                /* Step 11.2 */
+                BigInteger W = V[0];
+                for (int i = 1; i < n; i++) {
+                    W = W.add(V[i].multiply(TWO.pow(i * outLen)));
+                }
+                W = W.add((V[n].mod(TWO.pow(b))).multiply(TWO.pow(n * outLen)));
+                /* Step 11.3 */
+                BigInteger twoLm1 = TWO.pow(valueL - 1);
+                BigInteger X = W.add(twoLm1);
+                /* Step 11.4, 11.5 */
+                BigInteger c = X.mod(resultQ.multiply(TWO));
+                resultP = X.subtract(c.subtract(ONE));
+                /* Step 11.6, 11.7 */
+                if (resultP.compareTo(twoLm1) > -1
+                    && resultP.isProbablePrime(primeCertainty)) {
+                    /* Step 11.8 */
+                    BigInteger[] result = {resultP, resultQ, seed,
+                                           BigInteger.valueOf(counter)};
+                    return result;
+                }
+                /* Step 11.9 */
+                offset = offset.add(BigInteger.valueOf(n)).add(ONE);
+             }
+        }
 
-                 /* Step 9 */
-                 BigInteger c = X.mod(q.multiply(TWO));
-                 BigInteger p = X.subtract(c.subtract(ONE));
-
-                 /* Step 10 - 13 */
-                 if (p.compareTo(TWOLm1) > -1 && p.isProbablePrime(80)) {
-                     BigInteger[] result = {p, q, SEED,
-                                            BigInteger.valueOf(counter)};
-                     return result;
-                 }
-                 offset = offset.add(BigInteger.valueOf(n)).add(ONE);
-             }
-             return null;
-         }
     }
 
     /*
@@ -262,31 +279,24 @@
      *
      * @param the <code>g</code>
      */
-    BigInteger generateG(BigInteger p, BigInteger q) {
+    private static BigInteger generateG(BigInteger p, BigInteger q) {
         BigInteger h = ONE;
+        /* Step 1 */
         BigInteger pMinusOneOverQ = (p.subtract(ONE)).divide(q);
-        BigInteger g = ONE;
-        while (g.compareTo(TWO) < 0) {
-            g = h.modPow(pMinusOneOverQ, p);
+        BigInteger resultG = ONE;
+        while (resultG.compareTo(TWO) < 0) {
+            /* Step 3 */
+            resultG = h.modPow(pMinusOneOverQ, p);
             h = h.add(ONE);
         }
-        return g;
-    }
-
-    /*
-     * Returns the SHA-1 digest of some data
-     */
-    private byte[] SHA(byte[] array) {
-        sha.engineReset();
-        sha.engineUpdate(array, 0, array.length);
-        return sha.engineDigest();
+        return resultG;
     }
 
     /*
      * Converts the result of a BigInteger.toByteArray call to an exact
      * signed magnitude representation for any positive number.
      */
-    private byte[] toByteArray(BigInteger bigInt) {
+    private static byte[] toByteArray(BigInteger bigInt) {
         byte[] result = bigInt.toByteArray();
         if (result[0] == 0) {
             byte[] tmp = new byte[result.length - 1];
@@ -295,13 +305,4 @@
         }
         return result;
     }
-
-    /*
-     * XORs U2 into U1
-     */
-    private void xor(byte[] U1, byte[] U2) {
-        for (int i = 0; i < U1.length; i++) {
-            U1[i] ^= U2[i];
-        }
-    }
 }
--- a/jdk/src/share/classes/sun/security/provider/ParameterCache.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/provider/ParameterCache.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package sun.security.provider;
 
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 import java.math.BigInteger;
 
 import java.security.*;
@@ -55,11 +56,17 @@
     private final static Map<Integer,DHParameterSpec> dhCache;
 
     /**
-     * Return cached DSA parameters for the given keylength, or null if none
-     * are available in the cache.
+     * Return cached DSA parameters for the given length combination of
+     * prime and subprime, or null if none are available in the cache.
      */
-    public static DSAParameterSpec getCachedDSAParameterSpec(int keyLength) {
-        return dsaCache.get(Integer.valueOf(keyLength));
+    public static DSAParameterSpec getCachedDSAParameterSpec(int primeLen,
+            int subprimeLen) {
+        // ensure the sum is unique in all cases, i.e.
+        // case#1: (512 <= p <= 1024) AND q=160
+        // case#2: p=2048 AND q=224
+        // case#3: p=2048 AND q=256
+        // (NOT-YET-SUPPORTED)case#4: p=3072 AND q=256
+        return dsaCache.get(Integer.valueOf(primeLen+subprimeLen));
     }
 
     /**
@@ -71,18 +78,39 @@
     }
 
     /**
-     * Return DSA parameters for the given keylength. Uses cache if possible,
-     * generates new parameters and adds them to the cache otherwise.
+     * Return DSA parameters for the given primeLen. Uses cache if
+     * possible, generates new parameters and adds them to the cache
+     * otherwise.
      */
-    public static DSAParameterSpec getDSAParameterSpec(int keyLength,
+    public static DSAParameterSpec getDSAParameterSpec(int primeLen,
             SecureRandom random)
-            throws NoSuchAlgorithmException, InvalidParameterSpecException {
-        DSAParameterSpec spec = getCachedDSAParameterSpec(keyLength);
+            throws NoSuchAlgorithmException, InvalidParameterSpecException,
+                   InvalidAlgorithmParameterException {
+        if (primeLen <= 1024) {
+            return getDSAParameterSpec(primeLen, 160, random);
+        } else if (primeLen == 2048) {
+            return getDSAParameterSpec(primeLen, 224, random);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Return DSA parameters for the given primeLen and subprimeLen.
+     * Uses cache if possible, generates new parameters and adds them to the
+     * cache otherwise.
+     */
+    public static DSAParameterSpec getDSAParameterSpec(int primeLen,
+            int subprimeLen, SecureRandom random)
+            throws NoSuchAlgorithmException, InvalidParameterSpecException,
+                   InvalidAlgorithmParameterException {
+        DSAParameterSpec spec =
+            getCachedDSAParameterSpec(primeLen, subprimeLen);
         if (spec != null) {
             return spec;
         }
-        spec = getNewDSAParameterSpec(keyLength, random);
-        dsaCache.put(Integer.valueOf(keyLength), spec);
+        spec = getNewDSAParameterSpec(primeLen, subprimeLen, random);
+        dsaCache.put(Integer.valueOf(primeLen + subprimeLen), spec);
         return spec;
     }
 
@@ -107,28 +135,28 @@
     }
 
     /**
-     * Return new DSA parameters for the given keylength. Do not lookup in
-     * cache and do not cache the newly generated parameters. This method
-     * really only exists for the legacy method
+     * Return new DSA parameters for the given length combination of prime and
+     * sub prime. Do not lookup in cache and do not cache the newly generated
+     * parameters. This method really only exists for the legacy method
      * DSAKeyPairGenerator.initialize(int, boolean, SecureRandom).
      */
-    public static DSAParameterSpec getNewDSAParameterSpec(int keyLength,
-            SecureRandom random)
-            throws NoSuchAlgorithmException, InvalidParameterSpecException {
+    public static DSAParameterSpec getNewDSAParameterSpec(int primeLen,
+            int subprimeLen, SecureRandom random)
+            throws NoSuchAlgorithmException, InvalidParameterSpecException,
+                   InvalidAlgorithmParameterException {
         AlgorithmParameterGenerator gen =
                 AlgorithmParameterGenerator.getInstance("DSA");
-        gen.init(keyLength, random);
+        DSAGenParameterSpec genParams =
+            new DSAGenParameterSpec(primeLen, subprimeLen);
+        gen.init(genParams, random);
         AlgorithmParameters params = gen.generateParameters();
         DSAParameterSpec spec = params.getParameterSpec(DSAParameterSpec.class);
         return spec;
     }
 
     static {
-        // XXX change to ConcurrentHashMap once available
-        dhCache = Collections.synchronizedMap
-                        (new HashMap<Integer,DHParameterSpec>());
-        dsaCache = Collections.synchronizedMap
-                        (new HashMap<Integer,DSAParameterSpec>());
+        dhCache = new ConcurrentHashMap<Integer,DHParameterSpec>();
+        dsaCache = new ConcurrentHashMap<Integer,DSAParameterSpec>();
 
         /*
          * We support precomputed parameter for 512, 768 and 1024 bit
@@ -210,17 +238,99 @@
                            "83dfe15ae59f06928b665e807b552564014c3bfecf" +
                            "492a", 16);
 
-        dsaCache.put(Integer.valueOf(512),
+        dsaCache.put(Integer.valueOf(512+160),
                                 new DSAParameterSpec(p512, q512, g512));
-        dsaCache.put(Integer.valueOf(768),
+        dsaCache.put(Integer.valueOf(768+160),
                                 new DSAParameterSpec(p768, q768, g768));
-        dsaCache.put(Integer.valueOf(1024),
+        dsaCache.put(Integer.valueOf(1024+160),
                                 new DSAParameterSpec(p1024, q1024, g1024));
+        /*
+         * L = 2048, N = 224
+         * SEED = 584236080cfa43c09b02354135f4cc5198a19efada08bd866d601ba4
+         * counter = 2666
+         */
+        BigInteger p2048_224 =
+            new BigInteger("8f7935d9b9aae9bfabed887acf4951b6f32ec59e3b" +
+                           "af3718e8eac4961f3efd3606e74351a9c4183339b8" +
+                           "09e7c2ae1c539ba7475b85d011adb8b47987754984" +
+                           "695cac0e8f14b3360828a22ffa27110a3d62a99345" +
+                           "3409a0fe696c4658f84bdd20819c3709a01057b195" +
+                           "adcd00233dba5484b6291f9d648ef883448677979c" +
+                           "ec04b434a6ac2e75e9985de23db0292fc1118c9ffa" +
+                           "9d8181e7338db792b730d7b9e349592f6809987215" +
+                           "3915ea3d6b8b4653c633458f803b32a4c2e0f27290" +
+                           "256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea1" +
+                           "43de4b66ff04903ed5cf1623e158d487c608e97f21" +
+                           "1cd81dca23cb6e380765f822e342be484c05763939" +
+                           "601cd667", 16);
+
+        BigInteger q2048_224 =
+            new BigInteger("baf696a68578f7dfdee7fa67c977c785ef32b233ba" +
+                           "e580c0bcd5695d", 16);
+
+        BigInteger g2048_224 =
+            new BigInteger("16a65c58204850704e7502a39757040d34da3a3478" +
+                           "c154d4e4a5c02d242ee04f96e61e4bd0904abdac8f" +
+                           "37eeb1e09f3182d23c9043cb642f88004160edf9ca" +
+                           "09b32076a79c32a627f2473e91879ba2c4e744bd20" +
+                           "81544cb55b802c368d1fa83ed489e94e0fa0688e32" +
+                           "428a5c78c478c68d0527b71c9a3abb0b0be12c4468" +
+                           "9639e7d3ce74db101a65aa2b87f64c6826db3ec72f" +
+                           "4b5599834bb4edb02f7c90e9a496d3a55d535bebfc" +
+                           "45d4f619f63f3dedbb873925c2f224e07731296da8" +
+                           "87ec1e4748f87efb5fdeb75484316b2232dee553dd" +
+                           "af02112b0d1f02da30973224fe27aeda8b9d4b2922" +
+                           "d9ba8be39ed9e103a63c52810bc688b7e2ed4316e1" +
+                           "ef17dbde", 16);
+        dsaCache.put(Integer.valueOf(2048+224),
+                     new DSAParameterSpec(p2048_224, q2048_224, g2048_224));
+
+        /*
+         * L = 2048, N = 256
+         * SEED = b0b4417601b59cbc9d8ac8f935cadaec4f5fbb2f23785609ae466748d9b5a536
+         * counter = 497
+         */
+        BigInteger p2048_256 =
+            new BigInteger("95475cf5d93e596c3fcd1d902add02f427f5f3c721" +
+                           "0313bb45fb4d5bb2e5fe1cbd678cd4bbdd84c9836b" +
+                           "e1f31c0777725aeb6c2fc38b85f48076fa76bcd814" +
+                           "6cc89a6fb2f706dd719898c2083dc8d896f84062e2" +
+                           "c9c94d137b054a8d8096adb8d51952398eeca852a0" +
+                           "af12df83e475aa65d4ec0c38a9560d5661186ff98b" +
+                           "9fc9eb60eee8b030376b236bc73be3acdbd74fd61c" +
+                           "1d2475fa3077b8f080467881ff7e1ca56fee066d79" +
+                           "506ade51edbb5443a563927dbc4ba520086746175c" +
+                           "8885925ebc64c6147906773496990cb714ec667304" +
+                           "e261faee33b3cbdf008e0c3fa90650d97d3909c927" +
+                           "5bf4ac86ffcb3d03e6dfc8ada5934242dd6d3bcca2" +
+                           "a406cb0b", 16);
+
+        BigInteger q2048_256 =
+            new BigInteger("f8183668ba5fc5bb06b5981e6d8b795d30b8978d43" +
+                           "ca0ec572e37e09939a9773", 16);
+
+        BigInteger g2048_256 =
+            new BigInteger("42debb9da5b3d88cc956e08787ec3f3a09bba5f48b" +
+                           "889a74aaf53174aa0fbe7e3c5b8fcd7a53bef563b0" +
+                           "e98560328960a9517f4014d3325fc7962bf1e04937" +
+                           "0d76d1314a76137e792f3f0db859d095e4a5b93202" +
+                           "4f079ecf2ef09c797452b0770e1350782ed57ddf79" +
+                           "4979dcef23cb96f183061965c4ebc93c9c71c56b92" +
+                           "5955a75f94cccf1449ac43d586d0beee43251b0b22" +
+                           "87349d68de0d144403f13e802f4146d882e057af19" +
+                           "b6f6275c6676c8fa0e3ca2713a3257fd1b27d0639f" +
+                           "695e347d8d1cf9ac819a26ca9b04cb0eb9b7b03598" +
+                           "8d15bbac65212a55239cfc7e58fae38d7250ab9991" +
+                           "ffbc97134025fe8ce04c4399ad96569be91a546f49" +
+                           "78693c7a", 16);
+        dsaCache.put(Integer.valueOf(2048+256),
+                                new DSAParameterSpec(p2048_256, q2048_256, g2048_256));
 
         // use DSA parameters for DH as well
         dhCache.put(Integer.valueOf(512), new DHParameterSpec(p512, g512));
         dhCache.put(Integer.valueOf(768), new DHParameterSpec(p768, g768));
         dhCache.put(Integer.valueOf(1024), new DHParameterSpec(p1024, g1024));
+        dhCache.put(Integer.valueOf(2048), new DHParameterSpec(p2048_224, g2048_224));
     }
 
 }
--- a/jdk/src/share/classes/sun/security/provider/SunEntries.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/provider/SunEntries.java	Tue Sep 25 11:48:00 2012 -0700
@@ -47,6 +47,10 @@
  *   SHA-2 family of hash functions includes SHA-224, SHA-256, SHA-384,
  *   and SHA-512.
  *
+ * - SHA-224withDSA/SHA-256withDSA are the signature schemes
+ *   described in FIPS 186-3. The associated object identifiers are
+ *   "OID.2.16.840.1.101.3.4.3.1", and "OID.2.16.840.1.101.3.4.3.2".
+
  * - DSA is the key generation scheme as described in FIPS 186.
  *   Aliases for DSA include the OID strings "OID.1.3.14.3.2.12"
  *   and "OID.1.2.840.10040.4.1".
@@ -106,11 +110,15 @@
         map.put("Signature.SHA1withDSA", "sun.security.provider.DSA$SHA1withDSA");
         map.put("Signature.NONEwithDSA", "sun.security.provider.DSA$RawDSA");
         map.put("Alg.Alias.Signature.RawDSA", "NONEwithDSA");
+        map.put("Signature.SHA224withDSA", "sun.security.provider.DSA$SHA224withDSA");
+        map.put("Signature.SHA256withDSA", "sun.security.provider.DSA$SHA256withDSA");
 
         String dsaKeyClasses = "java.security.interfaces.DSAPublicKey" +
                 "|java.security.interfaces.DSAPrivateKey";
         map.put("Signature.SHA1withDSA SupportedKeyClasses", dsaKeyClasses);
         map.put("Signature.NONEwithDSA SupportedKeyClasses", dsaKeyClasses);
+        map.put("Signature.SHA224withDSA SupportedKeyClasses", dsaKeyClasses);
+        map.put("Signature.SHA256withDSA SupportedKeyClasses", dsaKeyClasses);
 
         map.put("Alg.Alias.Signature.DSA", "SHA1withDSA");
         map.put("Alg.Alias.Signature.DSS", "SHA1withDSA");
@@ -124,6 +132,10 @@
         map.put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA");
         map.put("Alg.Alias.Signature.1.3.14.3.2.13", "SHA1withDSA");
         map.put("Alg.Alias.Signature.1.3.14.3.2.27", "SHA1withDSA");
+        map.put("Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.1", "SHA224withDSA");
+        map.put("Alg.Alias.Signature.2.16.840.1.101.3.4.3.1", "SHA224withDSA");
+        map.put("Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.2", "SHA256withDSA");
+        map.put("Alg.Alias.Signature.2.16.840.1.101.3.4.3.2", "SHA256withDSA");
 
         /*
          *  Key Pair Generator engines
@@ -143,6 +155,8 @@
 
         map.put("Alg.Alias.MessageDigest.SHA-1", "SHA");
         map.put("Alg.Alias.MessageDigest.SHA1", "SHA");
+        map.put("Alg.Alias.MessageDigest.1.3.14.3.2.26", "SHA");
+        map.put("Alg.Alias.MessageDigest.OID.1.3.14.3.2.26", "SHA");
 
         map.put("MessageDigest.SHA-224", "sun.security.provider.SHA2$SHA224");
         map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.4", "SHA-224");
@@ -169,15 +183,17 @@
          */
         map.put("AlgorithmParameters.DSA",
             "sun.security.provider.DSAParameters");
+        map.put("Alg.Alias.AlgorithmParameters.OID.1.2.840.10040.4.1", "DSA");
+        map.put("Alg.Alias.AlgorithmParameters.1.2.840.10040.4.1", "DSA");
         map.put("Alg.Alias.AlgorithmParameters.1.3.14.3.2.12", "DSA");
-        map.put("Alg.Alias.AlgorithmParameters.1.2.840.10040.4.1", "DSA");
 
         /*
          * Key factories
          */
         map.put("KeyFactory.DSA", "sun.security.provider.DSAKeyFactory");
+        map.put("Alg.Alias.KeyFactory.OID.1.2.840.10040.4.1", "DSA");
+        map.put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA");
         map.put("Alg.Alias.KeyFactory.1.3.14.3.2.12", "DSA");
-        map.put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA");
 
         /*
          * Certificates
@@ -234,9 +250,13 @@
         /*
          * KeySize
          */
+        map.put("Signature.NONEwithDSA KeySize", "1024");
         map.put("Signature.SHA1withDSA KeySize", "1024");
-        map.put("KeyPairGenerator.DSA KeySize", "1024");
-        map.put("AlgorithmParameterGenerator.DSA KeySize", "1024");
+        map.put("Signature.SHA224withDSA KeySize", "2048");
+        map.put("Signature.SHA256withDSA KeySize", "2048");
+
+        map.put("KeyPairGenerator.DSA KeySize", "2048");
+        map.put("AlgorithmParameterGenerator.DSA KeySize", "2048");
 
         /*
          * Implementation type: software or hardware
--- a/jdk/src/share/classes/sun/security/x509/AlgorithmId.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/classes/sun/security/x509/AlgorithmId.java	Tue Sep 25 11:48:00 2012 -0700
@@ -120,21 +120,14 @@
         try {
             algParams = AlgorithmParameters.getInstance(algidString);
         } catch (NoSuchAlgorithmException e) {
-            try {
-                // Try the internal EC code so that we can fully parse EC
-                // keys even if the provider is not registered.
-                // This code can go away once we have EC in the SUN provider.
-                algParams = AlgorithmParameters.getInstance(algidString,
-                                sun.security.ec.ECKeyFactory.ecInternalProvider);
-            } catch (NoSuchAlgorithmException ee) {
-                /*
-                 * This algorithm parameter type is not supported, so we cannot
-                 * parse the parameters.
-                 */
-                algParams = null;
-                return;
-            }
+            /*
+             * This algorithm parameter type is not supported, so we cannot
+             * parse the parameters.
+             */
+            algParams = null;
+            return;
         }
+
         // Decode (parse) the parameters
         algParams.init(params.toByteArray());
     }
@@ -505,6 +498,9 @@
         if (name.equalsIgnoreCase("EC")) {
             return EC_oid;
         }
+        if (name.equalsIgnoreCase("ECDH")) {
+            return AlgorithmId.ECDH_oid;
+        }
 
         // Common signature types
         if (name.equalsIgnoreCase("MD5withRSA")
@@ -524,6 +520,12 @@
             || name.equalsIgnoreCase("SHA-1/DSA")) {
             return AlgorithmId.sha1WithDSA_oid;
         }
+        if (name.equalsIgnoreCase("SHA224WithDSA")) {
+            return AlgorithmId.sha224WithDSA_oid;
+        }
+        if (name.equalsIgnoreCase("SHA256WithDSA")) {
+            return AlgorithmId.sha256WithDSA_oid;
+        }
         if (name.equalsIgnoreCase("SHA1WithRSA")
             || name.equalsIgnoreCase("SHA1/RSA")) {
             return AlgorithmId.sha1WithRSAEncryption_oid;
@@ -654,6 +656,7 @@
     public static final ObjectIdentifier DSA_oid;
     public static final ObjectIdentifier DSA_OIW_oid;
     public static final ObjectIdentifier EC_oid = oid(1, 2, 840, 10045, 2, 1);
+    public static final ObjectIdentifier ECDH_oid = oid(1, 3, 132, 1, 12);
     public static final ObjectIdentifier RSA_oid;
     public static final ObjectIdentifier RSAEncryption_oid;
 
@@ -694,6 +697,10 @@
     public static final ObjectIdentifier shaWithDSA_OIW_oid;
     public static final ObjectIdentifier sha1WithDSA_OIW_oid;
     public static final ObjectIdentifier sha1WithDSA_oid;
+    public static final ObjectIdentifier sha224WithDSA_oid =
+                                            oid(2, 16, 840, 1, 101, 3, 4, 3, 1);
+    public static final ObjectIdentifier sha256WithDSA_oid =
+                                            oid(2, 16, 840, 1, 101, 3, 4, 3, 2);
 
     public static final ObjectIdentifier sha1WithECDSA_oid =
                                             oid(1, 2, 840, 10045, 4, 1);
@@ -725,7 +732,6 @@
     public static ObjectIdentifier pbeWithSHA1AndRC2_40_oid =
         ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 6});
 
-
     static {
     /*
      * Note the preferred OIDs are named simply with no "OIW" or
@@ -885,6 +891,8 @@
         nameTable.put(DSA_oid, "DSA");
         nameTable.put(DSA_OIW_oid, "DSA");
         nameTable.put(EC_oid, "EC");
+        nameTable.put(ECDH_oid, "ECDH");
+
         nameTable.put(sha1WithECDSA_oid, "SHA1withECDSA");
         nameTable.put(sha224WithECDSA_oid, "SHA224withECDSA");
         nameTable.put(sha256WithECDSA_oid, "SHA256withECDSA");
@@ -895,6 +903,8 @@
         nameTable.put(sha1WithDSA_oid, "SHA1withDSA");
         nameTable.put(sha1WithDSA_OIW_oid, "SHA1withDSA");
         nameTable.put(shaWithDSA_OIW_oid, "SHA1withDSA");
+        nameTable.put(sha224WithDSA_oid, "SHA224withDSA");
+        nameTable.put(sha256WithDSA_oid, "SHA256withDSA");
         nameTable.put(sha1WithRSAEncryption_oid, "SHA1withRSA");
         nameTable.put(sha1WithRSAEncryption_OIW_oid, "SHA1withRSA");
         nameTable.put(sha224WithRSAEncryption_oid, "SHA224withRSA");
--- a/jdk/src/share/demo/applets/CardTest/example1.html	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/demo/applets/CardTest/example1.html	Tue Sep 25 11:48:00 2012 -0700
@@ -5,7 +5,7 @@
   <body>
       <h1>Card Test (1.1)</h1>
       <hr>
-      <applet code=CardTest.class width=400 height=300>
+      <applet code=CardTest.class width=455 height=300>
 	alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason."
 	Your browser is completely ignoring the &lt;APPLET&gt; tag!
       </applet>
--- a/jdk/src/share/demo/applets/DitherTest/example1.html	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/demo/applets/DitherTest/example1.html	Tue Sep 25 11:48:00 2012 -0700
@@ -5,7 +5,7 @@
   <body>
       <h1>Dither Test (1.1)</h1>
       <hr>
-      <applet code=DitherTest.class width=425 height=400>
+      <applet code=DitherTest.class width=455 height=400>
 	alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason."
 	Your browser is completely ignoring the &lt;APPLET&gt; tag!
       </applet>
--- a/jdk/src/share/demo/jvmti/hprof/debug_malloc.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/demo/jvmti/hprof/debug_malloc.h	Tue Sep 25 11:48:00 2012 -0700
@@ -59,6 +59,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* The real functions behind the macro curtains. */
 
 void           *debug_malloc(size_t, const char *, int);
@@ -71,10 +76,10 @@
 
 void            debug_malloc_verify(const char*, int);
 #undef malloc_verify
-#define malloc_verify()     debug_malloc_verify(__FILE__, __LINE__)
+#define malloc_verify()     debug_malloc_verify(THIS_FILE, __LINE__)
 
 void            debug_malloc_police(const char*, int);
 #undef malloc_police
-#define malloc_police()     debug_malloc_police(__FILE__, __LINE__)
+#define malloc_police()     debug_malloc_police(THIS_FILE, __LINE__)
 
 #endif
--- a/jdk/src/share/demo/jvmti/hprof/hprof_error.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/demo/jvmti/hprof/hprof_error.h	Tue Sep 25 11:48:00 2012 -0700
@@ -41,20 +41,25 @@
 #ifndef HPROF_ERROR_H
 #define HPROF_ERROR_H
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Macros over assert and error functions so we can capture the source loc. */
 
 #define HPROF_BOOL(x) ((jboolean)((x)==0?JNI_FALSE:JNI_TRUE))
 
 #define HPROF_ERROR(fatal,msg) \
-    error_handler(HPROF_BOOL(fatal), JVMTI_ERROR_NONE, msg, __FILE__, __LINE__)
+    error_handler(HPROF_BOOL(fatal), JVMTI_ERROR_NONE, msg, THIS_FILE, __LINE__)
 
 #define HPROF_JVMTI_ERROR(error,msg) \
     error_handler(HPROF_BOOL(error!=JVMTI_ERROR_NONE), \
-            error, msg, __FILE__, __LINE__)
+            error, msg, THIS_FILE, __LINE__)
 
 #if defined(DEBUG) || !defined(NDEBUG)
     #define HPROF_ASSERT(cond) \
-        (((int)(cond))?(void)0:error_assert(#cond, __FILE__, __LINE__))
+        (((int)(cond))?(void)0:error_assert(#cond, THIS_FILE, __LINE__))
 #else
     #define HPROF_ASSERT(cond)
 #endif
@@ -77,11 +82,11 @@
 #define LOG_FORMAT(format)      "HPROF LOG: " format " [%s:%d]\n"
 
 #define LOG1(str1)              LOG_STDERR((stderr, LOG_FORMAT("%s"), \
-                                    str1, __FILE__, __LINE__ ))
+                                    str1, THIS_FILE, __LINE__ ))
 #define LOG2(str1,str2)         LOG_STDERR((stderr, LOG_FORMAT("%s %s"), \
-                                    str1, str2, __FILE__, __LINE__ ))
+                                    str1, str2, THIS_FILE, __LINE__ ))
 #define LOG3(str1,str2,num)     LOG_STDERR((stderr, LOG_FORMAT("%s %s 0x%x"), \
-                                    str1, str2, num, __FILE__, __LINE__ ))
+                                    str1, str2, num, THIS_FILE, __LINE__ ))
 
 #define LOG(str) LOG1(str)
 
--- a/jdk/src/share/demo/jvmti/hprof/hprof_util.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/demo/jvmti/hprof/hprof_util.h	Tue Sep 25 11:48:00 2012 -0700
@@ -41,6 +41,11 @@
 #ifndef HPROF_UTIL_H
 #define HPROF_UTIL_H
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Macros that protect code from accidently using a local ref improperly */
 #define WITH_LOCAL_REFS(env, number)            \
     {                                           \
@@ -184,8 +189,8 @@
 #ifdef DEBUG
     void *        hprof_debug_malloc(int size, char *file, int line);
     void          hprof_debug_free(void *ptr, char *file, int line);
-    #define HPROF_MALLOC(size)  hprof_debug_malloc(size, __FILE__, __LINE__)
-    #define HPROF_FREE(ptr)     hprof_debug_free(ptr, __FILE__, __LINE__)
+    #define HPROF_MALLOC(size)  hprof_debug_malloc(size, THIS_FILE, __LINE__)
+    #define HPROF_FREE(ptr)     hprof_debug_free(ptr, THIS_FILE, __LINE__)
 #else
     #define HPROF_MALLOC(size)  hprof_malloc(size)
     #define HPROF_FREE(ptr)     hprof_free(ptr)
--- a/jdk/src/share/demo/jvmti/java_crw_demo/java_crw_demo.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/demo/jvmti/java_crw_demo/java_crw_demo.c	Tue Sep 25 11:48:00 2012 -0700
@@ -70,12 +70,20 @@
 
 /* Macros over error functions to capture line numbers */
 
-#define CRW_FATAL(ci, message) fatal_error(ci, message, __FILE__, __LINE__)
+/* Fatal error used in all builds. */
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE "java_crw.demo.c" /* Never use __FILE__ */
+#endif
+
+#define CRW_FATAL(ci, message) fatal_error(ci, message, THIS_FILE, __LINE__)
 
 #if defined(DEBUG) || !defined(NDEBUG)
 
+  /* This assert macro is only used in the debug builds. */
   #define CRW_ASSERT(ci, cond) \
-        ((cond)?(void)0:assert_error(ci, #cond, __FILE__, __LINE__))
+        ((cond)?(void)0:assert_error(ci, #cond, THIS_FILE, __LINE__))
 
 #else
 
--- a/jdk/src/share/instrument/JPLISAssert.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/instrument/JPLISAssert.h	Tue Sep 25 11:48:00 2012 -0700
@@ -49,10 +49,14 @@
 #define JPLISASSERT_ENABLEASSERTIONS    (0)
 #endif
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
 
 #if JPLISASSERT_ENABLEASSERTIONS
-#define jplis_assert(x)             JPLISAssertCondition((jboolean)(x), #x, __FILE__, __LINE__)
-#define jplis_assert_msg(x, msg)    JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, __FILE__, __LINE__)
+#define jplis_assert(x)             JPLISAssertCondition((jboolean)(x), #x, THIS_FILE, __LINE__)
+#define jplis_assert_msg(x, msg)    JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, THIS_FILE, __LINE__)
 #else
 #define jplis_assert(x)
 #define jplis_assert_msg(x, msg)
--- a/jdk/src/share/native/sun/awt/debug/debug_assert.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/native/sun/awt/debug/debug_assert.h	Tue Sep 25 11:48:00 2012 -0700
@@ -32,17 +32,22 @@
 
 #include "debug_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #if defined(DEBUG)
 
 #define DASSERT(_expr) \
         if ( !(_expr) ) { \
-            DAssert_Impl( #_expr, __FILE__, __LINE__); \
+            DAssert_Impl( #_expr, THIS_FILE, __LINE__); \
         } else { \
         }
 
 #define DASSERTMSG(_expr, _msg) \
         if ( !(_expr) ) { \
-            DAssert_Impl( (_msg), __FILE__, __LINE__); \
+            DAssert_Impl( (_msg), THIS_FILE, __LINE__); \
         } else { \
         }
 
--- a/jdk/src/share/native/sun/awt/debug/debug_mem.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/native/sun/awt/debug/debug_mem.c	Tue Sep 25 11:48:00 2012 -0700
@@ -27,6 +27,11 @@
 
 #include "debug_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define DMEM_MIN(a,b)   (a) < (b) ? (a) : (b)
 #define DMEM_MAX(a,b)   (a) > (b) ? (a) : (b)
 
@@ -291,7 +296,7 @@
     DMutex_Enter(DMemMutex);
 
     /* Force memory leaks to be output regardless of trace settings */
-    DTrace_EnableFile(__FILE__, TRUE);
+    DTrace_EnableFile(THIS_FILE, TRUE);
     DTRACE_PRINTLN("--------------------------");
     DTRACE_PRINTLN("Debug Memory Manager Leaks");
     DTRACE_PRINTLN("--------------------------");
--- a/jdk/src/share/native/sun/awt/debug/debug_trace.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/native/sun/awt/debug/debug_trace.h	Tue Sep 25 11:48:00 2012 -0700
@@ -34,6 +34,11 @@
 
 #include "debug_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 typedef int     dtrace_id;
 enum {
     UNDEFINED_TRACE_ID = -1 /* indicates trace point has not been registered yet */
@@ -69,7 +74,7 @@
 #define _DTrace_Template(_func, _ac, _f, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \
 { \
     static dtrace_id _dt_lineid_ = UNDEFINED_TRACE_ID; \
-    DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, __FILE__, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
+    DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, THIS_FILE, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
 }
 
 /* printf style trace macros */
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Tue Sep 25 11:48:00 2012 -0700
@@ -452,7 +452,12 @@
 void *p11malloc(size_t c, char *file, int line);
 void p11free(void *p, char *file, int line);
 
-#define malloc(c)       (p11malloc((c), __FILE__, __LINE__))
-#define free(c)         (p11free((c), __FILE__, __LINE__))
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
+#define malloc(c)       (p11malloc((c), THIS_FILE, __LINE__))
+#define free(c)         (p11free((c), THIS_FILE, __LINE__))
 
 #endif
--- a/jdk/src/share/npt/utf.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/npt/utf.h	Tue Sep 25 11:48:00 2012 -0700
@@ -33,8 +33,13 @@
 #include "jni.h"
 #include "utf_md.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Error and assert macros */
-#define UTF_ERROR(m) utfError(__FILE__, __LINE__,  m)
+#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__,  m)
 #define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
 
 void utfError(char *file, int line, char *message);
--- a/jdk/src/share/transport/shmem/shmemBase.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/share/transport/shmem/shmemBase.h	Tue Sep 25 11:48:00 2012 -0700
@@ -49,11 +49,16 @@
 jint shmemBase_name(SharedMemoryTransport *, char **name);
 jint shmemBase_getlasterror(char *msg, jint size);
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #ifdef DEBUG
 #define SHMEM_ASSERT(expression)  \
 do {                            \
     if (!(expression)) {                \
-        exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
+        exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
     } \
 } while (0)
 #else
@@ -63,7 +68,7 @@
 #define SHMEM_GUARANTEE(expression) \
 do {                            \
     if (!(expression)) {                \
-        exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
+        exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
     } \
 } while (0)
 
--- a/jdk/src/solaris/bin/jexec.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/bin/jexec.c	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -80,6 +80,7 @@
 #  include <sys/types.h>
 #  include <sys/stat.h>
 #  include <fcntl.h>
+#  include "jni.h"
 #  include "manifest_info.h"
 #endif
 
--- a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1001,6 +1001,13 @@
         switch (xev.get_type()) {
         case XConstants.ButtonPress:
             if (buttonState == 0) {
+                XWindowPeer parent = getToplevelXWindow();
+                // See 6385277, 6981400.
+                if (parent != null && parent.isFocusableWindow()) {
+                    // A click in a client area drops the actual focused window retaining.
+                    parent.setActualFocusedWindow(null);
+                    parent.requestWindowFocus(xbe.get_time(), true);
+                }
                 XAwtState.setAutoGrabWindow(this);
             }
             break;
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -588,33 +588,6 @@
 
     }
 
-    public void handleButtonPressRelease(XEvent xev) {
-        /*
-         * Fix for 6385277.
-         * We request focus on simple Window by click in order
-         * to make it behave like Frame/Dialog in this case and also to unify
-         * the behaviour with what we have on MS Windows.
-         * handleJavaMouseEvent() would be more suitable place to do this
-         * but we want Swing to have this functionality also.
-         */
-        if (xev.get_type() == XConstants.ButtonPress) {
-            final XWindowPeer parentXWindow = getParentTopLevel();
-            Window parentWindow = (Window)parentXWindow.getTarget();
-            if (parentXWindow.isFocusableWindow() && parentXWindow.isSimpleWindow() &&
-                XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() != parentWindow)
-            {
-                postEvent(new InvocationEvent(parentWindow, new  Runnable() {
-                        public void run() {
-                            // Request focus on the EDT of 'parentWindow' because
-                            // XDecoratedPeer.requestWindowFocus() calls client code.
-                            parentXWindow.requestXFocus();
-                        }
-                    }));
-            }
-        }
-        super.handleButtonPressRelease(xev);
-    }
-
     public Dimension getMinimumSize() {
         return target.getSize();
     }
--- a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1108,7 +1108,7 @@
         focusLog.fine("Request for decorated window focus");
         // If this is Frame or Dialog we can't assure focus request success - but we still can try
         // If this is Window and its owner Frame is active we can be sure request succedded.
-        Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
+        Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
         Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
 
         focusLog.finer("Current window is: active={0}, focused={1}",
@@ -1201,7 +1201,7 @@
     }
 
     public void handleWindowFocusOut(Window oppositeWindow, long serial) {
-        Window actualFocusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
+        Window actualFocusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
 
         // If the actual focused window is not this decorated window then retain it.
         if (actualFocusedWindow != null && actualFocusedWindow != target) {
--- a/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -135,7 +135,7 @@
      * Thus we don't have to perform any transitive (a blocker of a blocker) checks.
      */
     boolean isFocusedWindowModalBlocker() {
-        Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
+        Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
         XWindowPeer focusedWindowPeer = null;
 
         if (focusedWindow != null) {
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -96,11 +96,11 @@
     public void handleEvent(AWTEvent e) {
         switch (e.getID()) {
           case FocusEvent.FOCUS_GAINED:
-              XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(proxy);
+              XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(proxy);
               container.focusGained(handle);
               break;
           case FocusEvent.FOCUS_LOST:
-              XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
+              XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
               container.focusLost(handle);
               break;
           case KeyEvent.KEY_PRESSED:
@@ -172,7 +172,7 @@
         if (lightweightChild == null) {
             lightweightChild = (Component)proxy;
         }
-        Component currentOwner = XKeyboardFocusManagerPeer.getCurrentNativeFocusOwner();
+        Component currentOwner = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
         if (currentOwner != null && currentOwner.getPeer() == null) {
             currentOwner = null;
         }
@@ -224,7 +224,8 @@
               if (parent != null) {
                   Window parentWindow = (Window)parent;
                   // and check that it is focused
-                  if (!parentWindow.isFocused() && XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() == parentWindow) {
+                  if (!parentWindow.isFocused() &&
+                      XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() == parentWindow) {
                       // if it is not - skip requesting focus on Solaris
                       // but return true for compatibility.
                       return true;
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java	Tue Sep 25 11:48:00 2012 -0700
@@ -204,7 +204,7 @@
         // XEMBED_FOCUS_OUT client messages), so we first need to check if
         // embedded is an active window before sending WINDOW_LOST_FOCUS
         // to shared code
-        if (XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() == embedded.target) {
+        if (XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() == embedded.target) {
             embedded.handleWindowFocusOut(null, 0);
         }
     }
--- a/jdk/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -25,66 +25,48 @@
 package sun.awt.X11;
 
 import java.awt.Component;
-import java.awt.KeyboardFocusManager;
 import java.awt.Window;
-
-import java.awt.event.FocusEvent;
-
-import java.awt.peer.KeyboardFocusManagerPeer;
-import java.awt.peer.ComponentPeer;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
 import sun.util.logging.PlatformLogger;
-
 import sun.awt.CausedFocusEvent;
-import sun.awt.SunToolkit;
 import sun.awt.KeyboardFocusManagerPeerImpl;
 
 public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
     private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XKeyboardFocusManagerPeer");
+    private static final XKeyboardFocusManagerPeer inst = new XKeyboardFocusManagerPeer();
 
-    private static Object lock = new Object() {};
-    private static Component currentFocusOwner;
-    private static Window currentFocusedWindow;
+    private Component currentFocusOwner;
+    private Window currentFocusedWindow;
 
-    XKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
-        super(manager);
+    public static XKeyboardFocusManagerPeer getInstance() {
+        return inst;
+    }
+
+    private XKeyboardFocusManagerPeer() {
     }
 
     @Override
     public void setCurrentFocusOwner(Component comp) {
-        setCurrentNativeFocusOwner(comp);
+        synchronized (this) {
+            currentFocusOwner = comp;
+        }
     }
 
     @Override
     public Component getCurrentFocusOwner() {
-        return getCurrentNativeFocusOwner();
-    }
-
-    @Override
-    public Window getCurrentFocusedWindow() {
-        return getCurrentNativeFocusedWindow();
-    }
-
-    public static void setCurrentNativeFocusOwner(Component comp) {
-        synchronized (lock) {
-            currentFocusOwner = comp;
-        }
-    }
-
-    public static Component getCurrentNativeFocusOwner() {
-        synchronized(lock) {
+        synchronized(this) {
             return currentFocusOwner;
         }
     }
 
-    public static void setCurrentNativeFocusedWindow(Window win) {
-        if (focusLog.isLoggable(PlatformLogger.FINER)) focusLog.finer("Setting current native focused window " + win);
+    @Override
+    public void setCurrentFocusedWindow(Window win) {
+        if (focusLog.isLoggable(PlatformLogger.FINER)) {
+            focusLog.finer("Setting current focused window " + win);
+        }
+
         XWindowPeer from = null, to = null;
 
-        synchronized(lock) {
+        synchronized(this) {
             if (currentFocusedWindow != null) {
                 from = (XWindowPeer)currentFocusedWindow.getPeer();
             }
@@ -104,8 +86,9 @@
         }
     }
 
-    public static Window getCurrentNativeFocusedWindow() {
-        synchronized(lock) {
+    @Override
+    public Window getCurrentFocusedWindow() {
+        synchronized(this) {
             return currentFocusedWindow;
         }
     }
@@ -124,6 +107,6 @@
                                                          focusedWindowChangeAllowed,
                                                          time,
                                                          cause,
-                                                         getCurrentNativeFocusOwner());
+                                                         getInstance().getCurrentFocusOwner());
     }
 }
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Tue Sep 25 11:48:00 2012 -0700
@@ -663,7 +663,7 @@
                 long w = 0;
                 if (windowToXWindow(ev.get_xany().get_window()) != null) {
                     Component owner =
-                        XKeyboardFocusManagerPeer.getCurrentNativeFocusOwner();
+                        XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
                     if (owner != null) {
                         XWindow ownerWindow = (XWindow) AWTAccessor.getComponentAccessor().getPeer(owner);
                         if (ownerWindow != null) {
@@ -1155,9 +1155,8 @@
         return peer;
     }
 
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) throws HeadlessException {
-        XKeyboardFocusManagerPeer peer = new XKeyboardFocusManagerPeer(manager);
-        return peer;
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() throws HeadlessException {
+        return XKeyboardFocusManagerPeer.getInstance();
     }
 
     /**
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -617,7 +617,7 @@
 
     public void handleWindowFocusIn_Dispatch() {
         if (EventQueue.isDispatchThread()) {
-            XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
+            XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
             WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
             SunToolkit.setSystemGenerated(we);
             target.dispatchEvent(we);
@@ -626,7 +626,7 @@
 
     public void handleWindowFocusInSync(long serial) {
         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
         sendEvent(we);
     }
     // NOTE: This method may be called by privileged threads.
@@ -634,7 +634,7 @@
     public void handleWindowFocusIn(long serial) {
         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
         /* wrap in Sequenced, then post*/
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
         postEvent(wrapInSequenced((AWTEvent) we));
     }
 
@@ -642,15 +642,15 @@
     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
     public void handleWindowFocusOut(Window oppositeWindow, long serial) {
         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
         /* wrap in Sequenced, then post*/
         postEvent(wrapInSequenced((AWTEvent) we));
     }
     public void handleWindowFocusOutSync(Window oppositeWindow, long serial) {
         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null);
-        XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
+        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
         sendEvent(we);
     }
 
@@ -1138,7 +1138,7 @@
             // getWMState() always returns 0 (Withdrawn) for simple windows. Hence
             // we ignore the state for such windows.
             if (isVisible() && (state == XUtilConstants.NormalState || isSimpleWindow())) {
-                if (XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() ==
+                if (XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() ==
                         getTarget())
                 {
                     show = true;
@@ -1165,15 +1165,25 @@
     }
 
     public void dispose() {
+        if (isGrabbed()) {
+            if (grabLog.isLoggable(PlatformLogger.FINE)) {
+                grabLog.fine("Generating UngrabEvent on {0} because of the window disposal", this);
+            }
+            postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource()));
+        }
+
         SunToolkit.awtLock();
+
         try {
             windows.remove(this);
         } finally {
             SunToolkit.awtUnlock();
         }
+
         if (warningWindow != null) {
             warningWindow.destroy();
         }
+
         removeRootPropertyEventDispatcher();
         mustControlStackPosition = false;
         super.dispose();
@@ -1185,12 +1195,13 @@
          * receive WM_TAKE_FOCUS.
          */
         if (isSimpleWindow()) {
-            if (target == XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow()) {
+            if (target == XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow()) {
                 Window owner = getDecoratedOwner((Window)target);
                 ((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).requestWindowFocus();
             }
         }
     }
+
     boolean isResizable() {
         return winAttr.isResizable;
     }
@@ -1825,7 +1836,7 @@
         // If this is Frame or Dialog we can't assure focus request success - but we still can try
         // If this is Window and its owner Frame is active we can be sure request succedded.
         Window ownerWindow  = XWindowPeer.getDecoratedOwner((Window)target);
-        Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
+        Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
         Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
 
         if (isWMStateNetHidden()) {
--- a/jdk/src/solaris/instrument/EncodingSupport_md.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/solaris/instrument/EncodingSupport_md.c	Tue Sep 25 11:48:00 2012 -0700
@@ -33,8 +33,13 @@
 
 /* Routines to convert back and forth between Platform Encoding and UTF-8 */
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Error and assert macros */
-#define UTF_ERROR(m) utfError(__FILE__, __LINE__,  m)
+#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__,  m)
 #define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
 #define UTF_DEBUG(x)
 
--- a/jdk/src/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -25,7 +25,6 @@
 
 package sun.awt.windows;
 
-import java.awt.KeyboardFocusManager;
 import java.awt.Window;
 import java.awt.Component;
 import java.awt.peer.ComponentPeer;
@@ -37,8 +36,13 @@
     static native Component getNativeFocusOwner();
     static native Window getNativeFocusedWindow();
 
-    WKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
-        super(manager);
+    private static final WKeyboardFocusManagerPeer inst = new WKeyboardFocusManagerPeer();
+
+    public static WKeyboardFocusManagerPeer getInstance() {
+        return inst;
+    }
+
+    private WKeyboardFocusManagerPeer() {
     }
 
     @Override
@@ -52,6 +56,12 @@
     }
 
     @Override
+    public void setCurrentFocusedWindow(Window win) {
+        // Not used on Windows
+        throw new RuntimeException("not implemented");
+    }
+
+    @Override
     public Window getCurrentFocusedWindow() {
         return getNativeFocusedWindow();
     }
--- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java	Tue Sep 25 11:48:00 2012 -0700
@@ -506,10 +506,10 @@
         return true;
     }
 
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager)
+    public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
       throws HeadlessException
     {
-        return new WKeyboardFocusManagerPeer(manager);
+        return WKeyboardFocusManagerPeer.getInstance();
     }
 
     protected native void setDynamicLayoutNative(boolean b);
--- a/jdk/src/windows/native/com/sun/management/OperatingSystem_md.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/native/com/sun/management/OperatingSystem_md.c	Tue Sep 25 11:48:00 2012 -0700
@@ -100,18 +100,20 @@
 Java_com_sun_management_OperatingSystem_getTotalSwapSpaceSize
   (JNIEnv *env, jobject mbean)
 {
-    MEMORYSTATUS ms;
-    GlobalMemoryStatus(&ms);
-    return (jlong)ms.dwTotalPageFile;
+    MEMORYSTATUSEX ms;
+    ms.dwLength = sizeof(ms);
+    GlobalMemoryStatusEx(&ms);
+    return (jlong) ms.ullTotalPageFile;
 }
 
 JNIEXPORT jlong JNICALL
 Java_com_sun_management_OperatingSystem_getFreeSwapSpaceSize
   (JNIEnv *env, jobject mbean)
 {
-    MEMORYSTATUS ms;
-    GlobalMemoryStatus(&ms);
-    return (jlong)ms.dwAvailPageFile;
+    MEMORYSTATUSEX ms;
+    ms.dwLength = sizeof(ms);
+    GlobalMemoryStatusEx(&ms);
+    return (jlong) ms.ullAvailPageFile;
 }
 
 JNIEXPORT jlong JNICALL
@@ -137,21 +139,20 @@
 Java_com_sun_management_OperatingSystem_getFreePhysicalMemorySize
   (JNIEnv *env, jobject mbean)
 {
-    MEMORYSTATUS ms;
-    GlobalMemoryStatus(&ms);
-    return (jlong) ms.dwAvailPhys;
+    MEMORYSTATUSEX ms;
+    ms.dwLength = sizeof(ms);
+    GlobalMemoryStatusEx(&ms);
+    return (jlong) ms.ullAvailPhys;
 }
 
 JNIEXPORT jlong JNICALL
 Java_com_sun_management_OperatingSystem_getTotalPhysicalMemorySize
   (JNIEnv *env, jobject mbean)
 {
-    MEMORYSTATUS ms;
-    // also returns dwAvailPhys (free physical memory bytes),
-    // dwTotalVirtual, dwAvailVirtual,
-    // dwMemoryLoad (% of memory in use)
-    GlobalMemoryStatus(&ms);
-    return ms.dwTotalPhys;
+    MEMORYSTATUSEX ms;
+    ms.dwLength = sizeof(ms);
+    GlobalMemoryStatusEx(&ms);
+    return (jlong) ms.ullTotalPhys;
 }
 
 // Seems WinXP PDH returns PDH_MORE_DATA whenever we send in a NULL buffer.
--- a/jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiIn.cpp	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiIn.cpp	Tue Sep 25 11:48:00 2012 -0700
@@ -35,9 +35,15 @@
 
 #ifdef USE_ERROR
 #include <stdio.h>
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define MIDIIN_CHECK_ERROR { \
         if (err != MMSYSERR_NOERROR) \
-            ERROR3("MIDI IN Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
+            ERROR3("MIDI IN Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
     }
 #else
 #define MIDIIN_CHECK_ERROR
--- a/jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiOut.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiOut.c	Tue Sep 25 11:48:00 2012 -0700
@@ -33,9 +33,15 @@
 
 #ifdef USE_ERROR
 #include <stdio.h>
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define MIDIOUT_CHECK_ERROR  { \
         if (err != MMSYSERR_NOERROR) \
-            ERROR3("MIDI OUT Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
+            ERROR3("MIDI OUT Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
         }
 #else
 #define MIDIOUT_CHECK_ERROR
--- a/jdk/src/windows/native/sun/java2d/d3d/D3DPipeline.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/native/sun/java2d/d3d/D3DPipeline.h	Tue Sep 25 11:48:00 2012 -0700
@@ -28,6 +28,11 @@
 #define D3D_DEBUG_INFO
 #endif // DEBUG
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE THIS_FILE
+#endif
+
 #ifdef D3D_PPL_DLL
 
 
@@ -104,7 +109,7 @@
 #define ACT_IF_NULL(ACTION, value)         \
     if ((value) == NULL) {                 \
         J2dTraceLn3(J2D_TRACE_ERROR,       \
-                    "%s is null in %s:%d", #value, __FILE__, __LINE__); \
+                    "%s is null in %s:%d", #value, THIS_FILE, __LINE__); \
         ACTION;                            \
     } else do { } while (0)
 #define RETURN_IF_NULL(value)   ACT_IF_NULL(return, value)
@@ -114,12 +119,12 @@
 
 #define RETURN_STATUS_IF_EXP_FAILED(EXPR) \
     if (FAILED(res = (EXPR))) {                    \
-        DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## __FILE__); \
+        DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## THIS_FILE); \
         return res;                   \
     } else do { } while (0)
 
 #define RETURN_STATUS_IF_FAILED(status) \
     if (FAILED((status))) {                    \
-        DebugPrintD3DError((status), " failed in " ## __FILE__ ## ", return;");\
+        DebugPrintD3DError((status), " failed in " ## THIS_FILE ## ", return;");\
         return (status);                   \
     } else do { } while (0)
--- a/jdk/src/windows/native/sun/windows/alloc.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/native/sun/windows/alloc.h	Tue Sep 25 11:48:00 2012 -0700
@@ -26,6 +26,11 @@
 #ifndef _ALLOC_H_
 #define _ALLOC_H_
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #include "stdhdrs.h"
 
 // By defining std::bad_alloc in a local header file instead of including
@@ -127,12 +132,12 @@
         throw (std::bad_alloc);
 
     #define safe_Malloc(size) \
-        safe_Malloc_outofmem(size, __FILE__, __LINE__)
+        safe_Malloc_outofmem(size, THIS_FILE, __LINE__)
     #define safe_Calloc(num, size) \
-        safe_Calloc_outofmem(num, size, __FILE__, __LINE__)
+        safe_Calloc_outofmem(num, size, THIS_FILE, __LINE__)
     #define safe_Realloc(memblock, size) \
-        safe_Realloc_outofmem(memblock, size, __FILE__, __LINE__)
-    #define new new(__FILE__, __LINE__)
+        safe_Realloc_outofmem(memblock, size, THIS_FILE, __LINE__)
+    #define new new(THIS_FILE, __LINE__)
 #endif /* OUTOFMEM_TEST */
 
 #define TRY \
--- a/jdk/src/windows/native/sun/windows/awt_Debug.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_Debug.h	Tue Sep 25 11:48:00 2012 -0700
@@ -65,7 +65,12 @@
     #define AWT_DUMP_CLIP_RECTANGLE(_msg, _hwnd) \
         _DTrace_Template(DumpClipRectangle, 2, "", (_msg), (_hwnd), 0, 0, 0, 0, 0, 0)
 
-    #define new         new(__FILE__, __LINE__)
+    /* Use THIS_FILE when it is available. */
+    #ifndef THIS_FILE
+        #define THIS_FILE __FILE__
+    #endif
+
+    #define new         new(THIS_FILE, __LINE__)
 
     #define VERIFY(exp)         DASSERT(exp)
     #define UNIMPLEMENTED()     DASSERT(FALSE)
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Tue Sep 25 11:48:00 2012 -0700
@@ -132,24 +132,30 @@
 
 // Macros for using CriticalSection objects that help trace
 // lock/unlock actions
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define CRITICAL_SECTION_ENTER(cs) { \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Wait:  tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
     (cs).Enter(); \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Enter: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
 }
 
 #define CRITICAL_SECTION_LEAVE(cs) { \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Leave: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
     (cs).Leave(); \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Left:  tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
 }
 
 /************************************************************************
--- a/jdk/src/windows/native/sun/windows/awt_Window.cpp	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_Window.cpp	Tue Sep 25 11:48:00 2012 -0700
@@ -1477,7 +1477,7 @@
     if (wClassEvent == NULL) {
         if (env->PushLocalFrame(1) < 0)
             return;
-        wClassEvent = env->FindClass("java/awt/event/WindowEvent");
+        wClassEvent = env->FindClass("sun/awt/TimedWindowEvent");
         if (wClassEvent != NULL) {
             wClassEvent = (jclass)env->NewGlobalRef(wClassEvent);
         }
@@ -1491,7 +1491,7 @@
     if (wEventInitMID == NULL) {
         wEventInitMID =
             env->GetMethodID(wClassEvent, "<init>",
-                             "(Ljava/awt/Window;ILjava/awt/Window;II)V");
+                             "(Ljava/awt/Window;ILjava/awt/Window;IIJ)V");
         DASSERT(wEventInitMID);
         if (wEventInitMID == NULL) {
             return;
@@ -1532,7 +1532,7 @@
         }
     }
     jobject event = env->NewObject(wClassEvent, wEventInitMID, target, id,
-                                   jOpposite, oldState, newState);
+                                   jOpposite, oldState, newState, TimeHelper::getMessageTimeUTC());
     DASSERT(!safe_ExceptionOccurred(env));
     DASSERT(event != NULL);
     if (jOpposite != NULL) {
--- a/jdk/src/windows/transport/shmem/shmem_md.c	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/src/windows/transport/shmem/shmem_md.c	Tue Sep 25 11:48:00 2012 -0700
@@ -30,6 +30,11 @@
 #include "sysShmem.h"
 #include "shmemBase.h"  /* for exitTransportWithError */
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /*
  * These functions are not completely universal. For now, they are used
  * exclusively for Jbug's shared memory transport mechanism. They have
@@ -44,7 +49,7 @@
     if (!(expression)) {                \
             exitTransportWithError \
             ("\"%s\", line %d: assertion failure\n", \
-             __FILE__, __DATE__, __LINE__); \
+             THIS_FILE, __DATE__, __LINE__); \
     }                                   \
 }
 #else
--- a/jdk/test/ProblemList.txt	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/ProblemList.txt	Tue Sep 25 11:48:00 2012 -0700
@@ -261,6 +261,18 @@
 # 7146541
 java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java	linux-all
 
+# 7187882
+java/rmi/activation/checkusage/CheckUsage.java                  generic-all
+
+# 7190106
+java/rmi/reliability/benchmark/runRmiBench.sh                   generic-all
+
+# 7191877
+java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java       generic-all
+
+# 7195095
+sun/rmi/transport/proxy/EagerHttpFallback.java                  linux-all
+
 ############################################################################
 
 # jdk_security
--- a/jdk/test/com/sun/corba/cachedSocket/7056731.sh	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/com/sun/corba/cachedSocket/7056731.sh	Tue Sep 25 11:48:00 2012 -0700
@@ -115,5 +115,8 @@
     exitCode=0
 fi
 
+#jtreg complaining about not being able to clean up; let's sleep
+sleep 2
 rm -rf out.$$ client.$$
+sleep 2
 exit ${exitCode}
--- a/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 6330287 6331386
+ * @bug 6330287 6331386 7044060
  * @summary verify that DHKeyPairGenerator returns keys of the expected size
  * (modulus and exponent)
  * -and-
@@ -57,7 +57,8 @@
      * Sizes and values for various lengths.
      */
     private enum Sizes {
-        two56(256), three84(384), five12(512), seven68(768), ten24(1024);
+        two56(256), three84(384), five12(512), seven68(768), ten24(1024),
+        twenty48(2048);
 
         private final int intSize;
         private final BigInteger bigIntValue;
@@ -82,7 +83,8 @@
         KeyPair kp;
         KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", "SunJCE");
 
-        // Sun's default uses a default psize of 1024/lsize of 512
+        // Sun's default uses a default psize of 1024 and
+        // lsize of (pSize / 2) but at least 384 bits
         kp = kpg.generateKeyPair();
         checkKeyPair(kp, Sizes.ten24, Sizes.five12);
 
@@ -114,6 +116,20 @@
         kp = kpg.generateKeyPair();
         checkKeyPair(kp, Sizes.seven68, Sizes.three84);
 
+        // test w/ only pSize
+        kpg.initialize(Sizes.twenty48.getIntSize());
+        kp = kpg.generateKeyPair();
+        checkKeyPair(kp, Sizes.twenty48, Sizes.ten24);
+
+        publicKey = (DHPublicKey)kp.getPublic();
+        p = publicKey.getParams().getP();
+        g = publicKey.getParams().getG();
+
+        // test w/ all values specified
+        kpg.initialize(new DHParameterSpec(p, g, Sizes.five12.getIntSize()));
+        kp = kpg.generateKeyPair();
+        checkKeyPair(kp, Sizes.twenty48, Sizes.five12);
+
         System.out.println("OK");
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/MemoryStatusOverflow.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug     6853676
+ * @summary On computers with more than 4 GB of memory,
+ *      the GlobalMemoryStatus function can return incorrect information,
+ *      reporting a value of -1 to indicate an overflow.
+ *
+ * @run main MemoryStatusOverflow
+ */
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+import java.lang.management.ManagementFactory;
+import com.sun.management.OperatingSystemMXBean;
+
+public class MemoryStatusOverflow {
+    static final long MEMORYSTATUS_OVERFLOW = (1L << 32) - 1; // (DWORD) -1
+
+    public static void main(String... args) throws Exception {
+        OperatingSystemMXBean bean = (OperatingSystemMXBean)
+                ManagementFactory.getOperatingSystemMXBean();
+        List<String> failedGetterNames = new ArrayList<String>();
+        List<String> testedGetterNames = Arrays.asList(
+                "getTotalSwapSpaceSize",      "getFreeSwapSpaceSize",
+                "getTotalPhysicalMemorySize", "getFreePhysicalMemorySize");
+        for (String getterName : testedGetterNames) {
+            Method getter = OperatingSystemMXBean.class.getMethod(getterName);
+            long value = (Long) getter.invoke(bean);
+            if (value == MEMORYSTATUS_OVERFLOW) {
+                failedGetterNames.add(getterName);
+            }
+        }
+        if (!failedGetterNames.isEmpty()) {
+            throw new AssertionError(failedGetterNames);
+        }
+        System.out.println("Test passed.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/6981400/Test1.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     6981400
+ * @summary Tabbing between textfiled do not work properly when ALT+TAB
+ * @author  anton.tarasov
+ * @library ../../regtesthelpers
+ * @build   Util
+ * @run     main Test1
+ */
+
+// This test shows a frame with four focusable components: b0, b1, b2, b3.
+// Then it presses Tab three times. EDT is freezed for a while on the first FOCUS_LOST event.
+// Meantime, the test clicks in a component of another frame and then clicks in the title
+// of the original frame. When EDT awakes and all the queued events get processed,
+// the other frame should ones gain focus and then pass it to the original frame.
+// The b3 component of the orinial frame should finally become a focus owner.
+// The FOCUS_LOST/FOCUS_GAINED events order in the original frame is tracked and should be:
+// b0 -> b1 -> b2 -> b3.
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.swing.*;
+import test.java.awt.regtesthelpers.Util;
+
+public class Test1 {
+    static JFrame f0 = new JFrame("base_frame") { public String getName() {return "base_frame";} };
+    static JButton f0b0 = new JB("b0");
+    static JButton f0b1 = new JB("b1");
+    static JButton f0b2 = new JB("b2");
+    static JButton f0b3 = new JB("b3");
+
+    static JFrame f1 = new JFrame("swing_frame") { public String getName() {return "swing_frame";} };
+    static JButton f1b0 = new JButton("button");
+
+    static Frame f2 = new Frame("awt_frame") { public String getName() {return "awt_frame";} };
+    static Button f2b0 = new Button("button");
+
+    static Robot robot;
+
+    static List<Component> gainedList = new ArrayList<Component>();
+    static List<Component> lostList = new ArrayList<Component>();
+
+    static Component[] refGainedList = new Component[] {f0b1, f0b2, f0b3, f0b3};
+    static Component[] refLostList = new Component[] {f0b0, f0b1, f0b2, f0b3};
+
+    static boolean tracking;
+
+    public static void main(String[] args) {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+            public void eventDispatched(AWTEvent e) {
+                System.out.println(e);
+            }
+        }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_EVENT_MASK);
+
+        try {
+            robot = new Robot();
+        } catch (AWTException ex) {
+            throw new RuntimeException("Error: can't create Robot");
+        }
+
+        f0.add(f0b0);
+        f0.add(f0b1);
+        f0.add(f0b2);
+        f0.add(f0b3);
+        f0.setLayout(new FlowLayout());
+        f0.setBounds(0, 100, 400, 200);
+
+        f1.add(f1b0);
+        f1.setBounds(0, 400, 400, 200);
+
+        f2.add(f2b0);
+        f2.setBounds(0, 400, 400, 200);
+
+        f0b0.addFocusListener(new FocusAdapter() {
+            @Override
+            public void focusLost(FocusEvent e) {
+                try {
+                    Thread.sleep(1000);
+                } catch (Exception ex) {}
+            }
+        });
+
+        //
+        // Case 1. Test against swing JFrame.
+        //
+
+        f1.setVisible(true);
+        f0.setVisible(true);
+
+        Util.waitForIdle(robot);
+
+        if (!f0b0.isFocusOwner()) {
+            Util.clickOnComp(f0b0, robot);
+            Util.waitForIdle(robot);
+            if (!f0b0.isFocusOwner()) {
+                throw new RuntimeException("Error: can't focus the component " + f0b0);
+            }
+        }
+
+        System.out.println("\nTest case 1: swing frame\n");
+        test(f1b0);
+
+        //
+        // Case 2. Test against awt Frame.
+        //
+
+        tracking = false;
+        gainedList.clear();
+        lostList.clear();
+
+        f1.dispose();
+        f2.setAutoRequestFocus(false);
+        f2.setVisible(true);
+        Util.waitForIdle(robot);
+
+        Util.clickOnComp(f0b0, robot);
+        Util.waitForIdle(robot);
+        if (!f0b0.isFocusOwner()) {
+            throw new RuntimeException("Error: can't focus the component " + f0b0);
+        }
+
+        System.out.println("\nTest case 2: awt frame\n");
+        test(f2b0);
+
+        System.out.println("\nTest passed.");
+    }
+
+    public static void test(Component compToClick) {
+        tracking = true;
+
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+        robot.delay(50);
+
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+        robot.delay(50);
+
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+
+        robot.delay(50);
+        Util.clickOnComp(compToClick, robot);
+
+        robot.delay(50);
+        Util.clickOnTitle(f0, robot);
+
+        Util.waitForIdle(robot);
+
+        if (!f0b3.isFocusOwner()) {
+            throw new RuntimeException("Test failed: f0b3 is not a focus owner");
+        }
+
+        if (!"sun.awt.X11.XToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
+
+            if (!Arrays.asList(refGainedList).equals(gainedList)) {
+                System.out.println("gained list: " + gainedList);
+                throw new RuntimeException("Test failed: wrong FOCUS_GAINED events order");
+            }
+            if (!Arrays.asList(refLostList).equals(lostList)) {
+                System.out.println("lost list: " + lostList);
+                throw new RuntimeException("Test failed: wrong FOCUS_LOST events order");
+            }
+        }
+    }
+}
+
+class JB extends JButton {
+    String name;
+
+    public JB(String name) {
+        super(name);
+        this.name = name;
+
+        addFocusListener(new FocusListener() {
+            public void focusGained(FocusEvent e) {
+                if (Test1.tracking)
+                    Test1.gainedList.add(e.getComponent());
+            }
+
+            public void focusLost(FocusEvent e) {
+                if (Test1.tracking)
+                    Test1.lostList.add(e.getComponent());
+            }
+        });
+    }
+
+    public String toString() {
+        return "[" + name + "]";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/6981400/Test2.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     6981400
+ * @summary Tabbing between textfiled do not work properly when ALT+TAB
+ * @author  anton.tarasov
+ * @library ../../regtesthelpers
+ * @build   Util
+ * @run     main Test2
+ */
+
+// A focus request made after a char is typed ahead shouldn't affect the char's target component.
+
+import java.awt.*;
+import java.awt.event.*;
+import test.java.awt.regtesthelpers.Util;
+
+public class Test2 {
+    static Frame f = new Frame("frame");
+    static TextArea t0 = new TextArea(1, 10) { public String toString() { return "[TA-0]";} };
+    static TextArea t1 = new TextArea(1, 10) { public String toString() { return "[TA-1]";} };
+    static TextArea t2 = new TextArea(1, 10) { public String toString() { return "[TA-2]";} };
+
+    static volatile boolean passed = true;
+
+    static Robot robot;
+
+    public static void main(String[] args) {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+            public void eventDispatched(AWTEvent e) {
+                System.out.println(e);
+                if (e.getID() == KeyEvent.KEY_TYPED) {
+                    if (e.getSource() != t1) {
+                        passed = false;
+                        throw new RuntimeException("Test failed: the key event has wrong source: " + e);
+                    }
+                }
+            }
+        }, FocusEvent.FOCUS_EVENT_MASK | KeyEvent.KEY_EVENT_MASK);
+
+        try {
+            robot = new Robot();
+        } catch (AWTException ex) {
+            throw new RuntimeException("Error: can't create Robot");
+        }
+
+        f.add(t0);
+        f.add(t1);
+        f.add(t2);
+
+        f.setLayout(new FlowLayout());
+        f.pack();
+
+        t0.addFocusListener(new FocusAdapter() {
+            public void focusLost(FocusEvent e) {
+                try {
+                    Thread.sleep(3000);
+                } catch (Exception ex) {}
+            }
+        });
+
+        // The request shouldn't affect the key event delivery.
+        new Thread(new Runnable() {
+            public void run() {
+                try {
+                    Thread.sleep(2000);
+                } catch (Exception ex) {}
+                System.out.println("requesting focus to " + t2);
+                t2.requestFocus();
+            }
+        }).start();
+
+
+        f.setVisible(true);
+        Util.waitForIdle(robot);
+
+        test();
+
+        if (passed) System.out.println("\nTest passed.");
+    }
+
+    static void test() {
+        Util.clickOnComp(t1, robot);
+
+        // The key event should be eventually delivered to t1.
+        robot.delay(50);
+        robot.keyPress(KeyEvent.VK_A);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_A);
+
+        Util.waitForIdle(robot);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/6981400/Test3.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     6981400
+ * @summary Tabbing between textfiled do not work properly when ALT+TAB
+ * @author  anton.tarasov
+ * @library ../../regtesthelpers
+ * @build   Util
+ * @run     main Test3
+ */
+
+// A menu item in a frame should not be auto-selected when switching by Alt+TAB back and forth.
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+import test.java.awt.regtesthelpers.Util;
+
+public class Test3 {
+    static JFrame f = new JFrame("Frame");
+    static JMenuBar bar = new JMenuBar();
+    static JMenu menu = new JMenu("File");
+    static JMenuItem item = new JMenuItem("Save");
+
+    static JButton b0 = new JButton("b0");
+    static JButton b1 = new JButton("b1");
+
+    static Robot robot;
+
+    public static void main(String[] args) {
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+            public void eventDispatched(AWTEvent e) {
+                System.err.println(e);
+            }
+        }, KeyEvent.KEY_EVENT_MASK);
+
+        try {
+            robot = new Robot();
+        } catch (AWTException ex) {
+            throw new RuntimeException("Error: can't create Robot");
+        }
+
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+        } catch (Exception e) {}
+
+        b0.addFocusListener(new FocusAdapter() {
+            public void focusLost(FocusEvent f) {
+                try {
+                    Thread.sleep(2000);
+                } catch (Exception e) {}
+            }
+        });
+
+        menu.add(item);
+        bar.add(menu);
+        f.setJMenuBar(bar);
+
+        f.add(b0);
+        f.add(b1);
+
+        f.setLayout(new FlowLayout());
+        f.setSize(400, 100);
+        f.setVisible(true);
+        Util.waitForIdle(robot);
+
+        if (!b0.hasFocus()) {
+            Util.clickOnComp(b0, robot);
+            Util.waitForIdle(robot);
+            if (!b0.hasFocus()) {
+                throw new RuntimeException("Error: can't focus " + b0);
+            }
+        }
+
+        test();
+
+        System.out.println("Test passed.");
+    }
+
+    public static void test() {
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+        robot.delay(50);
+
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.delay(50);
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_ALT);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+
+        robot.delay(500);
+
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.delay(50);
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_ALT);
+        robot.delay(50);
+        robot.keyRelease(KeyEvent.VK_TAB);
+
+        // Control shot.
+        Util.clickOnTitle(f, robot);
+        Util.waitForIdle(robot);
+
+        if (menu.isSelected()) {
+            throw new RuntimeException("Test failed: the menu gets selected");
+        }
+        if (!b1.hasFocus()) {
+            throw new RuntimeException("Test failed: the button is not a focus owner " + b1);
+        }
+    }
+}
+
+
--- a/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java	Tue Sep 25 11:48:00 2012 -0700
@@ -38,8 +38,7 @@
 
 import java.beans.BeanInfo;
 import java.beans.Introspector;
-import java.lang.ref.Reference;
-import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 
 public class TestBeanInfo implements Runnable {
 
@@ -60,10 +59,9 @@
         try {
             actual = Introspector.getBeanInfo(type);
             type = actual.getClass();
-            Field field = type.getDeclaredField("targetBeanInfoRef"); // NON-NLS: field name
-            field.setAccessible(true);
-            Reference ref = (Reference) field.get(actual);
-            actual = (BeanInfo) ref.get();
+            Method method = type.getDeclaredMethod("getTargetBeanInfo"); // NON-NLS: method name
+            method.setAccessible(true);
+            actual = (BeanInfo) method.invoke(actual);
         }
         catch (Exception exception) {
             throw new Error("unexpected error", exception);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/Test7186794.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7186794
+ * @summary Tests setter in the super class
+ * @author Sergey Malenkov
+ */
+
+import java.util.List;
+
+public class Test7186794 {
+
+    public static void main(String[] args) {
+        if (null == BeanUtils.findPropertyDescriptor(MyBean.class, "value").getWriteMethod()) {
+            throw new Error("The property setter is not found");
+        }
+    }
+
+    public static class BaseBean {
+
+        protected List<String> value;
+
+        public void setValue(List<String> value) {
+            this.value = value;
+        }
+    }
+
+    public static class MyBean extends BaseBean {
+        public List<String> getValue() {
+            return super.value;
+        }
+    }
+}
--- a/jdk/test/java/beans/Introspector/Test7189112.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/java/beans/Introspector/Test7189112.java	Tue Sep 25 11:48:00 2012 -0700
@@ -28,17 +28,11 @@
  * @author Sergey Malenkov
  */
 
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-
 public class Test7189112 {
 
-    public static void main(String[] args) throws IntrospectionException {
-        for (PropertyDescriptor pd : Introspector.getBeanInfo(MyBean.class).getPropertyDescriptors()) {
-            if (pd.getName().equals("value") && (null == pd.getWriteMethod())) {
-                throw new Error("The property setter is not found");
-            }
+    public static void main(String[] args) {
+        if (null == BeanUtils.findPropertyDescriptor(MyBean.class, "value").getWriteMethod()) {
+            throw new Error("The property setter is not found");
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/Test7192955.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7192955
+ * @summary Tests that all properties are bound
+ * @author Sergey Malenkov
+ */
+
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+public class Test7192955 {
+
+    public static void main(String[] args) {
+        if (!BeanUtils.findPropertyDescriptor(MyBean.class, "test").isBound()) {
+            throw new Error("a simple property is not bound");
+        }
+        if (!BeanUtils.findPropertyDescriptor(MyBean.class, "list").isBound()) {
+            throw new Error("a generic property is not bound");
+        }
+        if (!BeanUtils.findPropertyDescriptor(MyBean.class, "readOnly").isBound()) {
+            throw new Error("a read-only property is not bound");
+        }
+    }
+
+    public static class BaseBean {
+
+        private List<String> list;
+
+        public List<String> getList() {
+            return this.list;
+        }
+
+        public void setList(List<String> list) {
+            this.list = list;
+        }
+
+        public void addPropertyChangeListener(PropertyChangeListener listener) {
+        }
+
+        public void removePropertyChangeListener(PropertyChangeListener listener) {
+        }
+
+        public List<String> getReadOnly() {
+            return this.list;
+        }
+    }
+
+    public static class MyBean extends BaseBean {
+
+        private String test;
+
+        public String getTest() {
+            return this.test;
+        }
+
+        public void setTest(String test) {
+            this.test = test;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/Test7195106.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7195106
+ * @summary Tests that explicit BeanInfo is not collected
+ * @author Sergey Malenkov
+ */
+
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.SimpleBeanInfo;
+
+public class Test7195106 {
+
+    public static void main(String[] arg) throws Exception {
+        BeanInfo info = Introspector.getBeanInfo(My.class);
+        if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
+            throw new Error("Unexpected behavior");
+        }
+        try {
+            int[] array = new int[1024];
+            while (true) {
+                array = new int[array.length << 1];
+            }
+        }
+        catch (OutOfMemoryError error) {
+            System.gc();
+        }
+        if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
+            throw new Error("Explicit BeanInfo is collected");
+        }
+    }
+
+    public static class My {
+    }
+
+    public static class MyBeanInfo extends SimpleBeanInfo {
+        @Override
+        public Image getIcon(int type) {
+            return new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/Test7169395.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7169395
+ * @summary Tests that array list initialized correctly
+ * @author Sergey Malenkov
+ */
+
+import java.beans.ConstructorProperties;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class Test7169395 extends AbstractTest {
+
+    public static void main(String[] args) {
+        new Test7169395().test(true);
+    }
+
+    protected Object getObject() {
+        Container container = new Container();
+        container.add("test-null", null);
+        container.add("test-value", "value");
+        container.add("test-other", "other");
+        return container;
+    }
+
+    public static class Component {
+
+        private final Container container;
+        private final String name;
+        private String value;
+
+        @ConstructorProperties({ "container", "name" })
+        public Component(Container container, String name) {
+            this.container = container;
+            this.name = name;
+        }
+
+        public Container getContainer() {
+            return this.container;
+        }
+
+        public String getName() {
+            return this.name;
+        }
+
+        public String getValue() {
+            return this.value;
+        }
+
+        public void setValue(String value) {
+            this.value = value;
+        }
+    }
+
+    public static class Container {
+
+        private final Map<String, Component> map = new TreeMap<String, Component>();
+
+        public Collection<Component> getComponents() {
+            return new ArrayList<Component>(this.map.values());
+        }
+
+        public void setComponents(Collection<Component> components) {
+            this.map.clear();
+            for (Component component : components){
+                this.map.put(component.getName(), component);
+            }
+        }
+
+        public void add(String name, String value) {
+            Component list = new Component(this, name);
+            list.setValue(value);
+            this.map.put(name, list);
+        }
+    }
+}
--- a/jdk/test/java/nio/file/Files/CopyAndMove.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/java/nio/file/Files/CopyAndMove.java	Tue Sep 25 11:48:00 2012 -0700
@@ -86,10 +86,12 @@
         assertTrue(attrs1.isSymbolicLink() == attrs2.isSymbolicLink());
         assertTrue(attrs1.isOther() == attrs2.isOther());
 
-        // check last modified time
-        long time1 = attrs1.lastModifiedTime().toMillis();
-        long time2 = attrs2.lastModifiedTime().toMillis();
-        assertTrue(time1 == time2);
+        // check last modified time if not a symbolic link
+        if (!attrs1.isSymbolicLink()) {
+            long time1 = attrs1.lastModifiedTime().toMillis();
+            long time2 = attrs2.lastModifiedTime().toMillis();
+            assertTrue(time1 == time2);
+        }
 
         // check size
         if (attrs1.isRegularFile())
--- a/jdk/test/sun/security/ec/TestEC.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/sun/security/ec/TestEC.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
  * @run main TestEC
  */
 
+import java.security.NoSuchProviderException;
 import java.security.Provider;
 import java.security.Security;
 
@@ -62,7 +63,12 @@
     }
 
     public static void main0(String[] args) throws Exception {
-        Provider p = new sun.security.ec.SunEC();
+        Provider p = Security.getProvider("SunEC");
+
+        if (p == null) {
+            throw new NoSuchProviderException("Can't get SunEC provider");
+        }
+
         System.out.println("Running tests with " + p.getName() +
             " provider...\n");
         long start = System.currentTimeMillis();
--- a/jdk/test/sun/security/pkcs11/ec/ReadCertificates.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/sun/security/pkcs11/ec/ReadCertificates.java	Tue Sep 25 11:48:00 2012 -0700
@@ -63,6 +63,10 @@
             System.out.println("Provider does not support ECDSA, skipping...");
             return;
         }
+
+        /*
+         * PKCS11Test.main will remove this provider if needed
+         */
         Providers.setAt(p, 1);
 
         random = new SecureRandom();
@@ -132,7 +136,6 @@
             }
         }
 
-        Security.removeProvider(p.getName());
         System.out.println("OK");
     }
 
--- a/jdk/test/sun/security/pkcs11/ec/ReadPKCS12.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/sun/security/pkcs11/ec/ReadPKCS12.java	Tue Sep 25 11:48:00 2012 -0700
@@ -53,6 +53,10 @@
             System.out.println("Provider does not support ECDSA, skipping...");
             return;
         }
+
+        /*
+         * PKCS11Test.main will remove this provider if needed
+         */
         Providers.setAt(p, 1);
 
         CertificateFactory factory = CertificateFactory.getInstance("X.509");
@@ -147,7 +151,6 @@
             out.close();
         }
 
-        Security.removeProvider(p.getName());
         System.out.println("OK");
     }
 
--- a/jdk/test/sun/security/pkcs11/ec/TestECDH.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/sun/security/pkcs11/ec/TestECDH.java	Tue Sep 25 11:48:00 2012 -0700
@@ -60,6 +60,10 @@
             System.out.println("Provider does not support ECDH, skipping");
             return;
         }
+
+        /*
+         * PKCS11Test.main will remove this provider if needed
+         */
         Providers.setAt(p, 1);
 
         if (false) {
@@ -77,7 +81,6 @@
         test(p, pub192a, priv192a, pub192b, priv192b, secret192);
         test(p, pub163a, priv163a, pub163b, priv163b, secret163);
 
-        Security.removeProvider(p.getName());
         System.out.println("OK");
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/ec/TestECDH2.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6405536
+ * @summary basic test of ECDSA signatures for P-256 and P-384 from the
+ * example data in "Suite B Implementer's Guide to FIPS 186-3".
+ * @library ..
+ * @library ../../../../java/security/testlibrary
+ * @compile -XDignore.symbol.file TestECDH2.java
+ * @run main TestECDH2
+ */
+
+import java.io.*;
+import java.util.*;
+import java.math.BigInteger;
+
+import java.security.*;
+import java.security.spec.*;
+import java.security.interfaces.*;
+import javax.crypto.*;
+
+import sun.security.ec.NamedCurve;
+
+public class TestECDH2 extends PKCS11Test {
+
+    // values of the keys we use for the tests
+
+    // keypair using NIST P-256
+    private final static String privD256 = "70a12c2db16845ed56ff68cfc21a472b3f04d7d6851bf6349f2d7d5b3452b38a";
+    private final static String pubX256 = "8101ece47464a6ead70cf69a6e2bd3d88691a3262d22cba4f7635eaff26680a8";
+    private final static String pubY256 = "d8a12ba61d599235f67d9cb4d58f1783d3ca43e78f0a5abaa624079936c0c3a9";
+
+    // keypair using NIST P-384
+    private final static String privD384 = "c838b85253ef8dc7394fa5808a5183981c7deef5a69ba8f4f2117ffea39cfcd90e95f6cbc854abacab701d50c1f3cf24";
+    private final static String pubX384 = "1fbac8eebd0cbf35640b39efe0808dd774debff20a2a329e91713baf7d7f3c3e81546d883730bee7e48678f857b02ca0";
+    private final static String pubY384 = "eb213103bd68ce343365a8a4c3d4555fa385f5330203bdd76ffad1f3affb95751c132007e1b240353cb0a4cf1693bdf9";
+
+    private KeyFactory kf = null;
+    private KeyPairGenerator kpg = null;
+
+    private static void testKeyAgreement(KeyPair kpA, KeyPair kpB, Provider p)
+        throws Exception {
+        KeyAgreement ka1 = KeyAgreement.getInstance("ECDH", p);
+        ka1.init(kpA.getPrivate());
+        ka1.doPhase(kpB.getPublic(), true);
+        byte[] s1 = ka1.generateSecret();
+
+        KeyAgreement ka2 = KeyAgreement.getInstance("ECDH", p);
+        ka2.init(kpB.getPrivate());
+        ka2.doPhase(kpA.getPublic(), true);
+        byte[] s2 = ka2.generateSecret();
+        if (Arrays.equals(s1, s2) == false) {
+            System.out.println("expected: " + toString(s1));
+            System.out.println("actual:   " + toString(s2));
+            throw new Exception("Generated secrets do not match");
+        }
+    }
+
+    private KeyPair genECKeyPair(String curvName, String privD, String pubX,
+                                 String pubY) throws Exception {
+        ECParameterSpec ecParams = NamedCurve.getECParameterSpec(curvName);
+        ECPrivateKeySpec privKeySpec =
+            new ECPrivateKeySpec(new BigInteger(privD, 16), ecParams);
+        ECPublicKeySpec pubKeySpec =
+            new ECPublicKeySpec(new ECPoint(new BigInteger(pubX, 16),
+                                            new BigInteger(pubY, 16)),
+                                ecParams);
+        PrivateKey privKey = kf.generatePrivate(privKeySpec);
+        PublicKey pubKey = kf.generatePublic(pubKeySpec);
+        return new KeyPair(pubKey, privKey);
+    }
+    private KeyPair genECKeyPair(String curvName) throws Exception {
+        ECGenParameterSpec genParams = new ECGenParameterSpec(curvName);
+        kpg.initialize(genParams, null);
+        return kpg.generateKeyPair();
+    }
+    public static void main(String[] args) throws Exception {
+        main(new TestECDH2());
+    }
+
+    public void main(Provider provider) throws Exception {
+        if (provider.getService("KeyAgreement", "ECDH") == null) {
+            System.out.println("ECDH not supported, skipping");
+            return;
+        }
+
+        kf = KeyFactory.getInstance("EC", provider);
+        kpg = KeyPairGenerator.getInstance("EC", provider);
+
+        System.out.println("Testing against NIST P-256");
+
+        long start = System.currentTimeMillis();
+        KeyPair kp256A = genECKeyPair("secp256r1", privD256, pubX256, pubY256);
+        KeyPair kp256B = genECKeyPair("secp256r1");
+        testKeyAgreement(kp256A, kp256B, provider);
+
+        System.out.println("Testing against NIST P-384");
+        KeyPair kp384A = genECKeyPair("secp384r1", privD384, pubX384, pubY384);
+        KeyPair kp384B = genECKeyPair("secp384r1");
+        testKeyAgreement(kp384A, kp384B, provider);
+
+        long stop = System.currentTimeMillis();
+        System.out.println("All tests passed (" + (stop - start) + " ms).");
+    }
+}
--- a/jdk/test/sun/security/pkcs11/ec/TestECDSA.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/sun/security/pkcs11/ec/TestECDSA.java	Tue Sep 25 11:48:00 2012 -0700
@@ -116,6 +116,10 @@
             System.out.println("ECDSA not supported, skipping");
             return;
         }
+
+        /*
+         * PKCS11Test.main will remove this provider if needed
+         */
         Providers.setAt(provider, 1);
 
         if (false) {
@@ -137,7 +141,6 @@
         test(provider, pub521, priv521, sig521);
         test(provider, pub571, priv571, sig571);
 
-        Security.removeProvider(provider.getName());
         long stop = System.currentTimeMillis();
         System.out.println("All tests passed (" + (stop - start) + " ms).");
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/ec/TestECDSA2.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6405536
+ * @summary basic test of ECDSA signatures for P-256 and P-384 from the
+ * example data in "Suite B Implementer's Guide to FIPS 186-3".
+ * @library ..
+ * @library ../../../../java/security/testlibrary
+ * @compile -XDignore.symbol.file TestECDSA2.java
+ * @run main TestECDSA2
+ */
+
+import java.io.*;
+import java.util.*;
+import java.math.BigInteger;
+
+import java.security.*;
+import java.security.spec.*;
+import java.security.interfaces.*;
+
+import sun.security.ec.NamedCurve;
+
+public class TestECDSA2 extends PKCS11Test {
+
+    // values of the keys we use for the tests
+
+    // keypair using NIST P-256
+    private final static String privD256 = "70a12c2db16845ed56ff68cfc21a472b3f04d7d6851bf6349f2d7d5b3452b38a";
+    private final static String pubX256 = "8101ece47464a6ead70cf69a6e2bd3d88691a3262d22cba4f7635eaff26680a8";
+    private final static String pubY256 = "d8a12ba61d599235f67d9cb4d58f1783d3ca43e78f0a5abaa624079936c0c3a9";
+
+    // keypair using NIST P-384
+    private final static String privD384 = "c838b85253ef8dc7394fa5808a5183981c7deef5a69ba8f4f2117ffea39cfcd90e95f6cbc854abacab701d50c1f3cf24";
+    private final static String pubX384 = "1fbac8eebd0cbf35640b39efe0808dd774debff20a2a329e91713baf7d7f3c3e81546d883730bee7e48678f857b02ca0";
+    private final static String pubY384 = "eb213103bd68ce343365a8a4c3d4555fa385f5330203bdd76ffad1f3affb95751c132007e1b240353cb0a4cf1693bdf9";
+
+    // data to be signed
+    private final static byte[] data = "This is only a test message. It is 48 bytes long".getBytes();
+
+    private KeyFactory kf = null;
+
+    private static void testSignAndVerify(String alg, KeyPair kp, Provider p) throws Exception {
+        Signature s = Signature.getInstance(alg, p);
+        s.initSign(kp.getPrivate());
+        s.update(data);
+        byte[] result = s.sign();
+
+        s.initVerify(kp.getPublic());
+        s.update(data);
+        if (!s.verify(result)) {
+            throw new Exception("Error: Signature verification failed");
+        }
+        System.out.println(p.getName() + ": " + alg + " Passed");
+    }
+
+    private KeyPair genECKeyPair(String curvName, String privD, String pubX, String pubY) throws Exception {
+        ECParameterSpec ecParams = NamedCurve.getECParameterSpec(curvName);
+        ECPrivateKeySpec privKeySpec =
+            new ECPrivateKeySpec(new BigInteger(privD, 16), ecParams);
+        ECPublicKeySpec pubKeySpec =
+            new ECPublicKeySpec(new ECPoint(new BigInteger(pubX, 16), new BigInteger(pubY, 16)),
+                                ecParams);
+        PrivateKey privKey = kf.generatePrivate(privKeySpec);
+        PublicKey pubKey = kf.generatePublic(pubKeySpec);
+        return new KeyPair(pubKey, privKey);
+    }
+
+    public static void main(String[] args) throws Exception {
+        main(new TestECDSA2());
+    }
+
+    public void main(Provider provider) throws Exception {
+        boolean testP256 =
+            (provider.getService("Signature", "SHA256withECDSA") != null);
+
+        boolean testP384 =
+            (provider.getService("Signature", "SHA384withECDSA") != null);
+
+        if (!testP256 && !testP384) {
+            System.out.println("ECDSA not supported, skipping");
+            return;
+        }
+
+        kf = KeyFactory.getInstance("EC", provider);
+
+        long start = System.currentTimeMillis();
+        if (testP256) {
+            // can use secp256r1, NIST P-256, X9.62 prime256v1, or 1.2.840.10045.3.1.7
+            KeyPair kp = genECKeyPair("secp256r1", privD256, pubX256, pubY256);
+            testSignAndVerify("SHA256withECDSA", kp, provider);
+        }
+        if (testP384) {
+            // can use secp384r1, NIST P-384, 1.3.132.0.34
+            KeyPair kp = genECKeyPair("secp384r1", privD384, pubX384, pubY384);
+            testSignAndVerify("SHA384withECDSA", kp, provider);
+        }
+        long stop = System.currentTimeMillis();
+        System.out.println("All tests passed (" + (stop - start) + " ms).");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/provider/DSA/TestAlgParameterGenerator.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7044060
+ * @summary verify that DSA parameter generation works
+ * @run main/othervm/timeout=300 TestAlgParameterGenerator
+ */
+import java.security.*;
+import java.security.spec.*;
+import java.security.interfaces.*;
+
+public class TestAlgParameterGenerator {
+
+    private static void checkParamStrength(AlgorithmParameters param,
+                                           int strength) throws Exception {
+        String algo = param.getAlgorithm();
+        if (!algo.equalsIgnoreCase("DSA")) {
+            throw new Exception("Unexpected type of parameters: " + algo);
+        }
+        DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class);
+        int valueL = spec.getP().bitLength();
+        if (strength != valueL) {
+            System.out.println("Expected " + strength + " but actual " + valueL);
+            throw new Exception("Wrong P strength");
+        }
+    }
+    private static void checkParamStrength(AlgorithmParameters param,
+                                           DSAGenParameterSpec genParam)
+        throws Exception {
+        String algo = param.getAlgorithm();
+        if (!algo.equalsIgnoreCase("DSA")) {
+            throw new Exception("Unexpected type of parameters: " + algo);
+        }
+        DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class);
+        int valueL = spec.getP().bitLength();
+        int strength = genParam.getPrimePLength();
+        if (strength != valueL) {
+            System.out.println("P: Expected " + strength + " but actual " + valueL);
+            throw new Exception("Wrong P strength");
+        }
+        int valueN = spec.getQ().bitLength();
+        strength = genParam.getSubprimeQLength();
+        if (strength != valueN) {
+            System.out.println("Q: Expected " + strength + " but actual " + valueN);
+            throw new Exception("Wrong Q strength");
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        AlgorithmParameterGenerator apg =
+            AlgorithmParameterGenerator.getInstance("DSA", "SUN");
+
+        long start, stop;
+        // make sure no-init still works
+        start = System.currentTimeMillis();
+        AlgorithmParameters param = apg.generateParameters();
+        stop = System.currentTimeMillis();
+        System.out.println("Time: " + (stop - start) + " ms.");
+        checkParamStrength(param, 1024);
+
+        // make sure the old model works
+        int[] strengths = { 512, 768, 1024 };
+        for (int i = 0; i < strengths.length; i++) {
+            int sizeP = strengths[i];
+            System.out.println("Generating " + sizeP + "-bit DSA Parameters");
+            start = System.currentTimeMillis();
+            apg.init(sizeP);
+            param = apg.generateParameters();
+            stop = System.currentTimeMillis();
+            System.out.println("Time: " + (stop - start) + " ms.");
+            checkParamStrength(param, sizeP);
+        }
+
+        // now the newer model
+        DSAGenParameterSpec spec1 = new DSAGenParameterSpec(1024, 160);
+        DSAGenParameterSpec spec2 = new DSAGenParameterSpec(2048, 224);
+        DSAGenParameterSpec spec3 = new DSAGenParameterSpec(2048, 256);
+        //DSAGenParameterSpec spec4 = new DSAGenParameterSpec(3072, 256);
+        DSAGenParameterSpec[] specSet = {
+            spec1, spec2, spec3//, spec4
+        };
+        for (int i = 0; i < specSet.length; i++) {
+            DSAGenParameterSpec genParam = specSet[i];
+            System.out.println("Generating (" + genParam.getPrimePLength() +
+                               ", " + genParam.getSubprimeQLength() +
+                               ") DSA Parameters");
+            start = System.currentTimeMillis();
+            apg.init(genParam, null);
+            param = apg.generateParameters();
+            stop = System.currentTimeMillis();
+            System.out.println("Time: " + (stop - start) + " ms.");
+            checkParamStrength(param, genParam);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/provider/DSA/TestDSA2.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 7044060
+ * @run main/othervm/timeout=250 TestDSA2
+ * @summary verify that DSA signature works using SHA and SHA-224 and SHA-256 digests.
+ */
+
+
+import java.security.*;
+import java.security.spec.*;
+import java.security.interfaces.*;
+
+public class TestDSA2 {
+
+    // NOTE: need to explictly specify provider since the more
+    // preferred provider SunPKCS11 provider only supports up
+    // 1024 bits.
+    private static final String PROV = "SUN";
+
+    private static final String[] SIG_ALGOS = {
+        "SHA1withDSA", "SHA224withDSA", "SHA256withDSA"
+    };
+
+    private static final int[] KEYSIZES = {
+        1024, 2048
+    };
+
+    public static void main(String[] args) throws Exception {
+        boolean[] expectedToPass = { true, true, true };
+        test(1024, expectedToPass);
+        boolean[] expectedToPass2 = { false, true, true };
+        test(2048, expectedToPass2);
+    }
+
+    private static void test(int keySize, boolean[] testStatus)
+        throws Exception {
+        byte[] data = "1234567890".getBytes();
+        System.out.println("Test against key size: " + keySize);
+
+        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", PROV);
+        keyGen.initialize(keySize, new SecureRandom());
+        KeyPair pair = keyGen.generateKeyPair();
+
+        if (testStatus.length != SIG_ALGOS.length) {
+            throw new RuntimeException("TestError: incorrect status array!");
+        }
+        for (int i = 0; i < SIG_ALGOS.length; i++) {
+            Signature dsa = Signature.getInstance(SIG_ALGOS[i], PROV);
+            try {
+                dsa.initSign(pair.getPrivate());
+                dsa.update(data);
+                byte[] sig = dsa.sign();
+                dsa.initVerify(pair.getPublic());
+                dsa.update(data);
+                boolean verifies = dsa.verify(sig);
+                if (verifies == testStatus[i]) {
+                    System.out.println(SIG_ALGOS[i] + ": Passed");
+                } else {
+                    System.out.println(SIG_ALGOS[i] + ": should " +
+                                       (testStatus[i]? "pass":"fail"));
+                    throw new RuntimeException(SIG_ALGOS[i] + ": Unexpected Test result!");
+
+                }
+            } catch (Exception ex) {
+                if (testStatus[i]) {
+                    ex.printStackTrace();
+                    throw new RuntimeException(SIG_ALGOS[i] + ": Unexpected exception " + ex);
+                } else {
+                    System.out.println(SIG_ALGOS[i] + ": Passed, expected " + ex);
+                }
+            }
+        }
+    }
+}
--- a/jdk/test/sun/security/provider/DSA/TestKeyPairGenerator.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/sun/security/provider/DSA/TestKeyPairGenerator.java	Tue Sep 25 11:48:00 2012 -0700
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 4800108
- * @summary verify that precomputed DSA parameters are always used (512, 768, 1024 bit)
+ * @summary verify that precomputed DSA parameters are always used (512, 768, 1024, 2048 bit)
  * @run main/othervm/timeout=15 TestKeyPairGenerator
  */
 
@@ -78,6 +78,10 @@
         kp = kpg.generateKeyPair();
         checkKeyLength(kp, 512);
 
+        kpg.initialize(2048);
+        kp = kpg.generateKeyPair();
+        checkKeyLength(kp, 2048);
+
         long stop = System.currentTimeMillis();
         System.out.println("Time: " + (stop - start) + " ms.");
     }
--- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,10 +27,9 @@
  * @library ../../../httpstest/
  * @build HttpCallback HttpServer ClosedChannelList HttpTransaction TunnelProxy
  * @summary  Redirect problem with HttpsURLConnection using a proxy
- * @run main/othervm B6216082
- *
  *     SunJSSE does not support dynamic system properties, no way to re-use
  *     system properties in samevm/agentvm mode.
+ * @run main/othervm B6216082
  */
 
 import java.io.*;
@@ -54,7 +53,9 @@
         try {
             // XXX workaround for CNFE
             Class.forName("java.nio.channels.ClosedByInterruptException");
-            setupEnv();
+            if (!setupEnv()) {
+                return;
+            }
 
             startHttpServer();
 
@@ -69,6 +70,12 @@
                 throw new RuntimeException("Test failed : bad http request");
             }
         } finally {
+            if (proxy != null) {
+                proxy.terminate();
+            }
+            if (server != null) {
+               server.terminate();
+            }
             HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
         }
     }
@@ -80,18 +87,13 @@
     static String keyStoreFile = "keystore";
     static String trustStoreFile = "truststore";
     static String passwd = "passphrase";
-    public static void setupEnv() {
-        try {
-            firstNonLoAddress = getNonLoAddress();
-
-            if (firstNonLoAddress == null) {
-                System.out.println("The test needs at least one non-loopback address to run. Quit now.");
-                System.exit(0);
-            }
-            System.out.println(firstNonLoAddress.getHostAddress());
-        } catch (Exception e) {
-            e.printStackTrace();
+    public static boolean setupEnv() throws Exception {
+        firstNonLoAddress = getNonLoAddress();
+        if (firstNonLoAddress == null) {
+            System.err.println("The test needs at least one non-loopback address to run. Quit now.");
+            return false;
         }
+        System.out.println(firstNonLoAddress.getHostAddress());
         // will use proxy
         System.setProperty( "https.proxyHost", firstNonLoAddress.getHostAddress());
 
@@ -106,6 +108,7 @@
         System.setProperty("javax.net.ssl.trustStore", trustFilename);
         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
         HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
+        return true;
     }
 
     public static InetAddress getNonLoAddress() throws Exception {
@@ -126,33 +129,22 @@
         return null;
     }
 
-    public static void startHttpServer() {
-        try {
-            // Both the https server and the proxy let the
-            // system pick up an ephemeral port.
-            httpTrans = new SimpleHttpTransaction();
-            server = new HttpServer(httpTrans, 1, 10, 0);
-            proxy = new TunnelProxy(1, 10, 0);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
+    public static void startHttpServer() throws IOException {
+        // Both the https server and the proxy let the
+        // system pick up an ephemeral port.
+        httpTrans = new SimpleHttpTransaction();
+        server = new HttpServer(httpTrans, 1, 10, 0);
+        proxy = new TunnelProxy(1, 10, 0);
     }
 
-    public static void makeHttpCall() {
-        try {
-            System.out.println("https server listen on: " + server.getLocalPort());
-            System.out.println("https proxy listen on: " + proxy.getLocalPort());
-            URL url = new URL("https" , firstNonLoAddress.getHostAddress(),
-                                server.getLocalPort(), "/");
-            HttpURLConnection uc = (HttpURLConnection)url.openConnection();
-            System.out.println(uc.getResponseCode());
-            uc.disconnect();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            proxy.terminate();
-            server.terminate();
-        }
+    public static void makeHttpCall() throws Exception {
+        System.out.println("https server listen on: " + server.getLocalPort());
+        System.out.println("https proxy listen on: " + proxy.getLocalPort());
+        URL url = new URL("https" , firstNonLoAddress.getHostAddress(),
+                            server.getLocalPort(), "/");
+        HttpURLConnection uc = (HttpURLConnection)url.openConnection();
+        System.out.println(uc.getResponseCode());
+        uc.disconnect();
     }
 
     static class NameVerifier implements HostnameVerifier {
@@ -189,7 +181,7 @@
                 }
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
     }
 }
--- a/jdk/test/sun/tools/jstatd/jpsOutput1.awk	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/sun/tools/jstatd/jpsOutput1.awk	Tue Sep 25 11:48:00 2012 -0700
@@ -7,7 +7,7 @@
 	    matched++;
 	}
 
-/^[0-9]+ -- process information unavailable$/	{
+/^[0-9]+ -- .*$/	{
 	    matched++;
 	}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/BigJar.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7194005
+ * @summary launcher handling of zip64 archives (Scenario A and B)
+ * @compile  -XDignore.symbol.file BigJar.java
+ * @run main/timeout=600 BigJar
+ */
+/*
+ * This test consists of two scenarios:
+ *
+ * Scenario A: create a jar with entries exceeding 64K, add a main class and
+ * see if the launcher can handle it.
+ *
+ * Scenario A1: create a jar as in A, but add a zipfile comment as well.
+ *
+ * Scenario B: create a jar with a large enough file exceeding 4GB, and
+ * similarly test the launcher. This test can be run optionally by using the
+ * following jtreg option:
+ *  "-javaoptions:-DBigJar_testScenarioB=true"
+ * or set
+ *  "BigJar_testScenarioB" environment variable.
+ *
+ * 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.ArrayList;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class BigJar extends TestHelper {
+
+    private static final long GIGA = 1024 * 1024 * 1024;
+    private static final int BUFFER_LEN = Short.MAX_VALUE * 2;
+
+    long getCount(long minlength) {
+        return (minlength / BUFFER_LEN) + 1;
+    }
+
+    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();
+    }
+
+    long computeCRC(File inFile) throws IOException {
+        byte[] buffer = new byte[8192];
+        CRC32 crc = new CRC32();
+        try (FileInputStream fis = new FileInputStream(inFile);
+                BufferedInputStream bis = new BufferedInputStream(fis)) {
+            int n = bis.read(buffer);
+            while (n > 0) {
+                crc.update(buffer, 0, n);
+                n = bis.read(buffer);
+            }
+        }
+        return crc.getValue();
+    }
+
+    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();
+    }
+
+    Manifest createMainClass(File javaFile) throws IOException {
+        javaFile.delete();
+        List<String> content = new ArrayList<>();
+        content.add("public class " + baseName(javaFile) + "{");
+        content.add("public static void main(String... args) {");
+        content.add("System.out.println(\"Hello World\\n\");");
+        content.add("System.exit(0);");
+        content.add("}");
+        content.add("}");
+        createFile(javaFile, content);
+        compile(javaFile.getName());
+        Manifest manifest = new Manifest();
+        manifest.clear();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, baseName(javaFile));
+        System.out.println(manifest.getMainAttributes().keySet());
+        System.out.println(manifest.getMainAttributes().values());
+        return manifest;
+    }
+
+    void createJarWithLargeFile(File jarFile, long minlength) throws IOException {
+        File javaFile = new File("Foo.java");
+        Manifest manifest = createMainClass(javaFile);
+        File classFile = getClassFile(javaFile);
+        try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(jarFile), manifest);
+                BufferedOutputStream bos = new BufferedOutputStream(jos);
+                FileInputStream fis = new FileInputStream(classFile);) {
+            jos.setLevel(ZipOutputStream.STORED);
+            jos.setMethod(0);
+
+            JarEntry je = new JarEntry("large.data");
+            je.setCompressedSize(getCount(minlength) * BUFFER_LEN);
+            je.setSize(getCount(minlength) * BUFFER_LEN);
+            je.setCrc(computeCRC(minlength));
+            je.setMethod(ZipEntry.STORED);
+            jos.putNextEntry(je);
+            createLargeFile(bos, minlength);
+
+            je = new JarEntry(classFile.getName());
+            je.setCompressedSize(classFile.length());
+            je.setSize(classFile.length());
+            je.setCrc(computeCRC(classFile));
+            je.setMethod(ZipEntry.STORED);
+            jos.putNextEntry(je);
+            copyStream(fis, bos);
+            bos.flush();
+            jos.closeEntry();
+        }
+    }
+
+    void createLargeJar(File jarFile, String comment) throws IOException {
+        final int MAX = Short.MAX_VALUE * 2 + 10;
+        JarEntry je = null;
+        File javaFile = new File("Foo.java");
+        File classFile = getClassFile(javaFile);
+        Manifest manifest = createMainClass(javaFile);
+        try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(jarFile), manifest);
+                FileInputStream fis = new FileInputStream(classFile)) {
+            jos.setLevel(JarOutputStream.STORED);
+            jos.setMethod(JarOutputStream.STORED);
+            for (int i = 0; i < MAX; i++) {
+                je = new JarEntry("X" + i + ".txt");
+                je.setSize(0);
+                je.setCompressedSize(0);
+                je.setCrc(0);
+                jos.putNextEntry(je);
+            }
+
+            // add a class file
+            je = new JarEntry(classFile.getName());
+            je.setCompressedSize(classFile.length());
+            je.setSize(classFile.length());
+            je.setCrc(computeCRC(classFile));
+            jos.putNextEntry(je);
+            copyStream(fis, jos);
+            jos.closeEntry();
+            if (comment != null) {
+                jos.setComment(comment);
+            }
+        }
+    }
+
+    void testTheJar(File theJar) throws Exception {
+        try {
+            TestResult tr = doExec(javaCmd, "-jar", theJar.getName());
+            tr.checkPositive();
+            if (!tr.testStatus) {
+                System.out.println(tr);
+                throw new Exception("Failed");
+            }
+        } finally {
+            theJar.delete();
+        }
+    }
+
+    // a jar with entries exceeding 64k + a class file for the existential test
+    @Test
+    void testScenarioA() throws Exception {
+        File largeJar = new File("large.jar");
+        createLargeJar(largeJar, null);
+        testTheJar(largeJar);
+    }
+
+     // a jar with entries exceeding 64k and zip comment
+    @Test
+    void testScenarioA1() throws Exception {
+        File largeJar = new File("largewithcomment.jar");
+        createLargeJar(largeJar, "A really large jar with a comment");
+        testTheJar(largeJar);
+    }
+
+    // a jar with an enormous file + a class file for the existential test
+    @Test
+    void testScenarioB() throws Exception {
+        final String testString = "BigJar_testScenarioB";
+        if (Boolean.getBoolean(testString) == false &&
+                System.getenv(testString) == null) {
+            System.out.println("Warning: testScenarioB passes vacuously");
+            return;
+        }
+        final File largeJar = new File("huge.jar");
+
+        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, absolute);
+            testTheJar(largeJar);
+        } else {
+            System.out.println("Warning: testScenarioB passes vacuously,"
+                    + " requirements exceeds available space");
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        BigJar bj = new BigJar();
+        bj.run(args);
+        if (testExitValue > 0) {
+            System.out.println("Total of " + testExitValue + " failed");
+            System.exit(1);
+        } else {
+            System.out.println("All tests pass");
+        }
+    }
+}
--- a/jdk/test/tools/launcher/TestHelper.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/jdk/test/tools/launcher/TestHelper.java	Tue Sep 25 11:48:00 2012 -0700
@@ -21,6 +21,8 @@
  * questions.
  */
 
+import java.io.OutputStream;
+import java.io.InputStream;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
@@ -243,6 +245,21 @@
         return null;
     }
 
+    static File getClassFile(File javaFile) {
+        String s = javaFile.getAbsolutePath().replace(JAVA_FILE_EXT, CLASS_FILE_EXT);
+        return new File(s);
+    }
+
+    static File getJavaFile(File classFile) {
+        String s = classFile.getAbsolutePath().replace(CLASS_FILE_EXT, JAVA_FILE_EXT);
+        return new File(s);
+    }
+
+    static String baseName(File f) {
+        String s = f.getName();
+        return s.substring(0, s.indexOf("."));
+    }
+
     /*
      * A convenience method to create a jar with jar file name and defs
      */
@@ -324,6 +341,15 @@
         }
    }
 
+   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);
+        }
+    }
+
    static void copyFile(File src, File dst) throws IOException {
         Path parent = dst.toPath().getParent();
         if (parent != null) {
--- a/langtools/.hgtags	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/.hgtags	Tue Sep 25 11:48:00 2012 -0700
@@ -176,3 +176,5 @@
 1d2db0e5eabc2eaf865986f7b7ffbf7b14b00232 jdk8-b52
 d3d0b9cd76e04bf9e381b402630ac3cfe464bb38 jdk8-b53
 9cf72631baf5cb1ebd8736c5efeab7746977ea68 jdk8-b54
+e48e7e1f026b82d921433150180799898c088890 jdk8-b55
+363e9198b9de68ebf37a3e2c2f3f23543d3915cd jdk8-b56
--- a/langtools/makefiles/Makefile	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/makefiles/Makefile	Tue Sep 25 11:48:00 2012 -0700
@@ -34,8 +34,9 @@
 # and the bootstrap javac, to be run by the bootdir jvm.
 $(eval $(call SetupJavaCompiler,BOOT_JAVAC,\
 	JAVAC:=$(JAVAC),\
-        FLAGS:=-Xprefer:source -XDignore.symbol.file=true -g,\
-        MODE:=SINGLE_THREADED_BATCH))
+        SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+        SERVER_JVM:=$(SJAVAC_SERVER_JAVA),\
+        FLAGS:=-XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror))
 
 # Now setup the compilation of the properties compilation tool. You can depend
 # upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we
@@ -43,6 +44,8 @@
 # program needs to be linked and run towards the new javac sources.
 $(eval $(call SetupJavaCompilation,BUILD_TOOLS,\
 		SETUP:=BOOT_JAVAC,\
+		DISABLE_SJAVAC:=true,\
+                ADD_JAVAC_FLAGS:=-Xprefer:source,\
 		SRC:=$(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes,\
 		INCLUDES:=compileproperties genstubs,\
 		BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses))
@@ -93,6 +96,7 @@
         # to compile javac again and to build the complete new jdk.
         $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS,\
 		SETUP:=BOOT_JAVAC,\
+		DISABLE_SJAVAC:=true,\
 		SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\
 		EXCLUDES:=com/sun/tools/javac/nio,\
 		BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap))
@@ -122,7 +126,7 @@
         # exercises the functionality to verify that it works.
         TOOL_GENSTUBS_CMD=$(JAVA) \
              "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
-             -cp "$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar$(PATH_SEP)$(LANGTOOLS_OUTPUTDIR)/btclasses" \
+             -classpath $(LANGTOOLS_OUTPUTDIR)/btclasses \
              genstubs.GenStubs
         # We fetch source from the JDK...
         JDKS=$(JDK_TOPDIR)/src/share/classes
@@ -164,11 +168,9 @@
                   JVM:=$(JAVA),\
                   JAVAC:="-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
 			 -jar $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\
-                  FLAGS:=-Xprefer:source -XDignore.symbol.file=true,\
-                  SERVER_DIR:=$(JAVAC_SERVERS),\
-                  SERVER_JVM:=$(SERVER_JAVA),\
-                  MODE:=$(JAVAC_USE_MODE),\
-		  USE_DEPS:=$(JAVAC_USE_DEPS)))
+                  FLAGS:=-XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror,\
+                  SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+                  SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
 
                 # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied.
 		RESOURCE_SUFFIXES:=.gif .xml .css javax.tools.JavaCompilerTool
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Annotations.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.code;
+
+import java.util.Map;
+import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.comp.Annotate;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Pair;
+
+import static com.sun.tools.javac.code.Kinds.PCK;
+import com.sun.tools.javac.util.*;
+
+/**
+ * Container for all annotations (attributes in javac) on a Symbol.
+ *
+ * This class is explicitly mutable. Its contents will change when attributes
+ * are annotated onto the Symbol. However this class depends on the facts that
+ * List (in javac) is immutable.
+ *
+ * An instance of this class can be in one of three states:
+ *
+ * NOT_STARTED indicates that the Symbol this instance belongs to have not been
+ * annotated (yet). Specifically if the declaration is not annotated this
+ * instance will never move past NOT_STARTED. You can never go back to
+ * NOT_STARTED.
+ *
+ * IN_PROGRESS annotations have been found on the declaration. Will be processed
+ * later. You can reset to IN_PROGRESS. While IN_PROGRESS you can set the list
+ * of attributes (and this moves out of the IN_PROGRESS state).
+ *
+ * "unnamed" this Annotations contains some attributes, possibly the final set.
+ * While in this state you can only prepend or append to the attributes not set
+ * it directly. You can also move back to the IN_PROGRESS sate using reset().
+ *
+ * <p><b>This is NOT part of any supported API. If you write code that depends
+ * on this, you do so at your own risk. This code and its internal interfaces
+ * are subject to change or deletion without notice.</b>
+ */
+public class Annotations {
+
+    private static final List<Attribute.Compound> NOT_STARTED = List.of(null);
+    private static final List<Attribute.Compound> IN_PROGRESS = List.of(null);
+    /*
+     * This field should never be null
+     */
+    private List<Attribute.Compound> attributes = NOT_STARTED;
+    /*
+     * The Symbol this Annotatios belong to
+     */
+    private final Symbol s;
+
+    public Annotations(Symbol s) {
+        this.s = s;
+    }
+
+    public List<Attribute.Compound> getAttributes() {
+        return filterSentinels(attributes);
+    }
+
+    public void setAttributes(List<Attribute.Compound> a) {
+        Assert.check(pendingCompletion() || !isStarted());
+        if (a == null) {
+            throw new NullPointerException();
+        }
+        attributes = a;
+    }
+
+    public void setAttributes(Annotations other) {
+        if (other == null) {
+            throw new NullPointerException();
+        }
+        setAttributes(other.getAttributes());
+    }
+
+    public void setAttributesWithCompletion(final Annotate.AnnotateRepeatedContext ctx) {
+        Assert.check(pendingCompletion() || (!isStarted() && s.kind == PCK));
+
+        Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated = ctx.annotated;
+        boolean atLeastOneRepeated = false;
+        List<Attribute.Compound> buf = List.<Attribute.Compound>nil();
+        for (ListBuffer<Attribute.Compound> lb : annotated.values()) {
+            if (lb.size() == 1) {
+                buf = buf.prepend(lb.first());
+            } else { // repeated
+                buf = buf.prepend(new Placeholder(lb.toList(), s));
+                atLeastOneRepeated = true;
+            }
+        }
+
+        // Add non-repeating attributes
+        setAttributes(buf.reverse());
+
+        if (atLeastOneRepeated) {
+            // The Symbol s is now annotated with a combination of
+            // finished non-repeating annotations and placeholders for
+            // repeating annotations.
+            //
+            // We need to do this in two passes because when creating
+            // a container for a repeating annotation we must
+            // guarantee that the @ContainedBy on the
+            // contained annotation is fully annotated
+            //
+            // The way we force this order is to do all repeating
+            // annotations in a pass after all non-repeating are
+            // finished. This will work because @ContainedBy
+            // is non-repeating and therefore will be annotated in the
+            // fist pass.
+
+            // Queue a pass that will replace Attribute.Placeholders
+            // with Attribute.Compound (made from synthesized containers).
+            ctx.annotateRepeated(new Annotate.Annotator() {
+
+                @Override
+                public String toString() {
+                    return "repeated annotation pass of: " + s + " in: " + s.owner;
+                }
+
+                @Override
+                public void enterAnnotation() {
+                    complete(ctx);
+                }
+            });
+        }
+    }
+
+    public Annotations reset() {
+        attributes = IN_PROGRESS;
+        return this;
+    }
+
+    public boolean isEmpty() {
+        return !isStarted()
+                || pendingCompletion()
+                || attributes.isEmpty();
+    }
+
+    public boolean pendingCompletion() {
+        return attributes == IN_PROGRESS;
+    }
+
+    public Annotations append(List<Attribute.Compound> l) {
+        attributes = filterSentinels(attributes);
+
+        if (l.isEmpty()) {
+            ; // no-op
+        } else if (attributes.isEmpty()) {
+            attributes = l;
+        } else {
+            attributes = attributes.appendList(l);
+        }
+        return this;
+    }
+
+    public Annotations prepend(List<Attribute.Compound> l) {
+        attributes = filterSentinels(attributes);
+
+        if (l.isEmpty()) {
+            ; // no-op
+        } else if (attributes.isEmpty()) {
+            attributes = l;
+        } else {
+            attributes = attributes.prependList(l);
+        }
+        return this;
+    }
+
+    private List<Attribute.Compound> filterSentinels(List<Attribute.Compound> a) {
+        return (a == IN_PROGRESS || a == NOT_STARTED)
+                ? List.<Attribute.Compound>nil()
+                : a;
+    }
+
+    private boolean isStarted() {
+        return attributes != NOT_STARTED;
+    }
+
+    private List<Attribute.Compound> getPlaceholders() {
+        List<Attribute.Compound> res = List.<Attribute.Compound>nil();
+        for (Attribute.Compound a : filterSentinels(attributes)) {
+            if (a instanceof Placeholder) {
+                res = res.prepend(a);
+            }
+        }
+        return res.reverse();
+    }
+
+    /*
+     * Replace Placeholders for repeating annotations with their containers
+     */
+    private void complete(Annotate.AnnotateRepeatedContext ctx) {
+        Assert.check(!pendingCompletion());
+        Log log = ctx.log;
+        Env<AttrContext> env = ctx.env;
+        JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
+        try {
+
+            if (isEmpty()) {
+                return;
+            }
+
+            List<Attribute.Compound> result = List.nil();
+            for (Attribute.Compound a : getAttributes()) {
+                if (a instanceof Placeholder) {
+                    Attribute.Compound replacement = replaceOne((Placeholder) a, ctx);
+
+                    if (null != replacement) {
+                        result = result.prepend(replacement);
+                    }
+                } else {
+                    result = result.prepend(a);
+                }
+            }
+
+            attributes = result.reverse();
+
+            Assert.check(Annotations.this.getPlaceholders().isEmpty());
+        } finally {
+            log.useSource(oldSource);
+        }
+    }
+
+    private Attribute.Compound replaceOne(Placeholder placeholder, Annotate.AnnotateRepeatedContext ctx) {
+        Log log = ctx.log;
+
+        // Process repeated annotations
+        Attribute.Compound validRepeated =
+                ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor());
+
+        if (validRepeated != null) {
+            // Check that the container isn't manually
+            // present along with repeated instances of
+            // its contained annotation.
+            ListBuffer<Attribute.Compound> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
+            if (manualContainer != null) {
+                log.error(ctx.pos.get(manualContainer.first()), "invalid.containedby.annotation.repeated.and.container.present",
+                        manualContainer.first().type.tsym);
+            }
+        }
+
+        // A null return will delete the Placeholder
+        return validRepeated;
+
+    }
+
+    private static class Placeholder extends Attribute.Compound {
+
+        private List<Attribute.Compound> placeholderFor;
+        private Symbol on;
+
+        public Placeholder(List<Attribute.Compound> placeholderFor, Symbol on) {
+            super(Type.noType, List.<Pair<Symbol.MethodSymbol, Attribute>>nil());
+            this.placeholderFor = placeholderFor;
+            this.on = on;
+        }
+
+        @Override
+        public String toString() {
+            return "<placeholder: " + placeholderFor + " on: " + on + ">";
+        }
+
+        public List<Attribute.Compound> getPlaceholderFor() {
+            return placeholderFor;
+        }
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -103,11 +103,11 @@
      *  represented as a ClassSymbol.
      */
     public static class Class extends Attribute {
-        public final Type type;
+        public final Type classType;
         public void accept(Visitor v) { v.visitClass(this); }
         public Class(Types types, Type type) {
             super(makeClassType(types, type));
-            this.type = type;
+            this.classType = type;
         }
         static Type makeClassType(Types types, Type type) {
             Type arg = type.isPrimitive()
@@ -118,13 +118,13 @@
                                       types.syms.classType.tsym);
         }
         public String toString() {
-            return type + ".class";
+            return classType + ".class";
         }
         public Type getValue() {
-            return type;
+            return classType;
         }
         public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
-            return v.visitType(type, p);
+            return v.visitType(classType, p);
         }
     }
 
@@ -212,6 +212,12 @@
             super(type);
             this.values = values;
         }
+
+        public Array(Type type, List<Attribute> values) {
+            super(type);
+            this.values = values.toArray(new Attribute[values.size()]);
+        }
+
         public void accept(Visitor v) { v.visitArray(this); }
         public String toString() {
             StringBuilder buf = new StringBuilder();
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,16 +70,16 @@
      * Returns the result of combining the values in this object with
      * the given annotations.
      */
-    public Lint augment(List<Attribute.Compound> attrs) {
-        return augmentor.augment(this, attrs);
+    public Lint augment(Annotations annots) {
+        return augmentor.augment(this, annots.getAttributes());
     }
 
     /**
      * Returns the result of combining the values in this object with
      * the given annotations and flags.
      */
-    public Lint augment(List<Attribute.Compound> attrs, long flags) {
-        Lint l = augmentor.augment(this, attrs);
+    public Lint augment(Annotations annots, long flags) {
+        Lint l = augmentor.augment(this, annots.getAttributes());
         if ((flags & DEPRECATED) != 0) {
             if (l == this)
                 l = new Lint(this);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java	Tue Sep 25 11:48:00 2012 -0700
@@ -203,6 +203,9 @@
     public boolean allowEffectivelyFinalInInnerClasses() {
         return compareTo(JDK1_8) >= 0;
     }
+    public boolean allowRepeatedAnnotations() {
+        return compareTo(JDK1_8) >= 0;
+    }
     public static SourceVersion toSourceVersion(Source source) {
         switch(source) {
         case JDK1_2:
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Sep 25 11:48:00 2012 -0700
@@ -72,22 +72,24 @@
      */
     public long flags() { return flags_field; }
 
-    /** The attributes of this symbol.
+    /** The attributes of this symbol are contained in this
+     * Annotations. The Annotations instance is NOT immutable.
      */
-    public List<Attribute.Compound> attributes_field;
+    public final Annotations annotations = new Annotations(this);
 
     /** An accessor method for the attributes of this symbol.
      *  Attributes of class symbols should be accessed through the accessor
      *  method to make sure that the class symbol is loaded.
      */
     public List<Attribute.Compound> getAnnotationMirrors() {
-        return Assert.checkNonNull(attributes_field);
+        return Assert.checkNonNull(annotations.getAttributes());
     }
 
     /** Fetch a particular annotation from a symbol. */
     public Attribute.Compound attribute(Symbol anno) {
-        for (Attribute.Compound a : getAnnotationMirrors())
+        for (Attribute.Compound a : getAnnotationMirrors()) {
             if (a.type.tsym == anno) return a;
+        }
         return null;
     }
 
@@ -120,7 +122,6 @@
         this.owner = owner;
         this.completer = null;
         this.erasure_field = null;
-        this.attributes_field = List.nil();
         this.name = name;
     }
 
@@ -657,10 +658,11 @@
             if (completer != null) complete();
             if (package_info != null && package_info.completer != null) {
                 package_info.complete();
-                if (attributes_field.isEmpty())
-                    attributes_field = package_info.attributes_field;
+                if (annotations.isEmpty()) {
+                    annotations.setAttributes(package_info.annotations);
             }
-            return Assert.checkNonNull(attributes_field);
+            }
+            return Assert.checkNonNull(annotations.getAttributes());
         }
 
         /** A package "exists" if a type or package that exists has
@@ -762,7 +764,7 @@
 
         public List<Attribute.Compound> getAnnotationMirrors() {
             if (completer != null) complete();
-            return Assert.checkNonNull(attributes_field);
+            return Assert.checkNonNull(annotations.getAttributes());
         }
 
         public Type erasure(Types types) {
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java	Tue Sep 25 11:48:00 2012 -0700
@@ -156,6 +156,10 @@
     public final Type systemType;
     public final Type autoCloseableType;
     public final Type trustMeType;
+    public final Type containedByType;
+    public final Type containerForType;
+    public final Type documentedType;
+    public final Type elementTypeType;
 
     /** The symbol representing the length field of an array.
      */
@@ -468,6 +472,10 @@
         deprecatedType = enterClass("java.lang.Deprecated");
         suppressWarningsType = enterClass("java.lang.SuppressWarnings");
         inheritedType = enterClass("java.lang.annotation.Inherited");
+        containedByType = enterClass("java.lang.annotation.ContainedBy");
+        containerForType = enterClass("java.lang.annotation.ContainerFor");
+        documentedType = enterClass("java.lang.annotation.Documented");
+        elementTypeType = enterClass("java.lang.annotation.ElementType");
         systemType = enterClass("java.lang.System");
         autoCloseableType = enterClass("java.lang.AutoCloseable");
         autoCloseableClose = new MethodSymbol(PUBLIC,
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1358,6 +1358,20 @@
         }
         return result;
     }
+
+    /**
+     * Returns an ArrayType with the component type t
+     *
+     * @param t The component type of the ArrayType
+     * @return the ArrayType for the given component
+     */
+    public ArrayType makeArrayType(Type t) {
+        if (t.tag == VOID ||
+            t.tag >= PACKAGE) {
+            Assert.error("Type t must not be a a VOID or PACKAGE type, " + t.toString());
+        }
+        return new ArrayType(t, syms.arrayClass);
+    }
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="asSuper">
@@ -3811,8 +3825,12 @@
     // <editor-fold defaultstate="collapsed" desc="Annotation support">
 
     public RetentionPolicy getRetention(Attribute.Compound a) {
+        return getRetention(a.type.tsym);
+    }
+
+    public RetentionPolicy getRetention(Symbol sym) {
         RetentionPolicy vis = RetentionPolicy.CLASS; // the default
-        Attribute.Compound c = a.type.tsym.attribute(syms.retentionType.tsym);
+        Attribute.Compound c = sym.attribute(syms.retentionType.tsym);
         if (c != null) {
             Attribute value = c.member(names.value);
             if (value != null && value instanceof Attribute.Enum) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,11 @@
 
 package com.sun.tools.javac.comp;
 
+import java.util.Map;
+import java.util.Objects;
+
 import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.*;
@@ -83,8 +87,9 @@
     private int enterCount = 0;
 
     ListBuffer<Annotator> q = new ListBuffer<Annotator>();
+    ListBuffer<Annotator> repeatedQ = new ListBuffer<Annotator>();
 
-    public void later(Annotator a) {
+    public void normal(Annotator a) {
         q.append(a);
     }
 
@@ -92,6 +97,10 @@
         q.prepend(a);
     }
 
+    public void repeated(Annotator a) {
+        repeatedQ.append(a);
+    }
+
     /** Called when the Enter phase starts. */
     public void enterStart() {
         enterCount++;
@@ -109,6 +118,10 @@
         try {
             while (q.nonEmpty())
                 q.next().enterAnnotation();
+
+            while (repeatedQ.nonEmpty()) {
+                repeatedQ.next().enterAnnotation();
+            }
         } finally {
             enterCount--;
         }
@@ -124,6 +137,53 @@
         String toString();
     }
 
+    /**
+     * This context contains all the information needed to synthesize new
+     * annotations trees by the completer for repeating annotations.
+     */
+    public class AnnotateRepeatedContext {
+        public final Env<AttrContext> env;
+        public final Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated;
+        public final Map<Attribute.Compound, JCDiagnostic.DiagnosticPosition> pos;
+        public final Log log;
+
+        public AnnotateRepeatedContext(Env<AttrContext> env,
+                                       Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated,
+                                       Map<Attribute.Compound, JCDiagnostic.DiagnosticPosition> pos,
+                                       Log log) {
+            Objects.requireNonNull(env);
+            Objects.requireNonNull(annotated);
+            Objects.requireNonNull(pos);
+            Objects.requireNonNull(log);
+
+            this.env = env;
+            this.annotated = annotated;
+            this.pos = pos;
+            this.log = log;
+        }
+
+        /**
+         * Process a list of repeating annotations returning a new
+         * Attribute.Compound that is the attribute for the synthesized tree
+         * for the container.
+         *
+         * @param repeatingAnnotations a List of repeating annotations
+         * @return a new Attribute.Compound that is the container for the repeatingAnnotations
+         */
+        public Attribute.Compound processRepeatedAnnotations(List<Attribute.Compound> repeatingAnnotations) {
+            return Annotate.this.processRepeatedAnnotations(repeatingAnnotations, this);
+        }
+
+        /**
+         * Queue the Annotator a on the repeating annotations queue of the
+         * Annotate instance this context belongs to.
+         *
+         * @param a the Annotator to enqueue for repeating annotation annotating
+         */
+        public void annotateRepeated(Annotator a) {
+            Annotate.this.repeated(a);
+        }
+    }
 
 /* ********************************************************************
  * Compute an attribute from its annotation.
@@ -268,4 +328,219 @@
             log.error(tree.pos(), "annotation.value.not.allowable.type");
         return new Attribute.Error(attr.attribExpr(tree, env, expected));
     }
+
+    /* *********************************
+     * Support for repeating annotations
+     ***********************************/
+
+    /* Process repeated annotations. This method returns the
+     * synthesized container annotation or null IFF all repeating
+     * annotation are invalid.  This method reports errors/warnings.
+     */
+    private Attribute.Compound processRepeatedAnnotations(List<Attribute.Compound> annotations,
+            AnnotateRepeatedContext ctx) {
+        Attribute.Compound firstOccurrence = annotations.head;
+        List<Attribute> repeated = List.nil();
+        Type origAnnoType;
+        Type arrayOfOrigAnnoType = null;
+        Type targetContainerType = null;
+        MethodSymbol containerValueSymbol = null;
+
+        Assert.check(!annotations.isEmpty() &&
+                     !annotations.tail.isEmpty()); // i.e. size() > 1
+
+        for (List<Attribute.Compound> al = annotations;
+             !al.isEmpty();
+             al = al.tail)
+        {
+            Attribute.Compound currentAnno = al.head;
+
+            origAnnoType = currentAnno.type;
+            if (arrayOfOrigAnnoType == null) {
+                arrayOfOrigAnnoType = types.makeArrayType(origAnnoType);
 }
+
+            Type currentContainerType = getContainingType(currentAnno, ctx.pos.get(currentAnno));
+            if (currentContainerType == null) {
+                continue;
+            }
+            // Assert that the target Container is == for all repeated
+            // annos of the same annotation type, the types should
+            // come from the same Symbol, i.e. be '=='
+            Assert.check(targetContainerType == null || currentContainerType == targetContainerType);
+            targetContainerType = currentContainerType;
+
+            containerValueSymbol = validateContainer(targetContainerType, origAnnoType, ctx.pos.get(currentAnno));
+
+            if (containerValueSymbol == null) { // Check of CA type failed
+                // errors are already reported
+                continue;
+            }
+
+            repeated = repeated.prepend(currentAnno);
+        }
+
+        if (!repeated.isEmpty()) {
+            repeated = repeated.reverse();
+            JCAnnotation annoTree;
+            TreeMaker m = make.at(ctx.pos.get(firstOccurrence));
+            Pair<MethodSymbol, Attribute> p =
+                    new Pair<MethodSymbol, Attribute>(containerValueSymbol,
+                                                      new Attribute.Array(arrayOfOrigAnnoType, repeated));
+            annoTree = m.Annotation(new Attribute.Compound(targetContainerType,
+                    List.of(p)));
+            Attribute.Compound c = enterAnnotation(annoTree,
+                                                   targetContainerType,
+                                                   ctx.env);
+            return c;
+        } else {
+            return null; // errors should have been reported elsewhere
+        }
+    }
+
+    /** Fetches the actual Type that should be the containing annotation. */
+    private Type getContainingType(Attribute.Compound currentAnno,
+            DiagnosticPosition pos)
+    {
+        Type origAnnoType = currentAnno.type;
+        TypeSymbol origAnnoDecl = origAnnoType.tsym;
+
+        // Fetch the ContainedBy annotation from the current
+        // annotation's declaration, or null if it has none
+        Attribute.Compound ca = origAnnoDecl.attribute(syms.containedByType.tsym);
+        if (ca == null) { // has no ContainedBy annotation
+            log.error(pos, "duplicate.annotation.missing.container", origAnnoType);
+            return null;
+        }
+
+        return filterSame(extractContainingType(ca, pos, origAnnoDecl),
+                          origAnnoType);
+    }
+
+    // returns null if t is same as 's', returns 't' otherwise
+    private Type filterSame(Type t, Type s) {
+        if (t == null || s == null) {
+            return t;
+        }
+
+        return types.isSameType(t, s) ? null : t;
+    }
+
+    /** Extract the actual Type to be used for a containing annotation. */
+    private Type extractContainingType(Attribute.Compound ca,
+            DiagnosticPosition pos,
+            TypeSymbol annoDecl)
+    {
+        // The next three checks check that the ContainedBy annotation
+        // on the declaration of the annotation type that is repeating is
+        // valid.
+
+        // ContainedBy must have at least one element
+        if (ca.values.isEmpty()) {
+            log.error(pos, "invalid.containedby.annotation", annoDecl);
+            return null;
+        }
+        Pair<MethodSymbol,Attribute> p = ca.values.head;
+        Name name = p.fst.name;
+        if (name != names.value) { // should contain only one element, named "value"
+            log.error(pos, "invalid.containedby.annotation", annoDecl);
+            return null;
+        }
+        if (!(p.snd instanceof Attribute.Class)) { // check that the value of "value" is an Attribute.Class
+            log.error(pos, "invalid.containedby.annotation", annoDecl);
+            return null;
+        }
+
+        return ((Attribute.Class)p.snd).getValue();
+    }
+
+    /* Validate that the suggested targetContainerType Type is a valid
+     * container type for repeated instances of originalAnnoType
+     * annotations. Return null and report errors if this is not the
+     * case, return the MethodSymbol of the value element in
+     * targetContainerType if it is suitable (this is needed to
+     * synthesize the container). */
+    private MethodSymbol validateContainer(Type targetContainerType,
+                                           Type originalAnnoType,
+                                           DiagnosticPosition pos) {
+        MethodSymbol containerValueSymbol = null;
+        boolean fatalError = false;
+
+        // Validate that there is a (and only 1) value method
+        Scope scope = targetContainerType.tsym.members();
+        int nr_value_elems = 0;
+        boolean error = false;
+        for(Symbol elm : scope.getElementsByName(names.value)) {
+            nr_value_elems++;
+
+            if (nr_value_elems == 1 &&
+                elm.kind == Kinds.MTH) {
+                containerValueSymbol = (MethodSymbol)elm;
+            } else {
+                error = true;
+            }
+        }
+        if (error) {
+            log.error(pos,
+                      "invalid.containedby.annotation.multiple.values",
+                      targetContainerType,
+                      nr_value_elems);
+            return null;
+        } else if (nr_value_elems == 0) {
+            log.error(pos,
+                      "invalid.containedby.annotation.no.value",
+                      targetContainerType);
+            return null;
+        }
+
+        // validate that the 'value' element is a method
+        // probably "impossible" to fail this
+        if (containerValueSymbol.kind != Kinds.MTH) {
+            log.error(pos,
+                      "invalid.containedby.annotation.invalid.value",
+                      targetContainerType);
+            fatalError = true;
+        }
+
+        // validate that the 'value' element has the correct return type
+        // i.e. array of original anno
+        Type valueRetType = containerValueSymbol.type.getReturnType();
+        Type expectedType = types.makeArrayType(originalAnnoType);
+        if (!(types.isArray(valueRetType) &&
+              types.isSameType(expectedType, valueRetType))) {
+            log.error(pos,
+                      "invalid.containedby.annotation.value.return",
+                      targetContainerType,
+                      valueRetType,
+                      expectedType);
+            fatalError = true;
+        }
+
+        // validate that all other elements of containing type has defaults
+        scope = targetContainerType.tsym.members();
+        error = false;
+        for(Symbol elm : scope.getElements()) {
+            if (elm.name != names.value &&
+                elm.kind == Kinds.MTH &&
+                ((MethodSymbol)elm).defaultValue == null) {
+                log.error(pos,
+                          "invalid.containedby.annotation.elem.nondefault",
+                          targetContainerType,
+                          elm);
+                containerValueSymbol = null;
+                error = true;
+            }
+        }
+        if (error) {
+            fatalError = true;
+        }
+
+        // Explicitly no check for/validity of @ContainerFor. That is
+        // done on declaration of the container, and at reflect time.
+
+        // The rest of the conditions for a valid containing annotation are made
+        // in Check.validateRepeatedAnnotaton();
+
+        return fatalError ? null : containerValueSymbol;
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Sep 25 11:48:00 2012 -0700
@@ -662,10 +662,12 @@
         // env.info.enclVar.attributes_field might not yet have been evaluated, and so might be
         // null. In that case, calling augment will throw an NPE. To avoid this, for now we
         // revert to the jdk 6 behavior and ignore the (unevaluated) attributes.
-        if (env.info.enclVar.attributes_field == null)
+        if (env.info.enclVar.annotations.pendingCompletion()) {
             env.info.lint = lintEnv.info.lint;
-        else
-            env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.attributes_field, env.info.enclVar.flags());
+        } else {
+            env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.annotations,
+                                                      env.info.enclVar.flags());
+        }
 
         Lint prevLint = chk.setLint(env.info.lint);
         JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
@@ -776,7 +778,7 @@
     public void visitMethodDef(JCMethodDecl tree) {
         MethodSymbol m = tree.sym;
 
-        Lint lint = env.info.lint.augment(m.attributes_field, m.flags());
+        Lint lint = env.info.lint.augment(m.annotations, m.flags());
         Lint prevLint = chk.setLint(lint);
         MethodSymbol prevMethod = chk.setMethod(m);
         try {
@@ -921,7 +923,7 @@
         }
 
         VarSymbol v = tree.sym;
-        Lint lint = env.info.lint.augment(v.attributes_field, v.flags());
+        Lint lint = env.info.lint.augment(v.annotations, v.flags());
         Lint prevLint = chk.setLint(lint);
 
         // Check that the variable's declared type is well-formed.
@@ -3069,7 +3071,7 @@
                 lintEnv = lintEnv.next;
 
             // Having found the enclosing lint value, we can initialize the lint value for this class
-            env.info.lint = lintEnv.info.lint.augment(c.attributes_field, c.flags());
+            env.info.lint = lintEnv.info.lint.augment(c.annotations, c.flags());
 
             Lint prevLint = chk.setLint(env.info.lint);
             JavaFileObject prev = log.useSource(c.sourcefile);
@@ -3133,6 +3135,26 @@
             if (tree.typarams.nonEmpty())
                 log.error(tree.typarams.head.pos(),
                           "intf.annotation.cant.have.type.params");
+
+            // If this annotation has a @ContainedBy, validate
+            Attribute.Compound containedBy = c.attribute(syms.containedByType.tsym);
+            if (containedBy != null) {
+                // get diagnositc position for error reporting
+                DiagnosticPosition cbPos = getDiagnosticPosition(tree, containedBy.type);
+                Assert.checkNonNull(cbPos);
+
+                chk.validateContainedBy(c, containedBy, cbPos);
+            }
+
+            // If this annotation has a @ContainerFor, validate
+            Attribute.Compound containerFor = c.attribute(syms.containerForType.tsym);
+            if (containerFor != null) {
+                // get diagnositc position for error reporting
+                DiagnosticPosition cfPos = getDiagnosticPosition(tree, containerFor.type);
+                Assert.checkNonNull(cfPos);
+
+                chk.validateContainerFor(c, containerFor, cfPos);
+            }
         } else {
             // Check that all extended classes and interfaces
             // are compatible (i.e. no two define methods with same arguments
@@ -3194,6 +3216,16 @@
         }
     }
         // where
+        /** get a diagnostic position for an attribute of Type t, or null if attribute missing */
+        private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) {
+            for(List<JCAnnotation> al = tree.mods.annotations; !al.isEmpty(); al = al.tail) {
+                if (types.isSameType(al.head.annotationType.type, t))
+                    return al.head.pos();
+            }
+
+            return null;
+        }
+
         /** check if a class is a subtype of Serializable, if that is available. */
         private boolean isSerializable(ClassSymbol c) {
             try {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue Sep 25 11:48:00 2012 -0700
@@ -69,7 +69,6 @@
     private final Infer infer;
     private final Types types;
     private final JCDiagnostic.Factory diags;
-    private final boolean skipAnnotations;
     private boolean warnOnSyntheticConflicts;
     private boolean suppressAbortOnBadClassFile;
     private boolean enableSunApiLintControl;
@@ -113,7 +112,6 @@
         allowCovariantReturns = source.allowCovariantReturns();
         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
         complexInference = options.isSet("complexinference");
-        skipAnnotations = options.isSet("skipAnnotations");
         warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
         suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
         enableSunApiLintControl = options.isSet("enableSunApiLintControl");
@@ -2422,14 +2420,13 @@
     /** Check the annotations of a symbol.
      */
     public void validateAnnotations(List<JCAnnotation> annotations, Symbol s) {
-        if (skipAnnotations) return;
         for (JCAnnotation a : annotations)
             validateAnnotation(a, s);
     }
 
     /** Check an annotation of a symbol.
      */
-    public void validateAnnotation(JCAnnotation a, Symbol s) {
+    private void validateAnnotation(JCAnnotation a, Symbol s) {
         validateAnnotationTree(a);
 
         if (!annotationApplicable(a, s))
@@ -2441,6 +2438,215 @@
         }
     }
 
+    /**
+     * Validate the proposed container 'containedBy' on the
+     * annotation type symbol 's'. Report errors at position
+     * 'pos'.
+     *
+     * @param s The (annotation)type declaration annotated with a @ContainedBy
+     * @param containerAnno the @ContainedBy on 's'
+     * @param pos where to report errors
+     */
+    public void validateContainedBy(TypeSymbol s, Attribute.Compound containedBy, DiagnosticPosition pos) {
+        Assert.check(types.isSameType(containedBy.type, syms.containedByType));
+
+        Type t = null;
+        List<Pair<MethodSymbol,Attribute>> l = containedBy.values;
+        if (!l.isEmpty()) {
+            Assert.check(l.head.fst.name == names.value);
+            t = ((Attribute.Class)l.head.snd).getValue();
+        }
+
+        if (t == null) {
+            log.error(pos, "invalid.container.wrong.containedby", s, containedBy);
+            return;
+        }
+
+        validateHasContainerFor(t.tsym, s, pos);
+        validateRetention(t.tsym, s, pos);
+        validateDocumented(t.tsym, s, pos);
+        validateInherited(t.tsym, s, pos);
+        validateTarget(t.tsym, s, pos);
+    }
+
+    /**
+     * Validate the proposed container 'containerFor' on the
+     * annotation type symbol 's'. Report errors at position
+     * 'pos'.
+     *
+     * @param s The (annotation)type declaration annotated with a @ContainerFor
+     * @param containerFor the @ContainedFor on 's'
+     * @param pos where to report errors
+     */
+    public void validateContainerFor(TypeSymbol s, Attribute.Compound containerFor, DiagnosticPosition pos) {
+        Assert.check(types.isSameType(containerFor.type, syms.containerForType));
+
+        Type t = null;
+        List<Pair<MethodSymbol,Attribute>> l = containerFor.values;
+        if (!l.isEmpty()) {
+            Assert.check(l.head.fst.name == names.value);
+            t = ((Attribute.Class)l.head.snd).getValue();
+        }
+
+        if (t == null) {
+            log.error(pos, "invalid.container.wrong.containerfor", s, containerFor);
+            return;
+        }
+
+        validateHasContainedBy(t.tsym, s, pos);
+    }
+
+    private void validateHasContainedBy(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) {
+        Attribute.Compound containedBy = container.attribute(syms.containedByType.tsym);
+
+        if (containedBy == null) {
+            log.error(pos, "invalid.container.no.containedby", container, syms.containedByType.tsym);
+            return;
+        }
+
+        Type t = null;
+        List<Pair<MethodSymbol,Attribute>> l = containedBy.values;
+        if (!l.isEmpty()) {
+            Assert.check(l.head.fst.name == names.value);
+            t = ((Attribute.Class)l.head.snd).getValue();
+        }
+
+        if (t == null) {
+            log.error(pos, "invalid.container.wrong.containedby", container, contained);
+            return;
+        }
+
+        if (!types.isSameType(t, contained.type))
+            log.error(pos, "invalid.container.wrong.containedby", t.tsym, contained);
+    }
+
+    private void validateHasContainerFor(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) {
+        Attribute.Compound containerFor = container.attribute(syms.containerForType.tsym);
+
+        if (containerFor == null) {
+            log.error(pos, "invalid.container.no.containerfor", container, syms.containerForType.tsym);
+            return;
+        }
+
+        Type t = null;
+        List<Pair<MethodSymbol,Attribute>> l = containerFor.values;
+        if (!l.isEmpty()) {
+            Assert.check(l.head.fst.name == names.value);
+            t = ((Attribute.Class)l.head.snd).getValue();
+        }
+
+        if (t == null) {
+            log.error(pos, "invalid.container.wrong.containerfor", container, contained);
+            return;
+        }
+
+        if (!types.isSameType(t, contained.type))
+            log.error(pos, "invalid.container.wrong.containerfor", t.tsym, contained);
+    }
+
+    private void validateRetention(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        Attribute.RetentionPolicy containerRetention = types.getRetention(container);
+        Attribute.RetentionPolicy containedRetention = types.getRetention(contained);
+
+        boolean error = false;
+        switch (containedRetention) {
+        case RUNTIME:
+            if (containerRetention != Attribute.RetentionPolicy.RUNTIME) {
+                error = true;
+            }
+            break;
+        case CLASS:
+            if (containerRetention == Attribute.RetentionPolicy.SOURCE)  {
+                error = true;
+            }
+        }
+        if (error ) {
+            log.error(pos, "invalid.containedby.annotation.retention",
+                      container, containerRetention,
+                      contained, containedRetention);
+        }
+    }
+
+    private void validateDocumented(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        if (contained.attribute(syms.documentedType.tsym) != null) {
+            if (container.attribute(syms.documentedType.tsym) == null) {
+                log.error(pos, "invalid.containedby.annotation.not.documented", container, contained);
+            }
+        }
+    }
+
+    private void validateInherited(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        if (contained.attribute(syms.inheritedType.tsym) != null) {
+            if (container.attribute(syms.inheritedType.tsym) == null) {
+                log.error(pos, "invalid.containedby.annotation.not.inherited", container, contained);
+            }
+        }
+    }
+
+    private void validateTarget(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        Attribute.Array containedTarget = getAttributeTargetAttribute(contained);
+
+        // If contained has no Target, we are done
+        if (containedTarget == null) {
+            return;
+        }
+
+        // If contained has Target m1, container must have a Target
+        // annotation, m2, and m2 must be a subset of m1. (This is
+        // trivially true if contained has no target as per above).
+
+        // contained has target, but container has not, error
+        Attribute.Array containerTarget = getAttributeTargetAttribute(container);
+        if (containerTarget == null) {
+            log.error(pos, "invalid.containedby.annotation.incompatible.target", container, contained);
+            return;
+        }
+
+        Set<Name> containerTargets = new HashSet<Name>();
+        for (Attribute app : containerTarget.values) {
+            if (!(app instanceof Attribute.Enum)) {
+                continue; // recovery
+            }
+            Attribute.Enum e = (Attribute.Enum)app;
+            containerTargets.add(e.value.name);
+        }
+
+        Set<Name> containedTargets = new HashSet<Name>();
+        for (Attribute app : containedTarget.values) {
+            if (!(app instanceof Attribute.Enum)) {
+                continue; // recovery
+            }
+            Attribute.Enum e = (Attribute.Enum)app;
+            containedTargets.add(e.value.name);
+        }
+
+        if (!isTargetSubset(containedTargets, containerTargets)) {
+            log.error(pos, "invalid.containedby.annotation.incompatible.target", container, contained);
+        }
+    }
+
+    /** Checks that t is a subset of s, with respect to ElementType
+     * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE}
+     */
+    private boolean isTargetSubset(Set<Name> s, Set<Name> t) {
+        // Check that all elements in t are present in s
+        for (Name n2 : t) {
+            boolean currentElementOk = false;
+            for (Name n1 : s) {
+                if (n1 == n2) {
+                    currentElementOk = true;
+                    break;
+                } else if (n1 == names.TYPE && n2 == names.ANNOTATION_TYPE) {
+                    currentElementOk = true;
+                    break;
+                }
+            }
+            if (!currentElementOk)
+                return false;
+        }
+        return true;
+    }
+
     /** Is s a method symbol that overrides a method in a superclass? */
     boolean isOverrider(Symbol s) {
         if (s.kind != MTH || s.isStatic())
@@ -2461,12 +2667,10 @@
 
     /** Is the annotation applicable to the symbol? */
     boolean annotationApplicable(JCAnnotation a, Symbol s) {
-        Attribute.Compound atTarget =
-            a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym);
-        if (atTarget == null) return true;
-        Attribute atValue = atTarget.member(names.value);
-        if (!(atValue instanceof Attribute.Array)) return true; // error recovery
-        Attribute.Array arr = (Attribute.Array) atValue;
+        Attribute.Array arr = getAttributeTargetAttribute(a.annotationType.type.tsym);
+        if (arr == null) {
+            return true;
+        }
         for (Attribute app : arr.values) {
             if (!(app instanceof Attribute.Enum)) return true; // recovery
             Attribute.Enum e = (Attribute.Enum) app;
@@ -2508,6 +2712,16 @@
         return false;
     }
 
+
+    Attribute.Array getAttributeTargetAttribute(Symbol s) {
+        Attribute.Compound atTarget =
+            s.attribute(syms.annotationTargetType.tsym);
+        if (atTarget == null) return null; // ok, is applicable
+        Attribute atValue = atTarget.member(names.value);
+        if (!(atValue instanceof Attribute.Array)) return null; // error recovery
+        return (Attribute.Array) atValue;
+    }
+
     /** Check an annotation value.
      */
     public void validateAnnotation(JCAnnotation a) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java	Tue Sep 25 11:48:00 2012 -0700
@@ -157,7 +157,7 @@
         Env<AttrContext> lintEnv = localEnv;
         while (lintEnv.info.lint == null)
             lintEnv = lintEnv.next;
-        localEnv.info.lint = lintEnv.info.lint.augment(sym.attributes_field, sym.flags());
+        localEnv.info.lint = lintEnv.info.lint.augment(sym.annotations, sym.flags());
         return localEnv;
     }
 
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Tue Sep 25 11:48:00 2012 -0700
@@ -406,7 +406,7 @@
             Lint lintPrev = lint;
 
             pendingExits = new ListBuffer<PendingExit>();
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             try {
                 // process all the static initializers
@@ -442,7 +442,7 @@
             if (tree.body == null) return;
             Lint lintPrev = lint;
 
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             Assert.check(pendingExits.isEmpty());
 
@@ -468,7 +468,7 @@
         public void visitVarDef(JCVariableDecl tree) {
             if (tree.init != null) {
                 Lint lintPrev = lint;
-                lint = lint.augment(tree.sym.attributes_field);
+                lint = lint.augment(tree.sym.annotations);
                 try{
                     scan(tree.init);
                 } finally {
@@ -783,7 +783,7 @@
             }
             classDef = tree;
             thrown = List.nil();
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             try {
                 // process all the static initializers
@@ -863,7 +863,7 @@
             List<Type> mthrown = tree.sym.type.getThrownTypes();
             Lint lintPrev = lint;
 
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             Assert.check(pendingExits.isEmpty());
 
@@ -902,7 +902,7 @@
         public void visitVarDef(JCVariableDecl tree) {
             if (tree.init != null) {
                 Lint lintPrev = lint;
-                lint = lint.augment(tree.sym.attributes_field);
+                lint = lint.augment(tree.sym.annotations);
                 try{
                     scan(tree.init);
                 } finally {
@@ -1491,7 +1491,7 @@
                 firstadr = nextadr;
             }
             classDef = tree;
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             try {
                 // define all the static fields
@@ -1558,7 +1558,7 @@
             int firstadrPrev = firstadr;
             Lint lintPrev = lint;
 
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             Assert.check(pendingExits.isEmpty());
 
@@ -1609,7 +1609,7 @@
             if (track && tree.sym.owner.kind == MTH) newVar(tree.sym);
             if (tree.init != null) {
                 Lint lintPrev = lint;
-                lint = lint.augment(tree.sym.attributes_field);
+                lint = lint.augment(tree.sym.annotations);
                 try{
                     scanExpr(tree.init);
                     if (track) letInit(tree.pos(), tree.sym);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Tue Sep 25 11:48:00 2012 -0700
@@ -2257,7 +2257,7 @@
                                 null, List.<JCExpression>nil(), List.<JCTree>nil());
             ClassSymbol c = tree.packge.package_info;
             c.flags_field |= flags;
-            c.attributes_field = tree.packge.attributes_field;
+            c.annotations.setAttributes(tree.packge.annotations);
             ClassType ctype = (ClassType) c.type;
             ctype.supertype_field = syms.objectType;
             ctype.interfaces_field = List.nil();
@@ -2274,7 +2274,8 @@
             case LEGACY:
                 return tree.packageAnnotations.nonEmpty();
             case NONEMPTY:
-                for (Attribute.Compound a: tree.packge.attributes_field) {
+                for (Attribute.Compound a :
+                         tree.packge.annotations.getAttributes()) {
                     Attribute.RetentionPolicy p = types.getRetention(a);
                     if (p != Attribute.RetentionPolicy.SOURCE)
                         return true;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Sep 25 11:48:00 2012 -0700
@@ -76,11 +76,10 @@
     private final Annotate annotate;
     private final Types types;
     private final JCDiagnostic.Factory diags;
+    private final Source source;
     private final Target target;
     private final DeferredLintHandler deferredLintHandler;
 
-    private final boolean skipAnnotations;
-
     public static MemberEnter instance(Context context) {
         MemberEnter instance = context.get(memberEnterKey);
         if (instance == null)
@@ -102,10 +101,9 @@
         annotate = Annotate.instance(context);
         types = Types.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
+        source = Source.instance(context);
         target = Target.instance(context);
         deferredLintHandler = DeferredLintHandler.instance(context);
-        Options options = Options.instance(context);
-        skipAnnotations = options.isSet("skipAnnotations");
     }
 
     /** A queue for classes whose members still need to be entered into the
@@ -690,7 +688,7 @@
 
     public Env<AttrContext> getMethodEnv(JCMethodDecl tree, Env<AttrContext> env) {
         Env<AttrContext> mEnv = methodEnv(tree, env);
-        mEnv.info.lint = mEnv.info.lint.augment(tree.sym.attributes_field, tree.sym.flags());
+        mEnv.info.lint = mEnv.info.lint.augment(tree.sym.annotations, tree.sym.flags());
         for (List<JCTypeParameter> l = tree.typarams; l.nonEmpty(); l = l.tail)
             mEnv.info.scope.enterIfAbsent(l.head.type.tsym);
         for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail)
@@ -727,18 +725,24 @@
     void annotateLater(final List<JCAnnotation> annotations,
                        final Env<AttrContext> localEnv,
                        final Symbol s) {
-        if (annotations.isEmpty()) return;
-        if (s.kind != PCK) s.attributes_field = null; // mark it incomplete for now
-        annotate.later(new Annotate.Annotator() {
+        if (annotations.isEmpty()) {
+            return;
+        }
+        if (s.kind != PCK) {
+            s.annotations.reset(); // mark Annotations as incomplete for now
+        }
+        annotate.normal(new Annotate.Annotator() {
+                @Override
                 public String toString() {
                     return "annotate " + annotations + " onto " + s + " in " + s.owner;
                 }
+
+                @Override
                 public void enterAnnotation() {
-                    Assert.check(s.kind == PCK || s.attributes_field == null);
+                    Assert.check(s.kind == PCK || s.annotations.pendingCompletion());
                     JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
                     try {
-                        if (s.attributes_field != null &&
-                            s.attributes_field.nonEmpty() &&
+                        if (!s.annotations.isEmpty() &&
                             annotations.nonEmpty())
                             log.error(annotations.head.pos,
                                       "already.annotated",
@@ -756,7 +760,7 @@
      * java.lang.Deprecated.
      **/
     private boolean hasDeprecatedAnnotation(List<JCAnnotation> annotations) {
-        for (List<JCAnnotation> al = annotations; al.nonEmpty(); al = al.tail) {
+        for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
             JCAnnotation a = al.head;
             if (a.annotationType.type == syms.deprecatedType && a.args.isEmpty())
                 return true;
@@ -764,42 +768,62 @@
         return false;
     }
 
-
     /** Enter a set of annotations. */
     private void enterAnnotations(List<JCAnnotation> annotations,
                           Env<AttrContext> env,
                           Symbol s) {
-        ListBuffer<Attribute.Compound> buf =
-            new ListBuffer<Attribute.Compound>();
-        Set<TypeSymbol> annotated = new HashSet<TypeSymbol>();
-        if (!skipAnnotations)
-        for (List<JCAnnotation> al = annotations; al.nonEmpty(); al = al.tail) {
+        Map<TypeSymbol, ListBuffer<Attribute.Compound>> annotated =
+                new LinkedHashMap<TypeSymbol, ListBuffer<Attribute.Compound>>();
+        Map<Attribute.Compound, DiagnosticPosition> pos =
+                new HashMap<Attribute.Compound, DiagnosticPosition>();
+
+        for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
             JCAnnotation a = al.head;
             Attribute.Compound c = annotate.enterAnnotation(a,
                                                             syms.annotationType,
                                                             env);
-            if (c == null) continue;
-            buf.append(c);
+            if (c == null) {
+                continue;
+            }
+
+            if (annotated.containsKey(a.type.tsym)) {
+                if (source.allowRepeatedAnnotations()) {
+                    ListBuffer<Attribute.Compound> l = annotated.get(a.type.tsym);
+                    l = l.append(c);
+                    annotated.put(a.type.tsym, l);
+                    pos.put(c, a.pos());
+                } else {
+                    log.error(a.pos(), "duplicate.annotation");
+                }
+            } else {
+                annotated.put(a.type.tsym, ListBuffer.of(c));
+                pos.put(c, a.pos());
+            }
+
             // Note: @Deprecated has no effect on local variables and parameters
             if (!c.type.isErroneous()
                 && s.owner.kind != MTH
-                && types.isSameType(c.type, syms.deprecatedType))
+                && types.isSameType(c.type, syms.deprecatedType)) {
                 s.flags_field |= Flags.DEPRECATED;
-            if (!annotated.add(a.type.tsym))
-                log.error(a.pos, "duplicate.annotation");
+        }
         }
-        s.attributes_field = buf.toList();
+
+        s.annotations.setAttributesWithCompletion(
+                annotate.new AnnotateRepeatedContext(env, annotated, pos, log));
     }
 
     /** Queue processing of an attribute default value. */
     void annotateDefaultValueLater(final JCExpression defaultValue,
                                    final Env<AttrContext> localEnv,
                                    final MethodSymbol m) {
-        annotate.later(new Annotate.Annotator() {
+        annotate.normal(new Annotate.Annotator() {
+                @Override
                 public String toString() {
                     return "annotate " + m.owner + "." +
                         m + " default " + defaultValue;
                 }
+
+                @Override
                 public void enterAnnotation() {
                     JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
                     try {
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1321,7 +1321,7 @@
                 else
                     proxies.append(proxy);
             }
-            annotate.later(new AnnotationCompleter(sym, proxies.toList()));
+            annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
         }
     }
 
@@ -1347,7 +1347,7 @@
     void attachAnnotationDefault(final Symbol sym) {
         final MethodSymbol meth = (MethodSymbol)sym; // only on methods
         final Attribute value = readAttributeValue();
-        annotate.later(new AnnotationDefaultCompleter(meth, value));
+        annotate.normal(new AnnotationDefaultCompleter(meth, value));
     }
 
     Type readTypeOrClassSymbol(int i) {
@@ -1693,10 +1693,13 @@
             JavaFileObject previousClassFile = currentClassFile;
             try {
                 currentClassFile = classFile;
+                Annotations annotations = sym.annotations;
                 List<Attribute.Compound> newList = deproxyCompoundList(l);
-                sym.attributes_field = ((sym.attributes_field == null)
-                                        ? newList
-                                        : newList.prependList(sym.attributes_field));
+                if (annotations.pendingCompletion()) {
+                    annotations.setAttributes(newList);
+                } else {
+                    annotations.append(newList);
+                }
             } finally {
                 currentClassFile = previousClassFile;
             }
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Tue Sep 25 11:48:00 2012 -0700
@@ -825,7 +825,7 @@
         }
         public void visitClass(Attribute.Class clazz) {
             databuf.appendByte('c');
-            databuf.appendChar(pool.put(typeSig(clazz.type)));
+            databuf.appendChar(pool.put(typeSig(clazz.classType)));
         }
         public void visitCompound(Attribute.Compound compound) {
             databuf.appendByte('@');
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Tue Sep 25 11:48:00 2012 -0700
@@ -157,7 +157,7 @@
         if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0)
             return false;
 
-        for (Attribute.Compound a: c.attributes_field) {
+        for (Attribute.Compound a: c.annotations.getAttributes()) {
             if (a.type.tsym == syms.nativeHeaderType.tsym)
                 return true;
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -177,7 +177,7 @@
         }
 
         public void visitClass(Attribute.Class c) {
-            value = new MirroredTypeExceptionProxy(c.type);
+            value = new MirroredTypeExceptionProxy(c.classType);
         }
 
         public void visitArray(Attribute.Array a) {
@@ -187,7 +187,7 @@
                 // Construct a proxy for a MirroredTypesException
                 ListBuffer<TypeMirror> elems = new ListBuffer<TypeMirror>();
                 for (Attribute value : a.values) {
-                    Type elem = ((Attribute.Class) value).type;
+                    Type elem = ((Attribute.Class) value).classType;
                     elems.append(elem);
                 }
                 value = new MirroredTypesExceptionProxy(elems.toList());
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Sep 25 11:48:00 2012 -0700
@@ -250,6 +250,70 @@
 compiler.err.duplicate.annotation.member.value=\
     duplicate annotation member value {0} in {1}
 
+# 0: type
+compiler.err.duplicate.annotation.missing.container=\
+    duplicate annotation, the declaration of {0} does not have a ContainedBy annotation
+
+# 0: type, 1: type
+compiler.err.invalid.container.no.containedby=\
+    invalid contained repeatable annotation, {0} is not annotated with {1}
+
+# 0: type, 1: type
+compiler.err.invalid.container.wrong.containedby=\
+    invalid contained repeatable annotation, {0} does not match {1}
+
+# 0: type, 1: type
+compiler.err.invalid.container.no.containerfor=\
+    invalid container for repeating annotations, {0} is not annotated with {1}
+
+# 0: type, 1: type
+compiler.err.invalid.container.wrong.containerfor=\
+    invalid container for repeating annotations, {0} does not match {1}
+
+# 0: type
+compiler.err.invalid.containedby.annotation=\
+    duplicate annotation, {0} is annotated with an invalid ContainedBy annotation
+
+# 0: type
+compiler.err.invalid.containedby.annotation.no.value=\
+    duplicate annotation, {0} is not a valid ContainedBy, no value element method declared
+
+# 0: type, 1: number
+compiler.err.invalid.containedby.annotation.multiple.values=\
+    duplicate annotation, {0} is not a valid ContainedBy, {1} value element methods declared
+
+# 0: type
+compiler.err.invalid.containedby.annotation.invalid.value=\
+    duplicate annotation, {0} is not a valid ContainedBy, invalid value element, need a method
+
+# 0: type, 1: type, 2: type
+compiler.err.invalid.containedby.annotation.value.return=\
+    duplicate annotation, value element of containing annotation {0} should have type {2}, found {1}
+
+# 0: type, 1: symbol
+compiler.err.invalid.containedby.annotation.elem.nondefault=\
+    duplicate annotation, element {1} in containing annotation {0} does not have a default value
+
+# 0: symbol, 1: type, 2: symbol, 3: type
+compiler.err.invalid.containedby.annotation.retention=\
+    containing annotation {0} has shorter retention ({1}) than the contained annotation {2} with retention {3}
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.containedby.annotation.not.documented=\
+    containing annotation type, {0}, is not @Documented while repeated annotation type, {1}, is
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.containedby.annotation.not.inherited=\
+    containing annotation type, {0}, is not @Inherited while repeated annotation type, {1}, is
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.containedby.annotation.incompatible.target=\
+    target of container annotation {0} is not a subset of target of repeated annotation {1}
+
+# 0: symbol
+compiler.err.invalid.containedby.annotation.repeated.and.container.present=\
+    container {0} must not be present at the same time as the element it contains
+
 # 0: name
 compiler.err.duplicate.class=\
     duplicate class: {0}
--- a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -206,9 +206,7 @@
             }
             ClassSymbol cs = (ClassSymbol) sym;
             if (addLegacyAnnotation) {
-                cs.attributes_field = (cs.attributes_field == null)
-                    ? List.of(proprietary)
-                    : cs.attributes_field.prepend(proprietary);
+                cs.annotations.prepend(List.of(proprietary));
             }
             writeClass(pool, cs, writer);
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -740,7 +740,7 @@
             result = Literal(v.value);
         }
         public void visitClass(Attribute.Class clazz) {
-            result = ClassLiteral(clazz.type).setType(syms.classType);
+            result = ClassLiteral(clazz.classType).setType(syms.classType);
         }
         public void visitEnum(Attribute.Enum e) {
             result = QualIdent(e.value);
--- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,7 +83,7 @@
 
         public void visitClass(Attribute.Class c) {
             value = TypeMaker.getType(env,
-                                      env.types.erasure(c.type));
+                                      env.types.erasure(c.classType));
         }
 
         public void visitEnum(Attribute.Enum e) {
--- a/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -506,7 +506,7 @@
         List<String> opts = new ArrayList<String>();
         opts.add("-proc:only");
         opts.addAll(javac_extras);
-        CompilationTask t = c.getTask(log, fileManager, diagnosticListener, opts, internalize(classes), null);
+        CompilationTask t = c.getTask(log, fileManager, diagnosticListener, opts, classes, null);
         JavahProcessor p = new JavahProcessor(g);
         t.setProcessors(Collections.singleton(p));
 
@@ -516,14 +516,6 @@
         return ok;
     }
 
-    private List<String> internalize(List<String> classes) {
-        List<String> l = new ArrayList<String>();
-        for (String c: classes) {
-            l.add(c.replace('$', '.'));
-        }
-        return l;
-    }
-
     private List<File> pathToFiles(String path) {
         List<File> files = new ArrayList<File>();
         for (String f: path.split(File.pathSeparator)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/BasicRepeatingAnnotations.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean BasicRepeatingAnnotations BasicRepeatingAnnos BasicNonRepeatingAnno Foo Foos Bar
+ * @run compile BasicRepeatingAnnotations.java
+ * @run main BasicRepeatingAnnotations
+ */
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(Foos.class)
+@interface Foo {}
+
+@ContainerFor(Foo.class)
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foos {
+    Foo[] value();
+}
+
+@interface Bar {}
+
+@Foo @Foo
+@Foo
+@Bar
+@Foo
+@Foo
+@Foo
+@Foo
+@Foo @Foo
+@Foo
+class BasicRepeatingAnnos {}
+
+@Foo
+class BasicNonRepeatingAnno {}
+
+public class BasicRepeatingAnnotations {
+    public static void main(String[] args) throws Exception {
+        Annotation a = BasicRepeatingAnnos.class.getAnnotation(Foos.class);
+        if (a == null) {
+            throw new RuntimeException("Container annotation missing");
+        }
+
+        // verify that container not present on nonrepeating
+        a = BasicNonRepeatingAnno.class.getAnnotation(Foos.class);
+        if (a != null) {
+            throw new RuntimeException("Container annotation present");
+        }
+        a = BasicNonRepeatingAnno.class.getAnnotation(Foo.class);
+        if (a == null) {
+            throw new RuntimeException("Repeated annoation not directly present");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/CheckTargets.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean Foos Foo Bars Bar Baz Bazs CheckTargets
+ * @run compile CheckTargets.java
+ */
+
+import java.lang.annotation.*;
+
+@ContainedBy(Foos.class)
+@Target(ElementType.TYPE)
+@interface Foo {}
+
+@ContainerFor(Foo.class)
+@Target(ElementType.ANNOTATION_TYPE)
+@interface Foos {
+    Foo[] value();
+}
+
+@ContainedBy(Bars.class)
+@Target(ElementType.TYPE)
+@interface Bar {}
+
+@ContainerFor(Bar.class)
+@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE })
+@interface Bars {
+    Bar[] value();
+}
+
+
+@ContainedBy(Bazs.class)
+@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
+@interface Baz {}
+
+@ContainerFor(Baz.class)
+@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE })
+@interface Bazs {
+    Baz[] value();
+}
+
+
+public class CheckTargets {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/ContainerHasRepeatedContained.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean Bar BarContainer ContainerHasRepeatedContained
+ * @run compile ContainerHasRepeatedContained.java
+ */
+
+import java.lang.annotation.ContainedBy;
+import java.lang.annotation.ContainerFor;
+
+@ContainedBy(BarContainer.class)
+@interface Bar {}
+
+@Bar
+@Bar
+@ContainerFor(Bar.class)
+@interface BarContainer {
+    Bar[] value();
+}
+
+public class ContainerHasRepeatedContained {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/DelayRepeatedContainer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean DelayRepeatedContainer Bar BarContainer
+ * @run compile DelayRepeatedContainer.java
+ */
+
+import java.lang.annotation.*;
+
+public class DelayRepeatedContainer {
+    @Bar("apa") @Bar("banan")
+    String meh() { return "meh"; }
+}
+
+@Bar("katt")
+@Bar("lol")
+@ContainedBy(BarContainer.class)
+@interface Bar {
+    String value();
+}
+
+@ContainerFor(Bar.class)
+@interface BarContainer {
+    Bar[] value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/InvalidTarget.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean Foos Foo
+ * @run compile/fail InvalidTarget.java
+ */
+
+import java.lang.annotation.*;
+
+@ContainedBy(Foos.class)
+@Target(ElementType.ANNOTATION_TYPE)
+@interface Foo {}
+
+@ContainerFor(Foo.class)
+@Target(ElementType.TYPE)
+@interface Foos {
+    Foo[] value();
+}
+
+public class InvalidTargets {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/MissingContainedBy.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile/fail MissingContainedBy.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+
+@ContainerFor(MissingContainedBy.class)
+@interface Foos {
+    MissingContainedBy[] value();
+}
+
+public @interface MissingContainedBy {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/MissingContainerFor.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile/fail MissingContainerFor.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@interface Foos {
+    MissingContainerFor[] value();
+}
+
+@ContainedBy(Foos.class)
+public @interface MissingContainerFor {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/NestedContainers.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean NestedContainers BasicRepeatingAnnos BasicRepeatingAnnos2 Foo Foos FoosFoos
+ * @run compile NestedContainers.java
+ * @run main NestedContainers
+ */
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(Foos.class)
+@interface Foo {}
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(FoosFoos.class)
+@ContainerFor(Foo.class)
+@interface Foos {
+    Foo[] value();
+}
+
+@ContainerFor(Foos.class)
+@Retention(RetentionPolicy.RUNTIME)
+@interface FoosFoos {
+    Foos[] value();
+}
+
+@Foo
+@Foo
+class BasicRepeatingAnnos {}
+
+@Foos({})
+@Foos({})
+class BasicRepeatingAnnos2 {}
+
+public class NestedContainers {
+    public static void main(String[] args) throws Exception {
+        Annotation a = BasicRepeatingAnnos.class.getAnnotation(Foos.class);
+        if (a == null) {
+            throw new RuntimeException("Container annotation missing");
+        }
+
+        // Check 2:nd level container
+        a = BasicRepeatingAnnos2.class.getAnnotation(FoosFoos.class);
+        if (a == null) {
+            throw new RuntimeException("Container annotation missing");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/RepMemberAnno.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean RepMemberAnno Bar BarContainer
+ * @run compile RepMemberAnno.java
+ */
+
+import java.lang.annotation.ContainedBy;
+import java.lang.annotation.ContainerFor;
+
+public class RepMemberAnno {
+    @Bar("Apa") @Bar("Banan")
+    public void meh() {}
+}
+
+@ContainedBy(BarContainer.class)
+@interface Bar {
+    String value();
+}
+
+@ContainerFor(Bar.class)
+@interface BarContainer {
+    Bar[] value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/RepSelfMemberAnno.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean RepSelfMemberAnno BarContainer BarContainerContainer
+ * @run compile RepSelfMemberAnno.java
+ */
+
+import java.lang.annotation.*;
+
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(BarContainer.class)
+public @interface RepSelfMemberAnno {
+    @RepSelfMemberAnno @RepSelfMemberAnno
+    String meh() default "banan";
+}
+
+
+@ContainedBy(BarContainerContainer.class)
+@Retention(RetentionPolicy.RUNTIME)
+@ContainerFor(RepSelfMemberAnno.class)
+@interface BarContainer {
+    RepSelfMemberAnno[] value();
+}
+
+@ContainerFor(BarContainer.class)
+@Retention(RetentionPolicy.RUNTIME)
+@interface BarContainerContainer {
+    BarContainer[] value();
+    String meh() default "apa";
+}
+
+@BarContainer(value={})
+@BarContainer(value={})
+@interface Bar {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/RepeatingAndContainerPresent.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile/fail RepeatingAndContainerPresent.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainedBy(Foos.class)
+@interface Foo {}
+
+@interface Foos {
+    Foo[] value();
+}
+
+
+@Foo
+@Foo
+@Foos({})
+public class RepeatingAndContainerPresent {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/SelfRepeatingAnnotations.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean SelfRepeatingAnnotations Foos SelfRepeatingAnno
+ * @run compile SelfRepeatingAnnotations.java
+ * @run main SelfRepeatingAnnotations
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(SelfRepeatingAnno.class)
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foos {
+    SelfRepeatingAnno[] value();
+}
+
+@SelfRepeatingAnno
+@Retention(RetentionPolicy.RUNTIME)
+@SelfRepeatingAnno
+@ContainedBy(Foos.class)
+@interface SelfRepeatingAnno {}
+
+public class SelfRepeatingAnnotations {
+    public static void  main(String[] args) throws Exception {
+        Annotation a = SelfRepeatingAnno.class.getAnnotation(Foos.class);
+        if (a == null) {
+            throw new RuntimeException("Container annotation missing");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/SingleRepeatingAndContainer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile SingleRepeatingAndContainer.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainedBy(Foos.class)
+@interface Foo {}
+
+@ContainerFor(Foo.class)
+@interface Foos {
+    Foo[] value();
+}
+
+@Foo
+@Foos({})
+public class SingleRepeatingAndContainer {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/UseWrongContainedBy.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile/fail UseWrongContainedBy.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(UseWrongContainedBy.class)
+@interface Foos {
+    UseWrongContainedBy[] value();
+}
+
+@ContainedBy(Target.class)
+public @interface UseWrongContainedBy {}
+
+@UseWrongContainedBy @UseWrongContainedBy
+@interface Foo {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/UseWrongContainerFor.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile/fail UseWrongContainerFor.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(Retention.class)
+@interface Foos {
+    UseWrongContainerFor[] value();
+}
+
+@ContainedBy(Foos.class)
+public @interface UseWrongContainerFor {}
+
+@UseWrongContainerFor @UseWrongContainerFor
+@interface Foo {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongContainedBy.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile/fail WrongContainedBy.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(WrongContainedBy.class)
+@interface Foos {
+    WrongContainedBy[] value();
+}
+
+@ContainedBy(Target.class)
+public @interface WrongContainedBy {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongContainerFor.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile/fail WrongContainerFor.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(Retention.class)
+@interface Foos {
+    WrongContainerFor[] value();
+}
+
+@ContainedBy(Foos.class)
+public @interface WrongContainerFor {}
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Tue Sep 25 11:48:00 2012 -0700
@@ -5,6 +5,9 @@
 compiler.err.cant.read.file                             # (apt.JavaCompiler?)
 compiler.err.cant.select.static.class.from.param.type
 compiler.err.illegal.char.for.encoding
+compiler.err.invalid.containedby.annotation             # should not happen
+compiler.err.invalid.containedby.annotation.invalid.value # "can't" happen
+compiler.err.invalid.containedby.annotation.multiple.values # can't happen
 compiler.err.io.exception                               # (javah.JavahTask?)
 compiler.err.limit.code                                 # Code
 compiler.err.limit.code.too.large.for.try.stmt          # Gen
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ContainedByDocumentedMismatch.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.containedby.annotation.not.documented
+
+import java.lang.annotation.*;
+
+@Documented
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+@Anno
+@Anno
+class ContainedByDocumentedMismatch { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ContainedByInheritedMismatch.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.containedby.annotation.not.inherited
+
+import java.lang.annotation.*;
+
+@Inherited
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+@Anno
+@Anno
+class ContainedByInheritedMismatch { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ContainedByNoValue.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.containedby.annotation.no.value
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos {}
+
+@Anno
+@Anno
+class ContainedByNoValue { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ContainedByNonDefault.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.containedby.annotation.elem.nondefault
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); String foo(); }
+
+@Anno
+@Anno
+class ContainedByNonDefault { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ContainedByRetentionMismatch.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.containedby.annotation.retention
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+@Anno
+@Anno
+class ContainedByRetentionMismatch { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ContainedByTargetMismatch.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.containedby.annotation.incompatible.target
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@Target(ElementType.METHOD)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+class ContainedByTargetMismatch { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ContainedByWrongValueType.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.containedby.annotation.value.return
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { String value(); }
+
+@Anno
+@Anno
+class ContainedByWrongValueType { }
--- a/langtools/test/tools/javac/diags/examples/DuplicateAnnotation.java	Mon Sep 24 17:00:40 2012 +0400
+++ b/langtools/test/tools/javac/diags/examples/DuplicateAnnotation.java	Tue Sep 25 11:48:00 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
  */
 
 // key: compiler.err.duplicate.annotation
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 7
 
 @interface Anno { }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/DuplicateAnnotationJava8.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.duplicate.annotation.missing.container
+
+@interface Anno { }
+
+@Anno
+@Anno
+class DuplicateAnnotationJava8 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/RepeatingAnnotationAndContainer.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.containedby.annotation.repeated.and.container.present
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+@Anno
+@Anno
+@Annos(@Anno)
+class RepeatingAnnotationAndContainer { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/WrongContainedBy.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.container.no.containerfor
+// key: compiler.err.invalid.container.wrong.containedby
+
+import java.lang.annotation.*;
+
+@ContainerFor(WrongContainedBy.class)
+@interface Foos {
+    WrongContainedBy[] value();
+}
+
+@ContainedBy(Target.class)
+public @interface WrongContainedBy {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/WrongContainerFor.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.invalid.container.wrong.containerfor
+// key: compiler.err.invalid.container.no.containedby
+
+import java.lang.annotation.*;
+
+@ContainerFor(Retention.class)
+@interface Foos {
+    WrongContainerFor[] value();
+}
+
+@ContainedBy(Foos.class)
+public @interface WrongContainerFor {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/T7185778.java	Tue Sep 25 11:48:00 2012 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7185778
+ * @summary javah error "Not a valid class name" on class names with dollar signs
+ *   The first two tests are on an inner class name whose name does not contain $.
+ *   The second two tests are on an inner class name whose name does contain $.
+ *   The last test is on an outer class whose name contains $.
+ * @run main T7185778 T7185778$inner
+ * @run main T7185778 T7185778.inner
+ * @run main T7185778 T7185778$inner$
+ * @run main T7185778 T7185778.inner$
+ * @run main T7185778 xx$yy
+ */
+
+public class T7185778 {
+    class inner {
+        native byte[] xxxxx(String name);
+    }
+    class inner$ {
+        native byte[] xxxxx(String name);
+    }
+
+    static public void main(String[] args) {
+        int rc = com.sun.tools.javah.Main.run(args, null);
+        if ( rc != 0) {
+            throw new Error("javah returned non zero: " + rc);
+        }
+    }
+}
+
+class xx$yy {
+    native byte[] xxxxx(String name);
+}