changeset 25039:a0f814f72ad4

Merge
author prr
date Wed, 18 Jun 2014 13:12:58 -0700
parents cb2bdbbfbb2d d9ca34c227b8
children 09052d7f1467 7b8a6a85baa4 75bc95f43ca4
files common/autoconf/generated-configure.sh common/autoconf/libraries.m4 hotspot/test/gc/g1/TestStringDeduplicationMemoryUsage.java langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
diffstat 641 files changed, 15082 insertions(+), 7162 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Jun 09 11:58:07 2014 -0700
+++ b/.hgtags	Wed Jun 18 13:12:58 2014 -0700
@@ -259,3 +259,5 @@
 97932f6ad950ae5a73a9da5c96e6e58503ff646b jdk9-b14
 74eb0778e4f2dbff6628e718378449fba27c4265 jdk9-b15
 4a09f5d30be844ac6f714bdb0f63d8c3c08b9a98 jdk9-b16
+410bccbded9e9cce80f1e13ad221e37ae97a3986 jdk9-b17
+c5495e25c7258ab5f96a1ae14610887d76d2be63 jdk9-b18
--- a/.hgtags-top-repo	Mon Jun 09 11:58:07 2014 -0700
+++ b/.hgtags-top-repo	Wed Jun 18 13:12:58 2014 -0700
@@ -259,3 +259,5 @@
 4e3aa9723e9972623e3dafc321b368e7db7e9b3b jdk9-b14
 b114474fb25af4e73cb7219f7c04bd8994da03a5 jdk9-b15
 cf22a728521f91a4692b433d39d730a0a1b23155 jdk9-b16
+24152ee0ee1abef54a8bab04c099261dba7bcca5 jdk9-b17
+65abab59f783fcf02ff8e133431c252f9e5f07d5 jdk9-b18
--- a/common/autoconf/basics.m4	Mon Jun 09 11:58:07 2014 -0700
+++ b/common/autoconf/basics.m4	Wed Jun 18 13:12:58 2014 -0700
@@ -512,7 +512,7 @@
   )
 
   AC_ARG_WITH(sysroot, [AS_HELP_STRING([--with-sysroot],
-      [use this directory as sysroot)])],
+      [use this directory as sysroot])],
       [SYSROOT=$with_sysroot]
   )
 
@@ -531,6 +531,75 @@
       [BASIC_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)]
   )
 
+  if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then
+    # detect if Xcode is installed by running xcodebuild -version
+    # if no Xcode installed, xcodebuild exits with 1
+    # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0
+    if /usr/bin/xcodebuild -version >/dev/null 2>&1; then
+      # We need to use xcodebuild in the toolchain dir provided by the user, this will
+      # fall back on the stub binary in /usr/bin/xcodebuild
+      AC_PATH_PROG([XCODEBUILD], [xcodebuild], [/usr/bin/xcodebuild], [$TOOLCHAIN_PATH])
+    else
+      # this should result in SYSROOT being empty, unless --with-sysroot is provided
+      # when only the command line tools are installed there are no SDKs, so headers
+      # are copied into the system frameworks
+      XCODEBUILD=
+      AC_SUBST(XCODEBUILD)
+    fi
+  
+    AC_MSG_CHECKING([for sdk name])
+    AC_ARG_WITH([sdk-name], [AS_HELP_STRING([--with-sdk-name],
+        [use the platform SDK of the given name. @<:@macosx@:>@])],
+        [SDKNAME=$with_sdk_name]
+    )
+    AC_MSG_RESULT([$SDKNAME])
+
+    # if toolchain path is specified then don't rely on system headers, they may not compile
+    HAVE_SYSTEM_FRAMEWORK_HEADERS=0
+    test -z "$TOOLCHAIN_PATH" && \
+      HAVE_SYSTEM_FRAMEWORK_HEADERS=`test ! -f /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h; echo $?`
+
+    if test -z "$SYSROOT"; then
+      if test -n "$XCODEBUILD"; then
+        # if we don't have system headers, use default SDK name (last resort)
+        if test -z "$SDKNAME" -a $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then
+          SDKNAME=${SDKNAME:-macosx}
+        fi
+
+        if test -n "$SDKNAME"; then
+          # Call xcodebuild to determine SYSROOT
+          SYSROOT=`"$XCODEBUILD" -sdk $SDKNAME -version | grep '^Path: ' | sed 's/Path: //'`
+        fi
+      else
+        if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then
+          AC_MSG_ERROR([No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK])
+        fi
+      fi
+    else
+      # warn user if --with-sdk-name was also set
+      if test -n "$with_sdk_name"; then
+        AC_MSG_WARN([Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used])
+      fi
+    fi
+
+    if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0 -a -z "$SYSROOT"; then
+      # If no system framework headers, then SYSROOT must be set, or we won't build
+      AC_MSG_ERROR([Unable to determine SYSROOT and no headers found in /System/Library/Frameworks. Check Xcode configuration, --with-sysroot or --with-sdk-name arguments.])
+    fi
+
+    # Perform a basic sanity test
+    if test ! -f "$SYSROOT/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
+      if test -z "$SYSROOT"; then
+        AC_MSG_ERROR([Unable to find required framework headers, provide a path to an SDK via --with-sysroot or --with-sdk-name and be sure Xcode is installed properly])
+      else
+        AC_MSG_ERROR([Invalid SDK or SYSROOT path, dependent framework headers not found])
+      fi
+    fi
+
+    # set SDKROOT too, Xcode tools will pick it up
+    AC_SUBST(SDKROOT,$SYSROOT)
+  fi
+
   # Prepend the extra path to the global path
   BASIC_PREPEND_TO_PATH([PATH],$EXTRA_PATH)
 
--- a/common/autoconf/flags.m4	Mon Jun 09 11:58:07 2014 -0700
+++ b/common/autoconf/flags.m4	Wed Jun 18 13:12:58 2014 -0700
@@ -116,21 +116,25 @@
   AC_SUBST(RC_FLAGS)
 
   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX.
-    CCXXFLAGS="$CCXXFLAGS -nologo"
+    # silence copyright notice and other headers.
+    COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
   fi
 
   if test "x$SYSROOT" != "x"; then
     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       if test "x$OPENJDK_TARGET_OS" = xsolaris; then
         # Solaris Studio does not have a concept of sysroot. Instead we must
-        # make sure the default include and lib dirs are appended to each 
+        # make sure the default include and lib dirs are appended to each
         # compile and link command line.
         SYSROOT_CFLAGS="-I$SYSROOT/usr/include"
         SYSROOT_LDFLAGS="-L$SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \
             -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \
             -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR"
       fi
+    elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
+      # Apple only wants -isysroot <path>, but we also need -iframework<path>/System/Library/Frameworks
+      SYSROOT_CFLAGS="-isysroot \"$SYSROOT\" -iframework\"$SYSROOT/System/Library/Frameworks\""
+      SYSROOT_LDFLAGS=$SYSROOT_CFLAGS
     elif test "x$TOOLCHAIN_TYPE" = xgcc; then
       SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\""
       SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\""
@@ -143,6 +147,14 @@
     LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $SYSROOT_CFLAGS"
     LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $SYSROOT_LDFLAGS"
   fi
+
+  # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
+  # set this here so it doesn't have to be peppered throughout the forest
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    SYSROOT_CFLAGS="$SYSROOT_CFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\""
+    SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\""
+  fi
+
   AC_SUBST(SYSROOT_CFLAGS)
   AC_SUBST(SYSROOT_LDFLAGS)
 ])
@@ -302,6 +314,7 @@
   # Debug symbols
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
+      # reduce from default "-g2" option to save space
       CFLAGS_DEBUG_SYMBOLS="-g1"
       CXXFLAGS_DEBUG_SYMBOLS="-g1"
     else
@@ -313,6 +326,7 @@
     CXXFLAGS_DEBUG_SYMBOLS="-g"
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     CFLAGS_DEBUG_SYMBOLS="-g -xs"
+    # FIXME: likely a bug, this disables debug symbols rather than enables them
     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
     CFLAGS_DEBUG_SYMBOLS="-g"
@@ -321,6 +335,31 @@
   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
 
+  # bounds, memory and behavior checking options
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    case $DEBUG_LEVEL in
+    release )
+      # no adjustment
+      ;;
+    fastdebug )
+      # Add compile time bounds checks.
+      CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
+      CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
+      ;;
+    slowdebug )
+      # Add runtime bounds checks and symbol info.
+      CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
+      CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
+      if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then
+        CFLAGS_DEBUG_OPTIONS="$CFLAGS_DEBUG_OPTIONS  $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
+        CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
+      fi
+      ;;
+    esac
+  fi
+  AC_SUBST(CFLAGS_DEBUG_OPTIONS)
+  AC_SUBST(CXXFLAGS_DEBUG_OPTIONS)
+
   # Optimization levels
   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
@@ -330,10 +369,12 @@
       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -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_DEBUG="-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_DEBUG="-xregs=no%frameptr"
       CXX_O_FLAG_NONE="-xregs=no%frameptr"
       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
@@ -343,10 +384,12 @@
       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
+      C_O_FLAG_DEBUG=""
       C_O_FLAG_NONE=""
       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
+      C_O_FLAG_DEBUG=""
       CXX_O_FLAG_NONE=""
     fi
   else
@@ -359,13 +402,17 @@
         C_O_FLAG_HIGHEST="-Os"
         C_O_FLAG_HI="-Os"
         C_O_FLAG_NORM="-Os"
-        C_O_FLAG_NONE=""
       else
         C_O_FLAG_HIGHEST="-O3"
         C_O_FLAG_HI="-O3"
         C_O_FLAG_NORM="-O2"
-        C_O_FLAG_NONE="-O0"
       fi
+      if test "x$HAS_CFLAG_OPTIMIZE_DEBUG" = "xtrue"; then
+        C_O_FLAG_DEBUG="$CFLAG_OPTIMIZE_DEBUG_FLAG"
+      else
+        C_O_FLAG_DEBUG="-O0"
+      fi
+      C_O_FLAG_NONE="-O0"
     elif test "x$TOOLCHAIN_TYPE" = xclang; then
       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
         # On MacOSX we optimize for size, something
@@ -373,37 +420,63 @@
         C_O_FLAG_HIGHEST="-Os"
         C_O_FLAG_HI="-Os"
         C_O_FLAG_NORM="-Os"
-        C_O_FLAG_NONE=""
       else
         C_O_FLAG_HIGHEST="-O3"
         C_O_FLAG_HI="-O3"
         C_O_FLAG_NORM="-O2"
-        C_O_FLAG_NONE="-O0"
       fi
+      C_O_FLAG_DEBUG="-O0"
+      C_O_FLAG_NONE="-O0"
     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
       C_O_FLAG_HIGHEST="-O3"
       C_O_FLAG_HI="-O3 -qstrict"
       C_O_FLAG_NORM="-O2"
-      C_O_FLAG_NONE=""
+      C_O_FLAG_DEBUG="-qnoopt"
+      C_O_FLAG_NONE="-qnoop"
     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
       C_O_FLAG_HIGHEST="-O2"
       C_O_FLAG_HI="-O1"
       C_O_FLAG_NORM="-O1"
+      C_O_FLAG_DEBUG="-Od"
       C_O_FLAG_NONE="-Od"
     fi
     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_DEBUG="$C_O_FLAG_DEBUG"
     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   fi
 
+  # Adjust optimization flags according to debug level.
+  case $DEBUG_LEVEL in
+    release )
+      # no adjustment
+      ;;
+    fastdebug )
+      # Not quite so much optimization
+      C_O_FLAG_HI="$C_O_FLAG_NORM"
+      CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
+      ;;
+    slowdebug )
+      # Disable optimization
+      C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
+      C_O_FLAG_HI="$C_O_FLAG_DEBUG"
+      C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
+      CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
+      CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
+      CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
+      ;;
+  esac
+
   AC_SUBST(C_O_FLAG_HIGHEST)
   AC_SUBST(C_O_FLAG_HI)
   AC_SUBST(C_O_FLAG_NORM)
+  AC_SUBST(C_O_FLAG_DEBUG)
   AC_SUBST(C_O_FLAG_NONE)
   AC_SUBST(CXX_O_FLAG_HIGHEST)
   AC_SUBST(CXX_O_FLAG_HI)
   AC_SUBST(CXX_O_FLAG_NORM)
+  AC_SUBST(CXX_O_FLAG_DEBUG)
   AC_SUBST(CXX_O_FLAG_NONE)
 ])
 
@@ -461,11 +534,12 @@
   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
   #
 
-  # Setup compiler/platform specific flags to CFLAGS_JDK,
-  # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?)
+  # Setup compiler/platform specific flags into
+  #    CFLAGS_JDK    - C Compiler flags
+  #    CXXFLAGS_JDK  - C++ Compiler flags
+  #    COMMON_CCXXFLAGS_JDK - common to C and C++
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
-    # these options are used for both C and C++ compiles
-    CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
     case $OPENJDK_TARGET_CPU_ARCH in
       arm )
@@ -477,31 +551,31 @@
         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
         ;;
       * )
-        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
+        COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
         ;;
     esac
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
       CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
     fi
-  
+
     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"
   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_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"
     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
     else
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
     fi
   fi
 
@@ -509,28 +583,20 @@
 
   # Adjust flags according to debug level.
   case $DEBUG_LEVEL in
-    fastdebug )
-      CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
-      CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
-      C_O_FLAG_HI="$C_O_FLAG_NORM"
-      C_O_FLAG_NORM="$C_O_FLAG_NORM"
-      CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
-      CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
+    fastdebug | slowdebug )
+      CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
+      CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
       JAVAC_FLAGS="$JAVAC_FLAGS -g"
       ;;
-    slowdebug )
-      CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
-      CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
-      C_O_FLAG_HI="$C_O_FLAG_NONE"
-      C_O_FLAG_NORM="$C_O_FLAG_NONE"
-      CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
-      CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
-      JAVAC_FLAGS="$JAVAC_FLAGS -g"
+    release )
+      ;;
+    * )
+      AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
       ;;
   esac
 
   # Setup LP64
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64"
 
   # Set some common defines. These works for all compilers, but assume
   # -D is universally accepted.
@@ -543,74 +609,69 @@
     #   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="
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
     else
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
     fi
   else
     # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they
     # are defined in the system?
     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN="
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN="
     else
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
     fi
   fi
-  
+
   # Setup target OS define. Use OS target name but in upper case.
   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 
   # Setup target CPU
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
-  
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
+
   # Setup debug/release defines
   if test "x$DEBUG_LEVEL" = xrelease; then
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG"
     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED"
     fi
   else
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG"
   fi
 
   # Setup release name
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
 
 
   # Set some additional per-OS defines.
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
   elif test "x$OPENJDK_TARGET_OS" = xaix; then
     # FIXME: PPC64 should not be here.
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DPPC64"
   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
   fi
 
   # Additional macosx handling
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    if test "x$TOOLCHAIN_TYPE" = xgcc; then
-      # FIXME: This needs to be exported in spec.gmk due to closed legacy code.
-      # FIXME: clean this up, and/or move it elsewhere.
+    # Setting these parameters makes it an error to link to macosx APIs that are
+    # newer than the given OS version and makes the linked binaries compatible
+    # even if built on a newer version of the OS.
+    # The expected format is X.Y.Z
+    MACOSX_VERSION_MIN=10.7.0
+    AC_SUBST(MACOSX_VERSION_MIN)
 
-      # Setting these parameters makes it an error to link to macosx APIs that are
-      # newer than the given OS version and makes the linked binaries compatible 
-      # even if built on a newer version of the OS.
-      # The expected format is X.Y.Z
-      MACOSX_VERSION_MIN=10.7.0
-      AC_SUBST(MACOSX_VERSION_MIN)
-    
-      # The macro takes the version with no dots, ex: 1070
-      # Let the flags variables get resolved in make for easier override on make
-      # command line.
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
-      LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
-    fi
+    # The macro takes the version with no dots, ex: 1070
+    # Let the flags variables get resolved in make for easier override on make
+    # command line.
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
+    LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
   fi
 
   # Setup some hard coded includes
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
       -I${JDK_OUTPUTDIR}/include \
       -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
       -I${JDK_TOPDIR}/src/share/javavm/export \
@@ -619,12 +680,12 @@
       -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"
-  CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
+  CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
+  CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
 
   # Executable flags
-  CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
-  CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
+  CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
+  CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
 
   AC_SUBST(CFLAGS_JDKLIB)
   AC_SUBST(CFLAGS_JDKEXE)
@@ -633,6 +694,7 @@
 
   # Setup LDFLAGS et al.
   #
+
   # Now this is odd. The JDK native libraries have to link against libjvm.so
   # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
   # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
@@ -648,39 +710,93 @@
     fi
     # TODO: make -debug optional "--disable-full-debug-symbols"
     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
-    LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
-    LDFLAGS_JDKLIB_SUFFIX=""
+  elif test "x$TOOLCHAIN_TYPE" = xgcc; then
+    # If this is a --hash-style=gnu system, use --hash-style=both, why?
+    # We have previously set HAS_GNU_HASH if this is the case
+    if test -n "$HAS_GNU_HASH"; then
+      LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both"
+    fi
+    if test "x$OPENJDK_TARGET_OS" = xlinux; then
+      # And since we now know that the linker is gnu, then add -z defs, to forbid
+      # undefined symbols in object files.
+      LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
+      case $DEBUG_LEVEL in
+        release )
+          # tell linker to optimize libraries.
+          # Should this be supplied to the OSS linker as well?
+          LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
+          ;;
+        slowdebug )
+          if test "x$HAS_LINKER_NOW" = "xtrue"; then
+            # do relocations at load
+            LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_NOW_FLAG"
+            LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_NOW_FLAG"
+          fi
+          if test "x$HAS_LINKER_RELRO" = "xtrue"; then
+            # mark relocations read only
+            LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
+            LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
+          fi
+          ;;
+        fastdebug )
+          if test "x$HAS_LINKER_RELRO" = "xtrue"; then
+            # mark relocations read only
+            LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
+            LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
+          fi
+          ;;
+        * )
+          AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
+          ;;
+        esac
+    fi
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
+    LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
+  fi
+
+  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
+    # If undefined behaviour detection is enabled then we need to tell linker.
+    case $DEBUG_LEVEL in
+      release | fastdebug )
+        ;;
+      slowdebug )
+        AC_MSG_WARN([$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR])
+        if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then
+          # enable undefined behaviour checking
+          LDFLAGS_JDK="$LDFLAGS_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/[ ]*\([^ ]\+\)/ -Xlinker \1/g"`"
+          LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/[ ]*\([^ ]\+\)/ -Xlinker \1/g"`"
+        fi
+        ;;
+      * )
+        AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
+        ;;
+    esac
+  fi
+
+  # Customize LDFLAGS for executables
+
+  LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
+
+  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
       LDFLAGS_STACK_SIZE=1048576
     else
       LDFLAGS_STACK_SIZE=327680
     fi
-    LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
+    LDFLAGS_JDKEXE="${LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE"
+  elif test "x$OPENJDK_TARGET_OS" = xlinux; then
+    LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
+  fi
+
+  # Customize LDFLAGS for libs
+  LDFLAGS_JDKLIB="${LDFLAGS_JDK}"
+
+  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -dll -libpath:${JDK_OUTPUTDIR}/lib"
+    LDFLAGS_JDKLIB_SUFFIX=""
   else
-    if test "x$TOOLCHAIN_TYPE" = xgcc; then
-      # If this is a --hash-style=gnu system, use --hash-style=both, why?
-      # We have previously set HAS_GNU_HASH if this is the case
-      if test -n "$HAS_GNU_HASH"; then
-        LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
-      fi
-      if test "x$OPENJDK_TARGET_OS" = xlinux; then
-        # And since we now know that the linker is gnu, then add -z defs, to forbid
-        # undefined symbols in object files.
-        LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
-        if test "x$DEBUG_LEVEL" = "xrelease"; then
-          # When building release libraries, tell the linker optimize them.
-          # Should this be supplied to the OSS linker as well?
-          LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
-        fi
-      fi
-    fi
-
-    if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-      LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
-      LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
-    fi
-
-    LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
+    LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB}  ${SHARED_LIBRARY_FLAGS} \
         -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
 
     # On some platforms (mac) the linker warns about non existing -L dirs.
@@ -701,12 +817,8 @@
     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
     fi
+  fi
 
-    LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
-    if test "x$OPENJDK_TARGET_OS" = xlinux; then
-      LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
-    fi
-  fi
   AC_SUBST(LDFLAGS_JDKLIB)
   AC_SUBST(LDFLAGS_JDKEXE)
   AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
@@ -714,7 +826,6 @@
   AC_SUBST(LDFLAGS_CXX_JDK)
 ])
 
-
 # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
 #                                   [RUN-IF-FALSE])
 # ------------------------------------------------------------
@@ -727,7 +838,7 @@
   saved_cflags="$CFLAGS"
   CFLAGS="$CFLAGS $1"
   AC_LANG_PUSH([C])
-  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
       [supports=no])
   AC_LANG_POP([C])
   CFLAGS="$saved_cflags"
@@ -735,7 +846,7 @@
   saved_cxxflags="$CXXFLAGS"
   CXXFLAGS="$CXXFLAG $1"
   AC_LANG_PUSH([C++])
-  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
       [supports=no])
   AC_LANG_POP([C++])
   CXXFLAGS="$saved_cxxflags"
@@ -748,6 +859,31 @@
   fi
 ])
 
+# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
+#                                    [RUN-IF-FALSE])
+# ------------------------------------------------------------
+# Check that the linker support an argument
+AC_DEFUN([FLAGS_LINKER_CHECK_ARGUMENTS],
+[
+  AC_MSG_CHECKING([if linker supports "$1"])
+  supports=yes
+
+  saved_ldflags="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $1"
+  AC_LANG_PUSH([C])
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
+      [], [supports=no])
+  AC_LANG_POP([C])
+  LDFLAGS="$saved_ldflags"
+
+  AC_MSG_RESULT([$supports])
+  if test "x$supports" = "xyes" ; then
+    m4_ifval([$2], [$2], [:])
+  else
+    m4_ifval([$3], [$3], [:])
+  fi
+])
+
 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
 [
   # Some Zero and Shark settings.
--- a/common/autoconf/generated-configure.sh	Mon Jun 09 11:58:07 2014 -0700
+++ b/common/autoconf/generated-configure.sh	Wed Jun 18 13:12:58 2014 -0700
@@ -692,13 +692,17 @@
 LEGACY_EXTRA_CXXFLAGS
 LEGACY_EXTRA_CFLAGS
 CXX_O_FLAG_NONE
+CXX_O_FLAG_DEBUG
 CXX_O_FLAG_NORM
 CXX_O_FLAG_HI
 CXX_O_FLAG_HIGHEST
 C_O_FLAG_NONE
+C_O_FLAG_DEBUG
 C_O_FLAG_NORM
 C_O_FLAG_HI
 C_O_FLAG_HIGHEST
+CXXFLAGS_DEBUG_OPTIONS
+CFLAGS_DEBUG_OPTIONS
 CXXFLAGS_DEBUG_SYMBOLS
 CFLAGS_DEBUG_SYMBOLS
 CXX_FLAG_DEPS
@@ -870,6 +874,8 @@
 OUTPUT_ROOT
 CONF_NAME
 SPEC
+SDKROOT
+XCODEBUILD
 BUILD_VARIANT_RELEASE
 DEBUG_CLASSFILES
 FASTDEBUG
@@ -1036,6 +1042,7 @@
 with_tools_dir
 with_toolchain_path
 with_extra_path
+with_sdk_name
 with_conf_name
 with_builddeps_conf
 with_builddeps_server
@@ -1070,7 +1077,6 @@
 with_extra_ldflags
 enable_debug_symbols
 enable_zip_debug_info
-enable_macosx_runtime_support
 with_x
 with_cups
 with_cups_include
@@ -1838,9 +1844,6 @@
   --disable-debug-symbols disable generation of debug symbols [enabled]
   --disable-zip-debug-info
                           disable zipping of debug-info files [enabled]
-  --enable-macosx-runtime-support
-                          Deprecated. Option is kept for backwards
-                          compatibility and is ignored
   --disable-freetype-bundling
                           disable bundling of the freetype library with the
                           build result [enabled on Windows or when using
@@ -1869,12 +1872,13 @@
                           optimized (HotSpot build only)) [release]
   --with-devkit           use this devkit for compilers, tools and resources
   --with-sys-root         alias for --with-sysroot for backwards compatability
-  --with-sysroot          use this directory as sysroot)
+  --with-sysroot          use this directory as sysroot
   --with-tools-dir        alias for --with-toolchain-path for backwards
                           compatibility
   --with-toolchain-path   prepend these directories when searching for
                           toolchain binaries (compilers etc)
   --with-extra-path       prepend these directories to the default path
+  --with-sdk-name         use the platform SDK of the given name. [macosx]
   --with-conf-name        use this as the name of the configuration [generated
                           from important configuration options]
   --with-builddeps-conf   use this configuration file for the builddeps
@@ -2349,6 +2353,52 @@
 
 } # ac_fn_objc_try_compile
 
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
 # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES
 # ---------------------------------------------------------
 # Tests whether HEADER exists, giving a warning if it cannot be compiled using
@@ -3764,13 +3814,18 @@
 
 
 
-
 # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
 #                                   [RUN-IF-FALSE])
 # ------------------------------------------------------------
 # Check that the c and c++ compilers support an argument
 
 
+# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
+#                                    [RUN-IF-FALSE])
+# ------------------------------------------------------------
+# Check that the linker support an argument
+
+
 
 
 #
@@ -4256,7 +4311,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1400601642
+DATE_WHEN_GENERATED=1403110135
 
 ###############################################################################
 #
@@ -14916,6 +14971,122 @@
 fi
 
 
+  if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then
+    # detect if Xcode is installed by running xcodebuild -version
+    # if no Xcode installed, xcodebuild exits with 1
+    # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0
+    if /usr/bin/xcodebuild -version >/dev/null 2>&1; then
+      # We need to use xcodebuild in the toolchain dir provided by the user, this will
+      # fall back on the stub binary in /usr/bin/xcodebuild
+      # Extract the first word of "xcodebuild", so it can be a program name with args.
+set dummy xcodebuild; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_XCODEBUILD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $XCODEBUILD in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_XCODEBUILD="$XCODEBUILD" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $TOOLCHAIN_PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_XCODEBUILD="$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
+
+  test -z "$ac_cv_path_XCODEBUILD" && ac_cv_path_XCODEBUILD="/usr/bin/xcodebuild"
+  ;;
+esac
+fi
+XCODEBUILD=$ac_cv_path_XCODEBUILD
+if test -n "$XCODEBUILD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XCODEBUILD" >&5
+$as_echo "$XCODEBUILD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    else
+      # this should result in SYSROOT being empty, unless --with-sysroot is provided
+      # when only the command line tools are installed there are no SDKs, so headers
+      # are copied into the system frameworks
+      XCODEBUILD=
+
+    fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdk name" >&5
+$as_echo_n "checking for sdk name... " >&6; }
+
+# Check whether --with-sdk-name was given.
+if test "${with_sdk_name+set}" = set; then :
+  withval=$with_sdk_name; SDKNAME=$with_sdk_name
+
+fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SDKNAME" >&5
+$as_echo "$SDKNAME" >&6; }
+
+    # if toolchain path is specified then don't rely on system headers, they may not compile
+    HAVE_SYSTEM_FRAMEWORK_HEADERS=0
+    test -z "$TOOLCHAIN_PATH" && \
+      HAVE_SYSTEM_FRAMEWORK_HEADERS=`test ! -f /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h; echo $?`
+
+    if test -z "$SYSROOT"; then
+      if test -n "$XCODEBUILD"; then
+        # if we don't have system headers, use default SDK name (last resort)
+        if test -z "$SDKNAME" -a $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then
+          SDKNAME=${SDKNAME:-macosx}
+        fi
+
+        if test -n "$SDKNAME"; then
+          # Call xcodebuild to determine SYSROOT
+          SYSROOT=`"$XCODEBUILD" -sdk $SDKNAME -version | grep '^Path: ' | sed 's/Path: //'`
+        fi
+      else
+        if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then
+          as_fn_error $? "No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK" "$LINENO" 5
+        fi
+      fi
+    else
+      # warn user if --with-sdk-name was also set
+      if test -n "$with_sdk_name"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used" >&5
+$as_echo "$as_me: WARNING: Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used" >&2;}
+      fi
+    fi
+
+    if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0 -a -z "$SYSROOT"; then
+      # If no system framework headers, then SYSROOT must be set, or we won't build
+      as_fn_error $? "Unable to determine SYSROOT and no headers found in /System/Library/Frameworks. Check Xcode configuration, --with-sysroot or --with-sdk-name arguments." "$LINENO" 5
+    fi
+
+    # Perform a basic sanity test
+    if test ! -f "$SYSROOT/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
+      if test -z "$SYSROOT"; then
+        as_fn_error $? "Unable to find required framework headers, provide a path to an SDK via --with-sysroot or --with-sdk-name and be sure Xcode is installed properly" "$LINENO" 5
+      else
+        as_fn_error $? "Invalid SDK or SYSROOT path, dependent framework headers not found" "$LINENO" 5
+      fi
+    fi
+
+    # set SDKROOT too, Xcode tools will pick it up
+    SDKROOT=$SYSROOT
+
+  fi
+
   # Prepend the extra path to the global path
 
   if test "x$EXTRA_PATH" != x; then
@@ -26544,21 +26715,28 @@
   VALID_TOOLCHAINS=${!toolchain_var_name}
 
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    # On Mac OS X, default toolchain to clang after Xcode 5
-    XCODE_VERSION_OUTPUT=`xcodebuild -version 2>&1 | $HEAD -n 1`
-    $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
-    if test $? -ne 0; then
-      as_fn_error $? "Failed to determine Xcode version." "$LINENO" 5
-    fi
-    XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
-        $SED -e 's/^Xcode \([1-9][0-9.]*\)/\1/' | \
-        $CUT -f 1 -d .`
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Xcode major version: $XCODE_MAJOR_VERSION" >&5
+    if test -n "$XCODEBUILD"; then
+      # On Mac OS X, default toolchain to clang after Xcode 5
+      XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1`
+      $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
+      if test $? -ne 0; then
+        as_fn_error $? "Failed to determine Xcode version." "$LINENO" 5
+      fi
+      XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
+          $SED -e 's/^Xcode \([1-9][0-9.]*\)/\1/' | \
+          $CUT -f 1 -d .`
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Xcode major version: $XCODE_MAJOR_VERSION" >&5
 $as_echo "$as_me: Xcode major version: $XCODE_MAJOR_VERSION" >&6;}
-    if test $XCODE_MAJOR_VERSION -ge 5; then
-        DEFAULT_TOOLCHAIN="clang"
-    else
-        DEFAULT_TOOLCHAIN="gcc"
+      if test $XCODE_MAJOR_VERSION -ge 5; then
+          DEFAULT_TOOLCHAIN="clang"
+      else
+          DEFAULT_TOOLCHAIN="gcc"
+      fi
+    else
+      # If Xcode is not installed, but the command line tools are
+      # then we can't run xcodebuild. On these systems we should
+      # default to clang
+      DEFAULT_TOOLCHAIN="clang"
     fi
   else
     # First toolchain type in the list is the default
@@ -40267,6 +40445,8 @@
 
 
 
+
+
   # The package path is used only on macosx?
   # FIXME: clean this up, and/or move it elsewhere.
   PACKAGE_PATH=/opt/local
@@ -40292,6 +40472,242 @@
     # If this is a --hash-style=gnu system, use --hash-style=both, why?
     HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
     # This is later checked when setting flags.
+
+    # "-Og" suppported for GCC 4.8 and later
+    CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"" >&5
+$as_echo_n "checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"... " >&6; }
+  supports=yes
+
+  saved_cflags="$CFLAGS"
+  CFLAGS="$CFLAGS $CFLAG_OPTIMIZE_DEBUG_FLAG"
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int i;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  supports=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  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
+
+  CFLAGS="$saved_cflags"
+
+  saved_cxxflags="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAG $CFLAG_OPTIMIZE_DEBUG_FLAG"
+  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
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int i;
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+  supports=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  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
+
+  CXXFLAGS="$saved_cxxflags"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
+$as_echo "$supports" >&6; }
+  if test "x$supports" = "xyes" ; then
+    HAS_CFLAG_OPTIMIZE_DEBUG=true
+  else
+    HAS_CFLAG_OPTIMIZE_DEBUG=false
+  fi
+
+
+    # "-fsanitize=undefined" supported for GCC 4.9 and later
+    CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG="-fsanitize=undefined -fsanitize-recover"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG\"" >&5
+$as_echo_n "checking if compiler supports \"$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG\"... " >&6; }
+  supports=yes
+
+  saved_cflags="$CFLAGS"
+  CFLAGS="$CFLAGS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int i;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  supports=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  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
+
+  CFLAGS="$saved_cflags"
+
+  saved_cxxflags="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAG $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
+  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
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int i;
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+  supports=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  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
+
+  CXXFLAGS="$saved_cxxflags"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
+$as_echo "$supports" >&6; }
+  if test "x$supports" = "xyes" ; then
+    HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=true
+  else
+    HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=false
+  fi
+
+
+    # "-z relro" supported in GNU binutils 2.17 and later
+    LINKER_RELRO_FLAG="-Xlinker -z -Xlinker relro"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_RELRO_FLAG\"" >&5
+$as_echo_n "checking if linker supports \"$LINKER_RELRO_FLAG\"... " >&6; }
+  supports=yes
+
+  saved_ldflags="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $LINKER_RELRO_FLAG"
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+  supports=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  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
+
+  LDFLAGS="$saved_ldflags"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
+$as_echo "$supports" >&6; }
+  if test "x$supports" = "xyes" ; then
+    HAS_LINKER_RELRO=true
+  else
+    HAS_LINKER_RELRO=false
+  fi
+
+
+    # "-z now" supported in GNU binutils 2.11 and later
+    LINKER_NOW_FLAG="-Xlinker -z -Xlinker now"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_NOW_FLAG\"" >&5
+$as_echo_n "checking if linker supports \"$LINKER_NOW_FLAG\"... " >&6; }
+  supports=yes
+
+  saved_ldflags="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $LINKER_NOW_FLAG"
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+  supports=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  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
+
+  LDFLAGS="$saved_ldflags"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
+$as_echo "$supports" >&6; }
+  if test "x$supports" = "xyes" ; then
+    HAS_LINKER_NOW=true
+  else
+    HAS_LINKER_NOW=false
+  fi
+
   fi
 
   # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed
@@ -40300,8 +40716,8 @@
   if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken SuSE 'ld' which only understands anonymous version tags in executables" >&5
 $as_echo_n "checking for broken SuSE 'ld' which only understands anonymous version tags in executables... " >&6; }
-    echo "SUNWprivate_1.1 { local: *; };" > version-script.map
-    echo "int main() { }" > main.c
+    $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map
+    $ECHO "int main() { }" > main.c
     if $CXX -Xlinker -version-script=version-script.map main.c 2>&5 >&5; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -40771,8 +41187,8 @@
 
 
   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX.
-    CCXXFLAGS="$CCXXFLAGS -nologo"
+    # silence copyright notice and other headers.
+    COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
   fi
 
   if test "x$SYSROOT" != "x"; then
@@ -40786,6 +41202,10 @@
             -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \
             -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR"
       fi
+    elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
+      # Apple only wants -isysroot <path>, but we also need -iframework<path>/System/Library/Frameworks
+      SYSROOT_CFLAGS="-isysroot \"$SYSROOT\" -iframework\"$SYSROOT/System/Library/Frameworks\""
+      SYSROOT_LDFLAGS=$SYSROOT_CFLAGS
     elif test "x$TOOLCHAIN_TYPE" = xgcc; then
       SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\""
       SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\""
@@ -40799,6 +41219,14 @@
     LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $SYSROOT_LDFLAGS"
   fi
 
+  # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
+  # set this here so it doesn't have to be peppered throughout the forest
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    SYSROOT_CFLAGS="$SYSROOT_CFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\""
+    SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\""
+  fi
+
+
 
 
 
@@ -40806,7 +41234,6 @@
 
 # Now we can test some aspects on the target using configure macros.
 
-
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
 $as_echo_n "checking for ANSI C header files... " >&6; }
 if ${ac_cv_header_stdc+:} false; then :
@@ -41491,6 +41918,7 @@
   # Debug symbols
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
+      # reduce from default "-g2" option to save space
       CFLAGS_DEBUG_SYMBOLS="-g1"
       CXXFLAGS_DEBUG_SYMBOLS="-g1"
     else
@@ -41502,6 +41930,7 @@
     CXXFLAGS_DEBUG_SYMBOLS="-g"
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     CFLAGS_DEBUG_SYMBOLS="-g -xs"
+    # FIXME: likely a bug, this disables debug symbols rather than enables them
     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
     CFLAGS_DEBUG_SYMBOLS="-g"
@@ -41510,6 +41939,31 @@
 
 
 
+  # bounds, memory and behavior checking options
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    case $DEBUG_LEVEL in
+    release )
+      # no adjustment
+      ;;
+    fastdebug )
+      # Add compile time bounds checks.
+      CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
+      CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
+      ;;
+    slowdebug )
+      # Add runtime bounds checks and symbol info.
+      CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
+      CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
+      if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then
+        CFLAGS_DEBUG_OPTIONS="$CFLAGS_DEBUG_OPTIONS  $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
+        CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
+      fi
+      ;;
+    esac
+  fi
+
+
+
   # Optimization levels
   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
@@ -41519,10 +41973,12 @@
       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -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_DEBUG="-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_DEBUG="-xregs=no%frameptr"
       CXX_O_FLAG_NONE="-xregs=no%frameptr"
       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
@@ -41532,10 +41988,12 @@
       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
+      C_O_FLAG_DEBUG=""
       C_O_FLAG_NONE=""
       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
+      C_O_FLAG_DEBUG=""
       CXX_O_FLAG_NONE=""
     fi
   else
@@ -41548,13 +42006,17 @@
         C_O_FLAG_HIGHEST="-Os"
         C_O_FLAG_HI="-Os"
         C_O_FLAG_NORM="-Os"
-        C_O_FLAG_NONE=""
       else
         C_O_FLAG_HIGHEST="-O3"
         C_O_FLAG_HI="-O3"
         C_O_FLAG_NORM="-O2"
-        C_O_FLAG_NONE="-O0"
-      fi
+      fi
+      if test "x$HAS_CFLAG_OPTIMIZE_DEBUG" = "xtrue"; then
+        C_O_FLAG_DEBUG="$CFLAG_OPTIMIZE_DEBUG_FLAG"
+      else
+        C_O_FLAG_DEBUG="-O0"
+      fi
+      C_O_FLAG_NONE="-O0"
     elif test "x$TOOLCHAIN_TYPE" = xclang; then
       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
         # On MacOSX we optimize for size, something
@@ -41562,30 +42024,56 @@
         C_O_FLAG_HIGHEST="-Os"
         C_O_FLAG_HI="-Os"
         C_O_FLAG_NORM="-Os"
-        C_O_FLAG_NONE=""
       else
         C_O_FLAG_HIGHEST="-O3"
         C_O_FLAG_HI="-O3"
         C_O_FLAG_NORM="-O2"
-        C_O_FLAG_NONE="-O0"
-      fi
+      fi
+      C_O_FLAG_DEBUG="-O0"
+      C_O_FLAG_NONE="-O0"
     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
       C_O_FLAG_HIGHEST="-O3"
       C_O_FLAG_HI="-O3 -qstrict"
       C_O_FLAG_NORM="-O2"
-      C_O_FLAG_NONE=""
+      C_O_FLAG_DEBUG="-qnoopt"
+      C_O_FLAG_NONE="-qnoop"
     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
       C_O_FLAG_HIGHEST="-O2"
       C_O_FLAG_HI="-O1"
       C_O_FLAG_NORM="-O1"
+      C_O_FLAG_DEBUG="-Od"
       C_O_FLAG_NONE="-Od"
     fi
     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_DEBUG="$C_O_FLAG_DEBUG"
     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   fi
 
+  # Adjust optimization flags according to debug level.
+  case $DEBUG_LEVEL in
+    release )
+      # no adjustment
+      ;;
+    fastdebug )
+      # Not quite so much optimization
+      C_O_FLAG_HI="$C_O_FLAG_NORM"
+      CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
+      ;;
+    slowdebug )
+      # Disable optimization
+      C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
+      C_O_FLAG_HI="$C_O_FLAG_DEBUG"
+      C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
+      CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
+      CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
+      CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
+      ;;
+  esac
+
+
+
 
 
 
@@ -41663,11 +42151,12 @@
   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
   #
 
-  # Setup compiler/platform specific flags to CFLAGS_JDK,
-  # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?)
+  # Setup compiler/platform specific flags into
+  #    CFLAGS_JDK    - C Compiler flags
+  #    CXXFLAGS_JDK  - C++ Compiler flags
+  #    COMMON_CCXXFLAGS_JDK - common to C and C++
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
-    # these options are used for both C and C++ compiles
-    CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
     case $OPENJDK_TARGET_CPU_ARCH in
       arm )
@@ -41679,14 +42168,14 @@
         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
         ;;
       * )
-        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
+        COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
         ;;
     esac
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
       CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
     fi
 
@@ -41696,14 +42185,14 @@
     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_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"
     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
-    else
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
+    else
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
     fi
   fi
 
@@ -41711,28 +42200,20 @@
 
   # Adjust flags according to debug level.
   case $DEBUG_LEVEL in
-    fastdebug )
-      CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
-      CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
-      C_O_FLAG_HI="$C_O_FLAG_NORM"
-      C_O_FLAG_NORM="$C_O_FLAG_NORM"
-      CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
-      CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
+    fastdebug | slowdebug )
+      CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
+      CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
       JAVAC_FLAGS="$JAVAC_FLAGS -g"
       ;;
-    slowdebug )
-      CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
-      CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
-      C_O_FLAG_HI="$C_O_FLAG_NONE"
-      C_O_FLAG_NORM="$C_O_FLAG_NONE"
-      CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
-      CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
-      JAVAC_FLAGS="$JAVAC_FLAGS -g"
+    release )
+      ;;
+    * )
+      as_fn_error $? "Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL" "$LINENO" 5
       ;;
   esac
 
   # Setup LP64
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64"
 
   # Set some common defines. These works for all compilers, but assume
   # -D is universally accepted.
@@ -41745,74 +42226,69 @@
     #   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"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
+    else
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
     fi
   else
     # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they
     # are defined in the system?
     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN="
-    else
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN="
+    else
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
     fi
   fi
 
   # Setup target OS define. Use OS target name but in upper case.
   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 
   # Setup target CPU
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 
   # Setup debug/release defines
   if test "x$DEBUG_LEVEL" = xrelease; then
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG"
     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
-    fi
-  else
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED"
+    fi
+  else
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG"
   fi
 
   # Setup release name
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
 
 
   # Set some additional per-OS defines.
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
   elif test "x$OPENJDK_TARGET_OS" = xaix; then
     # FIXME: PPC64 should not be here.
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DPPC64"
   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
   fi
 
   # Additional macosx handling
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    if test "x$TOOLCHAIN_TYPE" = xgcc; then
-      # FIXME: This needs to be exported in spec.gmk due to closed legacy code.
-      # FIXME: clean this up, and/or move it elsewhere.
-
-      # Setting these parameters makes it an error to link to macosx APIs that are
-      # newer than the given OS version and makes the linked binaries compatible
-      # even if built on a newer version of the OS.
-      # The expected format is X.Y.Z
-      MACOSX_VERSION_MIN=10.7.0
-
-
-      # The macro takes the version with no dots, ex: 1070
-      # Let the flags variables get resolved in make for easier override on make
-      # command line.
-      CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
-      LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
-    fi
+    # Setting these parameters makes it an error to link to macosx APIs that are
+    # newer than the given OS version and makes the linked binaries compatible
+    # even if built on a newer version of the OS.
+    # The expected format is X.Y.Z
+    MACOSX_VERSION_MIN=10.7.0
+
+
+    # The macro takes the version with no dots, ex: 1070
+    # Let the flags variables get resolved in make for easier override on make
+    # command line.
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
+    LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
   fi
 
   # Setup some hard coded includes
-  CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
+  COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
       -I${JDK_OUTPUTDIR}/include \
       -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
       -I${JDK_TOPDIR}/src/share/javavm/export \
@@ -41821,12 +42297,12 @@
       -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"
-  CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
+  CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
+  CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
 
   # Executable flags
-  CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
-  CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
+  CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
+  CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
 
 
 
@@ -41835,6 +42311,7 @@
 
   # Setup LDFLAGS et al.
   #
+
   # Now this is odd. The JDK native libraries have to link against libjvm.so
   # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
   # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
@@ -41850,39 +42327,94 @@
     fi
     # TODO: make -debug optional "--disable-full-debug-symbols"
     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
-    LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
-    LDFLAGS_JDKLIB_SUFFIX=""
+  elif test "x$TOOLCHAIN_TYPE" = xgcc; then
+    # If this is a --hash-style=gnu system, use --hash-style=both, why?
+    # We have previously set HAS_GNU_HASH if this is the case
+    if test -n "$HAS_GNU_HASH"; then
+      LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both"
+    fi
+    if test "x$OPENJDK_TARGET_OS" = xlinux; then
+      # And since we now know that the linker is gnu, then add -z defs, to forbid
+      # undefined symbols in object files.
+      LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
+      case $DEBUG_LEVEL in
+        release )
+          # tell linker to optimize libraries.
+          # Should this be supplied to the OSS linker as well?
+          LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
+          ;;
+        slowdebug )
+          if test "x$HAS_LINKER_NOW" = "xtrue"; then
+            # do relocations at load
+            LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_NOW_FLAG"
+            LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_NOW_FLAG"
+          fi
+          if test "x$HAS_LINKER_RELRO" = "xtrue"; then
+            # mark relocations read only
+            LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
+            LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
+          fi
+          ;;
+        fastdebug )
+          if test "x$HAS_LINKER_RELRO" = "xtrue"; then
+            # mark relocations read only
+            LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG"
+            LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
+          fi
+          ;;
+        * )
+          as_fn_error $? "Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL" "$LINENO" 5
+          ;;
+        esac
+    fi
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
+    LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
+  fi
+
+  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
+    # If undefined behaviour detection is enabled then we need to tell linker.
+    case $DEBUG_LEVEL in
+      release | fastdebug )
+        ;;
+      slowdebug )
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" >&5
+$as_echo "$as_me: WARNING: $HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" >&2;}
+        if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then
+          # enable undefined behaviour checking
+          LDFLAGS_JDK="$LDFLAGS_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/ *\(^ \+\)/ -Xlinker \1/g"`"
+          LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/ *\(^ \+\)/ -Xlinker \1/g"`"
+        fi
+        ;;
+      * )
+        as_fn_error $? "Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL" "$LINENO" 5
+        ;;
+    esac
+  fi
+
+  # Customize LDFLAGS for executables
+
+  LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
+
+  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
       LDFLAGS_STACK_SIZE=1048576
     else
       LDFLAGS_STACK_SIZE=327680
     fi
-    LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
-  else
-    if test "x$TOOLCHAIN_TYPE" = xgcc; then
-      # If this is a --hash-style=gnu system, use --hash-style=both, why?
-      # We have previously set HAS_GNU_HASH if this is the case
-      if test -n "$HAS_GNU_HASH"; then
-        LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
-      fi
-      if test "x$OPENJDK_TARGET_OS" = xlinux; then
-        # And since we now know that the linker is gnu, then add -z defs, to forbid
-        # undefined symbols in object files.
-        LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
-        if test "x$DEBUG_LEVEL" = "xrelease"; then
-          # When building release libraries, tell the linker optimize them.
-          # Should this be supplied to the OSS linker as well?
-          LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
-        fi
-      fi
-    fi
-
-    if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-      LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
-      LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
-    fi
-
-    LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
+    LDFLAGS_JDKEXE="${LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE"
+  elif test "x$OPENJDK_TARGET_OS" = xlinux; then
+    LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
+  fi
+
+  # Customize LDFLAGS for libs
+  LDFLAGS_JDKLIB="${LDFLAGS_JDK}"
+
+  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -dll -libpath:${JDK_OUTPUTDIR}/lib"
+    LDFLAGS_JDKLIB_SUFFIX=""
+  else
+    LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB}  ${SHARED_LIBRARY_FLAGS} \
         -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
 
     # On some platforms (mac) the linker warns about non existing -L dirs.
@@ -41903,11 +42435,6 @@
     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
     fi
-
-    LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
-    if test "x$OPENJDK_TARGET_OS" = xlinux; then
-      LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
-    fi
   fi
 
 
@@ -42260,8 +42787,6 @@
     ALSA_NOT_NEEDED=yes
     PULSE_NOT_NEEDED=yes
     X11_NOT_NEEDED=yes
-    # If the java runtime framework is disabled, then we need X11.
-    # This will be adjusted below.
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa pulse x11" >&5
 $as_echo "alsa pulse x11" >&6; }
   fi
@@ -42282,33 +42807,6 @@
     X11_NOT_NEEDED=yes
   fi
 
-  ###############################################################################
-  #
-  # Check for MacOSX support for OpenJDK.
-  #
-
-
-  # Check whether --enable-macosx-runtime-support was given.
-if test "${enable_macosx_runtime_support+set}" = set; then :
-  enableval=$enable_macosx_runtime_support;
-fi
-
-  if test "x$enable_macosx_runtime_support" != x; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --enable-macosx-runtime-support is deprecated and will be ignored." >&5
-$as_echo "$as_me: WARNING: Option --enable-macosx-runtime-support is deprecated and will be ignored." >&2;}
-  fi
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mac OS X Java Framework" >&5
-$as_echo_n "checking for Mac OS X Java Framework... " >&6; }
-  if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: /System/Library/Frameworks/JavaVM.framework" >&5
-$as_echo "/System/Library/Frameworks/JavaVM.framework" >&6; }
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-  fi
-
 
 
   ###############################################################################
--- a/common/autoconf/libraries.m4	Mon Jun 09 11:58:07 2014 -0700
+++ b/common/autoconf/libraries.m4	Wed Jun 18 13:12:58 2014 -0700
@@ -65,8 +65,6 @@
     ALSA_NOT_NEEDED=yes
     PULSE_NOT_NEEDED=yes
     X11_NOT_NEEDED=yes
-    # If the java runtime framework is disabled, then we need X11.
-    # This will be adjusted below.
     AC_MSG_RESULT([alsa pulse x11])
   fi
 
@@ -83,20 +81,6 @@
   if test "x$SUPPORT_HEADFUL" = xno; then
     X11_NOT_NEEDED=yes
   fi
-
-  ###############################################################################
-  #
-  # Check for MacOSX support for OpenJDK.
-  #
-
-  BASIC_DEPRECATED_ARG_ENABLE(macosx-runtime-support, macosx_runtime_support)
-
-  AC_MSG_CHECKING([for Mac OS X Java Framework])
-  if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then
-    AC_MSG_RESULT([/System/Library/Frameworks/JavaVM.framework])
-  else
-    AC_MSG_RESULT([no])
-  fi
 ])
 
 AC_DEFUN_ONCE([LIB_SETUP_X11],
--- a/common/autoconf/spec.gmk.in	Mon Jun 09 11:58:07 2014 -0700
+++ b/common/autoconf/spec.gmk.in	Wed Jun 18 13:12:58 2014 -0700
@@ -347,6 +347,9 @@
 # The linker can be gcc or ld on posix systems, or link.exe on windows systems.
 LD:=@FIXPATH@ @LD@
 
+# Xcode SDK path
+SDKROOT:=@SDKROOT@
+
 # The linker on older SuSE distros (e.g. on SLES 10) complains with:
 # "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable."
 # if feeded with a version script which contains named tags.
@@ -544,7 +547,7 @@
 XATTR:=@XATTR@
 JT_HOME:=@JT_HOME@
 JTREGEXE:=@JTREGEXE@
-
+XCODEBUILD=@XCODEBUILD@
 FIXPATH:=@FIXPATH@
 
 # Where the build output is stored for your convenience.
--- a/common/autoconf/toolchain.m4	Mon Jun 09 11:58:07 2014 -0700
+++ b/common/autoconf/toolchain.m4	Wed Jun 18 13:12:58 2014 -0700
@@ -24,11 +24,11 @@
 #
 
 ########################################################################
-# This file is responsible for detecting, verifying and setting up the 
-# toolchain, i.e. the compiler, linker and related utilities. It will setup 
+# This file is responsible for detecting, verifying and setting up the
+# toolchain, i.e. the compiler, linker and related utilities. It will setup
 # proper paths to the binaries, but it will not setup any flags.
 #
-# The binaries used is determined by the toolchain type, which is the family of 
+# The binaries used is determined by the toolchain type, which is the family of
 # compilers and related tools that are used.
 ########################################################################
 
@@ -83,7 +83,7 @@
   AC_SUBST(SHARED_LIBRARY)
   AC_SUBST(STATIC_LIBRARY)
   AC_SUBST(OBJ_SUFFIX)
-  AC_SUBST(EXE_SUFFIX)  
+  AC_SUBST(EXE_SUFFIX)
 ])
 
 # Determine which toolchain type to use, and make sure it is valid for this
@@ -98,26 +98,33 @@
   VALID_TOOLCHAINS=${!toolchain_var_name}
 
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    # On Mac OS X, default toolchain to clang after Xcode 5
-    XCODE_VERSION_OUTPUT=`xcodebuild -version 2>&1 | $HEAD -n 1`
-    $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
-    if test $? -ne 0; then
-      AC_MSG_ERROR([Failed to determine Xcode version.])
-    fi
-    XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
-        $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \
-        $CUT -f 1 -d .`
-    AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION])
-    if test $XCODE_MAJOR_VERSION -ge 5; then
-        DEFAULT_TOOLCHAIN="clang"
+    if test -n "$XCODEBUILD"; then
+      # On Mac OS X, default toolchain to clang after Xcode 5
+      XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1`
+      $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
+      if test $? -ne 0; then
+        AC_MSG_ERROR([Failed to determine Xcode version.])
+      fi
+      XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
+          $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \
+          $CUT -f 1 -d .`
+      AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION])
+      if test $XCODE_MAJOR_VERSION -ge 5; then
+          DEFAULT_TOOLCHAIN="clang"
+      else
+          DEFAULT_TOOLCHAIN="gcc"
+      fi
     else
-        DEFAULT_TOOLCHAIN="gcc"
+      # If Xcode is not installed, but the command line tools are
+      # then we can't run xcodebuild. On these systems we should
+      # default to clang
+      DEFAULT_TOOLCHAIN="clang"
     fi
   else
     # First toolchain type in the list is the default
     DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
   fi
-  
+
   if test "x$with_toolchain_type" = xlist; then
     # List all toolchains
     AC_MSG_NOTICE([The following toolchains are valid on this platform:])
@@ -126,7 +133,7 @@
       TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
       $PRINTF "  %-10s  %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
     done
-    
+
     exit 0
   elif test "x$with_toolchain_type" != x; then
     # User override; check that it is valid
@@ -168,10 +175,10 @@
     AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)])
   else
     AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.])
-  fi 
+  fi
 ])
 
-# Before we start detecting the toolchain executables, we might need some 
+# Before we start detecting the toolchain executables, we might need some
 # special setup, e.g. additional paths etc.
 AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
 [
@@ -184,7 +191,7 @@
   ORG_OBJCFLAGS="$OBJCFLAGS"
 
   # On Windows, we need to detect the visual studio installation first.
-  # This will change the PATH, but we need to keep that new PATH even 
+  # This will change the PATH, but we need to keep that new PATH even
   # after toolchain detection is done, since the compiler (on x86) uses
   # it for DLL resolution in runtime.
   if test "x$OPENJDK_BUILD_OS" = "xwindows" && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
@@ -208,7 +215,7 @@
     PATH="/usr/ccs/bin:$PATH"
   fi
 
-  # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to 
+  # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to
   # override all other locations.
   if test "x$TOOLCHAIN_PATH" != x; then
     PATH=$TOOLCHAIN_PATH:$PATH
@@ -254,7 +261,7 @@
       AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
     fi
-    # Remove usage instructions (if present), and 
+    # Remove usage instructions (if present), and
     # collapse compiler output into a single line
     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
         $SED -e 's/ *@<:@Uu@:>@sage:.*//'`
@@ -282,7 +289,7 @@
     # There is no specific version flag, but all output starts with a version string.
     # First line typically looks something like:
     # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
-    COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`    
+    COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
     # Check that this is likely to be Microsoft CL.EXE.
     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null
     if test $? -ne 0; then
@@ -360,7 +367,7 @@
     AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1])
     if test "x`basename [$]$1`" = "x[$]$1"; then
       # A command without a complete path is provided, search $PATH.
-      
+
       AC_PATH_PROGS(POTENTIAL_$1, [$]$1)
       if test "x$POTENTIAL_$1" != x; then
         $1=$POTENTIAL_$1
@@ -375,12 +382,12 @@
     fi
   else
     # No user supplied value. Locate compiler ourselves.
-    
+
     # If we are cross compiling, assume cross compilation tools follows the
     # cross compilation standard where they are prefixed with the autoconf
-    # standard name for the target. For example the binary 
+    # standard name for the target. For example the binary
     # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10.
-    # If we are not cross compiling, then the default compiler name will be 
+    # If we are not cross compiling, then the default compiler name will be
     # used.
 
     $1=
@@ -450,9 +457,9 @@
   TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME])
 ])
 
-# Detect the core components of the toolchain, i.e. the compilers (CC and CXX), 
-# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the 
-# archiver (AR). Verify that the compilers are correct according to the 
+# Detect the core components of the toolchain, i.e. the compilers (CC and CXX),
+# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the
+# archiver (AR). Verify that the compilers are correct according to the
 # toolchain type.
 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE],
 [
@@ -529,7 +536,7 @@
 ])
 
 # Setup additional tools that is considered a part of the toolchain, but not the
-# core part. Many of these are highly platform-specific and do not exist, 
+# core part. Many of these are highly platform-specific and do not exist,
 # and/or are not needed on all platforms.
 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
 [
@@ -551,7 +558,7 @@
     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
     BASIC_FIXUP_EXECUTABLE(DUMPBIN)
   fi
-  
+
   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
     BASIC_PATH_PROGS(STRIP, strip)
     BASIC_FIXUP_EXECUTABLE(STRIP)
@@ -559,7 +566,7 @@
     BASIC_FIXUP_EXECUTABLE(NM)
     BASIC_PATH_PROGS(GNM, gnm)
     BASIC_FIXUP_EXECUTABLE(GNM)
-    
+
     BASIC_PATH_PROGS(MCS, mcs)
     BASIC_FIXUP_EXECUTABLE(MCS)
   elif test "x$OPENJDK_TARGET_OS" != xwindows; then
@@ -592,17 +599,17 @@
 
 # Setup the build tools (i.e, the compiler and linker used to build programs
 # that should be run on the build platform, not the target platform, as a build
-# helper). Since the non-cross-compile case uses the normal, target compilers 
+# helper). Since the non-cross-compile case uses the normal, target compilers
 # for this, we can only do this after these have been setup.
 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS],
-[  
+[
   if test "x$COMPILE_TYPE" = "xcross"; then
     # Now we need 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. Also, we need to do this without adding a tools dir to the
     # path, otherwise we might pick up cross-compilers which don't use standard
     # naming.
-    
+
     # FIXME: we should list the discovered compilers as an exclude pattern!
     # If we do that, we can do this detection before POST_DETECTION, and still
     # find the build compilers in the tools dir, if needed.
@@ -690,15 +697,39 @@
     # If this is a --hash-style=gnu system, use --hash-style=both, why?
     HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
     # This is later checked when setting flags.
+
+    # "-Og" suppported for GCC 4.8 and later
+    CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
+    FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_OPTIMIZE_DEBUG_FLAG],
+      [HAS_CFLAG_OPTIMIZE_DEBUG=true],
+      [HAS_CFLAG_OPTIMIZE_DEBUG=false])
+
+    # "-fsanitize=undefined" supported for GCC 4.9 and later
+    CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG="-fsanitize=undefined -fsanitize-recover"
+    FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG],
+      [HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=true],
+      [HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=false])
+
+    # "-z relro" supported in GNU binutils 2.17 and later
+    LINKER_RELRO_FLAG="-Xlinker -z -Xlinker relro"
+    FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_RELRO_FLAG],
+      [HAS_LINKER_RELRO=true],
+      [HAS_LINKER_RELRO=false])
+
+    # "-z now" supported in GNU binutils 2.11 and later
+    LINKER_NOW_FLAG="-Xlinker -z -Xlinker now"
+    FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_NOW_FLAG],
+      [HAS_LINKER_NOW=true],
+      [HAS_LINKER_NOW=false])
   fi
 
-  # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed 
+  # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed
   # in executable.'
   USING_BROKEN_SUSE_LD=no
   if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then
     AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables])
-    echo "SUNWprivate_1.1 { local: *; };" > version-script.map
-    echo "int main() { }" > main.c
+    $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map
+    $ECHO "int main() { }" > main.c
     if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
       AC_MSG_RESULT(no)
       USING_BROKEN_SUSE_LD=no
--- a/corba/.hgtags	Mon Jun 09 11:58:07 2014 -0700
+++ b/corba/.hgtags	Wed Jun 18 13:12:58 2014 -0700
@@ -259,3 +259,5 @@
 a2b82f863ba95a596da555a4c1b871c404863e7e jdk9-b14
 e54022d0dd92106fff7f7fe670010cd7e6517ee3 jdk9-b15
 422ef9d29d84f571453f015c4cb8713c3af70ee4 jdk9-b16
+4c75c2ca7cf3e0618315879acf17f42c8fcd0c09 jdk9-b17
+77565aaaa2bb814e94817e92d680168052a25395 jdk9-b18
--- a/hotspot/.hgtags	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/.hgtags	Wed Jun 18 13:12:58 2014 -0700
@@ -419,3 +419,5 @@
 bd333491bb6c012d7b606939406d0fa9a5ac7ffd jdk9-b14
 170f6d733d7aec062f743a6b8c1cce940a7a984a jdk9-b15
 b14e7c0b7d3ec04127f565cda1d84122e205680c jdk9-b16
+14b656df31c2cb09c505921061e79977823de71a jdk9-b17
+871fd128548480095e0dc3fc34c422666baeec75 jdk9-b18
--- a/hotspot/make/bsd/makefiles/universal.gmk	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/make/bsd/makefiles/universal.gmk	Wed Jun 18 13:12:58 2014 -0700
@@ -74,19 +74,21 @@
 
 
 # Replace arch specific binaries with universal binaries
+# Do not touch jre/lib/{client,server}/libjsig.$(LIBRARY_SUFFIX)
+# That symbolic link belongs to the 'jdk' build.
 export_universal:
 	$(RM) -r $(EXPORT_PATH)/jre/lib/{i386,amd64}
 	$(RM) -r $(JDK_IMAGE_DIR)/jre/lib/{i386,amd64}
-	$(RM) $(JDK_IMAGE_DIR)/jre/lib/{client,server}/libjsig.$(LIBRARY_SUFFIX)
 	($(CD) $(EXPORT_PATH) && \
 	  $(TAR) -cf - *) | \
 	  ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xpf -)
 
 
 # Overlay universal binaries
+# Do not touch jre/lib/{client,server}/libjsig.$(LIBRARY_SUFFIX)
+# That symbolic link belongs to the 'jdk' build.
 copy_universal:
 	$(RM) -r $(JDK_IMAGE_DIR)$(COPY_SUBDIR)/jre/lib/{i386,amd64}
-	$(RM) $(JDK_IMAGE_DIR)$(COPY_SUBDIR)/jre/lib/{client,server}/libjsig.$(LIBRARY_SUFFIX)
 	($(CD) $(EXPORT_PATH)$(COPY_SUBDIR) && \
 	  $(TAR) -cf - *) | \
 	  ($(CD) $(JDK_IMAGE_DIR)$(COPY_SUBDIR) && $(TAR) -xpf -)
--- a/hotspot/make/jprt.properties	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/make/jprt.properties	Wed Jun 18 13:12:58 2014 -0700
@@ -47,10 +47,10 @@
 #       sparc etc.
 
 # Define the Solaris platforms we want for the various releases
-jprt.my.solaris.sparcv9.jdk9=solaris_sparcv9_5.10
+jprt.my.solaris.sparcv9.jdk9=solaris_sparcv9_5.11
 jprt.my.solaris.sparcv9=${jprt.my.solaris.sparcv9.${jprt.tools.default.release}}
 
-jprt.my.solaris.x64.jdk9=solaris_x64_5.10
+jprt.my.solaris.x64.jdk9=solaris_x64_5.11
 jprt.my.solaris.x64=${jprt.my.solaris.x64.${jprt.tools.default.release}}
 
 jprt.my.linux.i586.jdk9=linux_i586_2.6
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -4359,9 +4359,15 @@
   Method* m = k->lookup_method(vmSymbols::finalize_method_name(),
                                  vmSymbols::void_method_signature());
   if (m != NULL && !m->is_empty_method()) {
-    f = true;
+      f = true;
   }
-  assert(f == k->has_finalizer(), "inconsistent has_finalizer");
+
+  // Spec doesn't prevent agent from redefinition of empty finalizer.
+  // Despite the fact that it's generally bad idea and redefined finalizer
+  // will not work as expected we shouldn't abort vm in this case
+  if (!k->has_redefined_this_or_super()) {
+    assert(f == k->has_finalizer(), "inconsistent has_finalizer");
+  }
 #endif
 
   // Check if this klass supports the java.lang.Cloneable interface
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp	Wed Jun 18 13:12:58 2014 -0700
@@ -1181,7 +1181,7 @@
   static oop              target(         oop site)             { return site->obj_field(             _target_offset);         }
   static void         set_target(         oop site, oop target) {        site->obj_field_put(         _target_offset, target); }
 
-  static volatile oop     target_volatile(oop site)             { return site->obj_field_volatile(    _target_offset);         }
+  static volatile oop     target_volatile(oop site)             { return oop((oopDesc *)(site->obj_field_volatile(_target_offset))); }
   static void         set_target_volatile(oop site, oop target) {        site->obj_field_put_volatile(_target_offset, target); }
 
   // Testers
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -311,8 +311,7 @@
                              _cmsGen->refs_discovery_is_mt(),     // mt discovery
                              (int) MAX2(ConcGCThreads, ParallelGCThreads), // mt discovery degree
                              _cmsGen->refs_discovery_is_atomic(), // discovery is not atomic
-                             &_is_alive_closure,                  // closure for liveness info
-                             false);                              // next field updates do not need write barrier
+                             &_is_alive_closure);                 // closure for liveness info
     // Initialize the _ref_processor field of CMSGen
     _cmsGen->set_ref_processor(_ref_processor);
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -2246,12 +2246,9 @@
                                 // degree of mt discovery
                            false,
                                 // Reference discovery is not atomic
-                           &_is_alive_closure_cm,
+                           &_is_alive_closure_cm);
                                 // is alive closure
                                 // (for efficiency/performance)
-                           true);
-                                // Setting next fields of discovered
-                                // lists requires a barrier.
 
   // STW ref processor
   _ref_processor_stw =
@@ -2266,12 +2263,9 @@
                                 // degree of mt discovery
                            true,
                                 // Reference discovery is atomic
-                           &_is_alive_closure_stw,
+                           &_is_alive_closure_stw);
                                 // is alive closure
                                 // (for efficiency/performance)
-                           false);
-                                // Setting next fields of discovered
-                                // lists does not require a barrier.
 }
 
 size_t G1CollectedHeap::capacity() const {
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -1636,8 +1636,7 @@
                              refs_discovery_is_mt(),     // mt discovery
                              (int) ParallelGCThreads,    // mt discovery degree
                              refs_discovery_is_atomic(), // atomic_discovery
-                             NULL,                       // is_alive_non_header
-                             false);                     // write barrier for next field updates
+                             NULL);                      // is_alive_non_header
   }
 }
 
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -854,8 +854,7 @@
                            true,          // mt discovery
                            (int) ParallelGCThreads, // mt discovery degree
                            true,          // atomic_discovery
-                           &_is_alive_closure, // non-header is alive closure
-                           false);        // write barrier for next field updates
+                           &_is_alive_closure); // non-header is alive closure
   _counters = new CollectorCounters("PSParallelCompact", 1);
 
   // Initialize static fields in ParCompactionManager.
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -864,8 +864,7 @@
                            true,                       // mt discovery
                            (int) ParallelGCThreads,    // mt discovery degree
                            true,                       // atomic_discovery
-                           NULL,                       // header provides liveness info
-                           false);                     // next field updates do not need write barrier
+                           NULL);                      // header provides liveness info
 
   // Cache the cardtable
   BarrierSet* bs = Universe::heap()->barrier_set();
--- a/hotspot/src/share/vm/memory/allocation.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/memory/allocation.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -563,6 +563,7 @@
   _chunk = new (alloc_failmode, len) Chunk(len);
 
   if (_chunk == NULL) {
+    _chunk = k;                 // restore the previous value of _chunk
     return NULL;
   }
   if (k) k->set_next(_chunk);   // Append new chunk to end of linked list
--- a/hotspot/src/share/vm/memory/metaspace.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/memory/metaspace.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -1423,6 +1423,17 @@
   return (size_t)Atomic::add_ptr(-(intptr_t)v, &_capacity_until_GC);
 }
 
+void MetaspaceGC::initialize() {
+  // Set the high-water mark to MaxMetapaceSize during VM initializaton since
+  // we can't do a GC during initialization.
+  _capacity_until_GC = MaxMetaspaceSize;
+}
+
+void MetaspaceGC::post_initialize() {
+  // Reset the high-water mark once the VM initialization is done.
+  _capacity_until_GC = MAX2(MetaspaceAux::committed_bytes(), MetaspaceSize);
+}
+
 bool MetaspaceGC::can_expand(size_t word_size, bool is_class) {
   // Check if the compressed class space is full.
   if (is_class && Metaspace::using_class_space()) {
@@ -1443,21 +1454,13 @@
 
 size_t MetaspaceGC::allowed_expansion() {
   size_t committed_bytes = MetaspaceAux::committed_bytes();
+  size_t capacity_until_gc = capacity_until_GC();
+
+  assert(capacity_until_gc >= committed_bytes,
+        err_msg("capacity_until_gc: " SIZE_FORMAT " < committed_bytes: " SIZE_FORMAT,
+                capacity_until_gc, committed_bytes));
 
   size_t left_until_max  = MaxMetaspaceSize - committed_bytes;
-
-  // Always grant expansion if we are initiating the JVM,
-  // or if the GC_locker is preventing GCs.
-  if (!is_init_completed() || GC_locker::is_active_and_needs_gc()) {
-    return left_until_max / BytesPerWord;
-  }
-
-  size_t capacity_until_gc = capacity_until_GC();
-
-  if (capacity_until_gc <= committed_bytes) {
-    return 0;
-  }
-
   size_t left_until_GC = capacity_until_gc - committed_bytes;
   size_t left_to_commit = MIN2(left_until_GC, left_until_max);
 
@@ -1469,7 +1472,15 @@
   uint current_shrink_factor = _shrink_factor;
   _shrink_factor = 0;
 
-  const size_t used_after_gc = MetaspaceAux::capacity_bytes();
+  // Using committed_bytes() for used_after_gc is an overestimation, since the
+  // chunk free lists are included in committed_bytes() and the memory in an
+  // un-fragmented chunk free list is available for future allocations.
+  // However, if the chunk free lists becomes fragmented, then the memory may
+  // not be available for future allocations and the memory is therefore "in use".
+  // Including the chunk free lists in the definition of "in use" is therefore
+  // necessary. Not including the chunk free lists can cause capacity_until_GC to
+  // shrink below committed_bytes() and this has caused serious bugs in the past.
+  const size_t used_after_gc = MetaspaceAux::committed_bytes();
   const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC();
 
   const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0;
@@ -3094,6 +3105,8 @@
 }
 
 void Metaspace::global_initialize() {
+  MetaspaceGC::initialize();
+
   // Initialize the alignment for shared spaces.
   int max_alignment = os::vm_allocation_granularity();
   size_t cds_total = 0;
@@ -3201,10 +3214,13 @@
     }
   }
 
-  MetaspaceGC::initialize();
   _tracer = new MetaspaceTracer();
 }
 
+void Metaspace::post_initialize() {
+  MetaspaceGC::post_initialize();
+}
+
 Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype,
                                                size_t chunk_word_size,
                                                size_t chunk_bunch) {
--- a/hotspot/src/share/vm/memory/metaspace.hpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/memory/metaspace.hpp	Wed Jun 18 13:12:58 2014 -0700
@@ -208,6 +208,7 @@
 
   static void ergo_initialize();
   static void global_initialize();
+  static void post_initialize();
 
   static size_t first_chunk_word_size() { return _first_chunk_word_size; }
   static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; }
@@ -398,7 +399,8 @@
 
  public:
 
-  static void initialize() { _capacity_until_GC = MetaspaceSize; }
+  static void initialize();
+  static void post_initialize();
 
   static size_t capacity_until_GC();
   static size_t inc_capacity_until_GC(size_t v);
--- a/hotspot/src/share/vm/memory/referenceProcessor.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -96,12 +96,10 @@
                                        bool      mt_discovery,
                                        uint      mt_discovery_degree,
                                        bool      atomic_discovery,
-                                       BoolObjectClosure* is_alive_non_header,
-                                       bool      discovered_list_needs_post_barrier)  :
+                                       BoolObjectClosure* is_alive_non_header)  :
   _discovering_refs(false),
   _enqueuing_is_done(false),
   _is_alive_non_header(is_alive_non_header),
-  _discovered_list_needs_post_barrier(discovered_list_needs_post_barrier),
   _processing_is_mt(mt_processing),
   _next_id(0)
 {
@@ -340,10 +338,18 @@
   // (java.lang.ref.Reference.discovered), self-loop their "next" field
   // thus distinguishing them from active References, then
   // prepend them to the pending list.
+  //
+  // The Java threads will see the Reference objects linked together through
+  // the discovered field. Instead of trying to do the write barrier updates
+  // in all places in the reference processor where we manipulate the discovered
+  // field we make sure to do the barrier here where we anyway iterate through
+  // all linked Reference objects. Note that it is important to not dirty any
+  // cards during reference processing since this will cause card table
+  // verification to fail for G1.
+  //
   // BKWRD COMPATIBILITY NOTE: For older JDKs (prior to the fix for 4956777),
   // the "next" field is used to chain the pending list, not the discovered
   // field.
-
   if (TraceReferenceGC && PrintGCDetails) {
     gclog_or_tty->print_cr("ReferenceProcessor::enqueue_discovered_reflist list "
                            INTPTR_FORMAT, (address)refs_list.head());
@@ -365,15 +371,15 @@
       assert(java_lang_ref_Reference::next(obj) == NULL,
              "Reference not active; should not be discovered");
       // Self-loop next, so as to make Ref not active.
-      // Post-barrier not needed when looping to self.
       java_lang_ref_Reference::set_next_raw(obj, obj);
-      if (next_d == obj) {  // obj is last
+      if (next_d != obj) {
+        oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), next_d);
+      } else {
+        // This is the last object.
         // Swap refs_list into pending_list_addr and
         // set obj's discovered to what we read from pending_list_addr.
         oop old = oopDesc::atomic_exchange_oop(refs_list.head(), pending_list_addr);
-        // Need post-barrier on pending_list_addr above;
-        // see special post-barrier code at the end of
-        // enqueue_discovered_reflists() further below.
+        // Need post-barrier on pending_list_addr. See enqueue_discovered_ref_helper() above.
         java_lang_ref_Reference::set_discovered_raw(obj, old); // old may be NULL
         oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), old);
       }
@@ -496,20 +502,15 @@
   // pre-barrier here because we know the Reference has already been found/marked,
   // that's how it ended up in the discovered list in the first place.
   oop_store_raw(_prev_next, new_next);
-  if (_discovered_list_needs_post_barrier && _prev_next != _refs_list.adr_head()) {
-    // Needs post-barrier and this is not the list head (which is not on the heap)
-    oopDesc::bs()->write_ref_field(_prev_next, new_next);
-  }
   NOT_PRODUCT(_removed++);
   _refs_list.dec_length(1);
 }
 
 // Make the Reference object active again.
 void DiscoveredListIterator::make_active() {
-  // For G1 we don't want to use set_next - it
-  // will dirty the card for the next field of
-  // the reference object and will fail
-  // CT verification.
+  // The pre barrier for G1 is probably just needed for the old
+  // reference processing behavior. Should we guard this with
+  // ReferenceProcessor::pending_list_uses_discovered_field() ?
   if (UseG1GC) {
     HeapWord* next_addr = java_lang_ref_Reference::next_addr(_ref);
     if (UseCompressedOops) {
@@ -517,10 +518,8 @@
     } else {
       oopDesc::bs()->write_ref_field_pre((oop*)next_addr, NULL);
     }
-    java_lang_ref_Reference::set_next_raw(_ref, NULL);
-  } else {
-    java_lang_ref_Reference::set_next(_ref, NULL);
   }
+  java_lang_ref_Reference::set_next_raw(_ref, NULL);
 }
 
 void DiscoveredListIterator::clear_referent() {
@@ -546,7 +545,7 @@
                                    OopClosure*        keep_alive,
                                    VoidClosure*       complete_gc) {
   assert(policy != NULL, "Must have a non-NULL policy");
-  DiscoveredListIterator iter(refs_list, keep_alive, is_alive, _discovered_list_needs_post_barrier);
+  DiscoveredListIterator iter(refs_list, keep_alive, is_alive);
   // Decide which softly reachable refs should be kept alive.
   while (iter.has_next()) {
     iter.load_ptrs(DEBUG_ONLY(!discovery_is_atomic() /* allow_null_referent */));
@@ -586,7 +585,7 @@
                              BoolObjectClosure* is_alive,
                              OopClosure*        keep_alive) {
   assert(discovery_is_atomic(), "Error");
-  DiscoveredListIterator iter(refs_list, keep_alive, is_alive, _discovered_list_needs_post_barrier);
+  DiscoveredListIterator iter(refs_list, keep_alive, is_alive);
   while (iter.has_next()) {
     iter.load_ptrs(DEBUG_ONLY(false /* allow_null_referent */));
     DEBUG_ONLY(oop next = java_lang_ref_Reference::next(iter.obj());)
@@ -623,7 +622,7 @@
                                                   OopClosure*        keep_alive,
                                                   VoidClosure*       complete_gc) {
   assert(!discovery_is_atomic(), "Error");
-  DiscoveredListIterator iter(refs_list, keep_alive, is_alive, _discovered_list_needs_post_barrier);
+  DiscoveredListIterator iter(refs_list, keep_alive, is_alive);
   while (iter.has_next()) {
     iter.load_ptrs(DEBUG_ONLY(true /* allow_null_referent */));
     HeapWord* next_addr = java_lang_ref_Reference::next_addr(iter.obj());
@@ -666,7 +665,7 @@
                                    OopClosure*        keep_alive,
                                    VoidClosure*       complete_gc) {
   ResourceMark rm;
-  DiscoveredListIterator iter(refs_list, keep_alive, is_alive, _discovered_list_needs_post_barrier);
+  DiscoveredListIterator iter(refs_list, keep_alive, is_alive);
   while (iter.has_next()) {
     iter.update_discovered();
     iter.load_ptrs(DEBUG_ONLY(false /* allow_null_referent */));
@@ -782,13 +781,6 @@
   bool _clear_referent;
 };
 
-void ReferenceProcessor::set_discovered(oop ref, oop value) {
-  java_lang_ref_Reference::set_discovered_raw(ref, value);
-  if (_discovered_list_needs_post_barrier) {
-    oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(ref), value);
-  }
-}
-
 // Balances reference queues.
 // Move entries from all queues[0, 1, ..., _max_num_q-1] to
 // queues[0, 1, ..., _num_q-1] because only the first _num_q
@@ -846,9 +838,9 @@
         // Add the chain to the to list.
         if (ref_lists[to_idx].head() == NULL) {
           // to list is empty. Make a loop at the end.
-          set_discovered(move_tail, move_tail);
+          java_lang_ref_Reference::set_discovered_raw(move_tail, move_tail);
         } else {
-          set_discovered(move_tail, ref_lists[to_idx].head());
+          java_lang_ref_Reference::set_discovered_raw(move_tail, ref_lists[to_idx].head());
         }
         ref_lists[to_idx].set_head(move_head);
         ref_lists[to_idx].inc_length(refs_to_move);
@@ -982,7 +974,7 @@
 
 void ReferenceProcessor::clean_up_discovered_reflist(DiscoveredList& refs_list) {
   assert(!discovery_is_atomic(), "Else why call this method?");
-  DiscoveredListIterator iter(refs_list, NULL, NULL, _discovered_list_needs_post_barrier);
+  DiscoveredListIterator iter(refs_list, NULL, NULL);
   while (iter.has_next()) {
     iter.load_ptrs(DEBUG_ONLY(true /* allow_null_referent */));
     oop next = java_lang_ref_Reference::next(iter.obj());
@@ -1071,16 +1063,6 @@
   // The last ref must have its discovered field pointing to itself.
   oop next_discovered = (current_head != NULL) ? current_head : obj;
 
-  // Note: In the case of G1, this specific pre-barrier is strictly
-  // not necessary because the only case we are interested in
-  // here is when *discovered_addr is NULL (see the CAS further below),
-  // so this will expand to nothing. As a result, we have manually
-  // elided this out for G1, but left in the test for some future
-  // collector that might have need for a pre-barrier here, e.g.:-
-  // oopDesc::bs()->write_ref_field_pre((oop* or narrowOop*)discovered_addr, next_discovered);
-  assert(!_discovered_list_needs_post_barrier || UseG1GC,
-         "Need to check non-G1 collector: "
-         "may need a pre-write-barrier for CAS from NULL below");
   oop retest = oopDesc::atomic_compare_exchange_oop(next_discovered, discovered_addr,
                                                     NULL);
   if (retest == NULL) {
@@ -1089,9 +1071,6 @@
     // is necessary.
     refs_list.set_head(obj);
     refs_list.inc_length(1);
-    if (_discovered_list_needs_post_barrier) {
-      oopDesc::bs()->write_ref_field((void*)discovered_addr, next_discovered);
-    }
 
     if (TraceReferenceGC) {
       gclog_or_tty->print_cr("Discovered reference (mt) (" INTPTR_FORMAT ": %s)",
@@ -1242,24 +1221,14 @@
   if (_discovery_is_mt) {
     add_to_discovered_list_mt(*list, obj, discovered_addr);
   } else {
-    // If "_discovered_list_needs_post_barrier", we do write barriers when
-    // updating the discovered reference list.  Otherwise, we do a raw store
-    // here: the field will be visited later when processing the discovered
-    // references.
+    // We do a raw store here: the field will be visited later when processing
+    // the discovered references.
     oop current_head = list->head();
     // The last ref must have its discovered field pointing to itself.
     oop next_discovered = (current_head != NULL) ? current_head : obj;
 
-    // As in the case further above, since we are over-writing a NULL
-    // pre-value, we can safely elide the pre-barrier here for the case of G1.
-    // e.g.:- oopDesc::bs()->write_ref_field_pre((oop* or narrowOop*)discovered_addr, next_discovered);
     assert(discovered == NULL, "control point invariant");
-    assert(!_discovered_list_needs_post_barrier || UseG1GC,
-           "For non-G1 collector, may need a pre-write-barrier for CAS from NULL below");
     oop_store_raw(discovered_addr, next_discovered);
-    if (_discovered_list_needs_post_barrier) {
-      oopDesc::bs()->write_ref_field((void*)discovered_addr, next_discovered);
-    }
     list->set_head(obj);
     list->inc_length(1);
 
@@ -1353,7 +1322,7 @@
                                                 OopClosure*        keep_alive,
                                                 VoidClosure*       complete_gc,
                                                 YieldClosure*      yield) {
-  DiscoveredListIterator iter(refs_list, keep_alive, is_alive, _discovered_list_needs_post_barrier);
+  DiscoveredListIterator iter(refs_list, keep_alive, is_alive);
   while (iter.has_next()) {
     iter.load_ptrs(DEBUG_ONLY(true /* allow_null_referent */));
     oop obj = iter.obj();
--- a/hotspot/src/share/vm/memory/referenceProcessor.hpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/memory/referenceProcessor.hpp	Wed Jun 18 13:12:58 2014 -0700
@@ -99,7 +99,6 @@
   oop                _referent;
   OopClosure*        _keep_alive;
   BoolObjectClosure* _is_alive;
-  bool               _discovered_list_needs_post_barrier;
 
   DEBUG_ONLY(
   oop                _first_seen; // cyclic linked list check
@@ -113,8 +112,7 @@
 public:
   inline DiscoveredListIterator(DiscoveredList&    refs_list,
                                 OopClosure*        keep_alive,
-                                BoolObjectClosure* is_alive,
-                                bool               discovered_list_needs_post_barrier = false):
+                                BoolObjectClosure* is_alive):
     _refs_list(refs_list),
     _prev_next(refs_list.adr_head()),
     _prev(NULL),
@@ -128,8 +126,7 @@
 #endif
     _next(NULL),
     _keep_alive(keep_alive),
-    _is_alive(is_alive),
-    _discovered_list_needs_post_barrier(discovered_list_needs_post_barrier)
+    _is_alive(is_alive)
 { }
 
   // End Of List.
@@ -230,14 +227,6 @@
                                         // other collectors in configuration
   bool        _discovery_is_mt;         // true if reference discovery is MT.
 
-  // If true, setting "next" field of a discovered refs list requires
-  // write post barrier.  (Must be true if used in a collector in which
-  // elements of a discovered list may be moved during discovery: for
-  // example, a collector like Garbage-First that moves objects during a
-  // long-term concurrent marking phase that does weak reference
-  // discovery.)
-  bool        _discovered_list_needs_post_barrier;
-
   bool        _enqueuing_is_done;       // true if all weak references enqueued
   bool        _processing_is_mt;        // true during phases when
                                         // reference processing is MT.
@@ -382,11 +371,6 @@
   void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor);
 
  protected:
-  // Set the 'discovered' field of the given reference to
-  // the given value - emitting post barriers depending upon
-  // the value of _discovered_list_needs_post_barrier.
-  void set_discovered(oop ref, oop value);
-
   // "Preclean" the given discovered reference list
   // by removing references with strongly reachable referents.
   // Currently used in support of CMS only.
@@ -427,8 +411,7 @@
                      bool mt_processing = false, uint mt_processing_degree = 1,
                      bool mt_discovery  = false, uint mt_discovery_degree  = 1,
                      bool atomic_discovery = true,
-                     BoolObjectClosure* is_alive_non_header = NULL,
-                     bool discovered_list_needs_post_barrier = false);
+                     BoolObjectClosure* is_alive_non_header = NULL);
 
   // RefDiscoveryPolicy values
   enum DiscoveryPolicy {
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -1501,6 +1501,21 @@
   return NULL;
 }
 
+#ifdef ASSERT
+// search through class hierarchy and return true if this class or
+// one of the superclasses was redefined
+bool InstanceKlass::has_redefined_this_or_super() const {
+  const InstanceKlass* klass = this;
+  while (klass != NULL) {
+    if (klass->has_been_redefined()) {
+      return true;
+    }
+    klass = InstanceKlass::cast(klass->super());
+  }
+  return false;
+}
+#endif
+
 // lookup a method in the default methods list then in all transitive interfaces
 // Do NOT return private or static methods
 Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name,
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp	Wed Jun 18 13:12:58 2014 -0700
@@ -754,6 +754,11 @@
   bool implements_interface(Klass* k) const;
   bool is_same_or_direct_interface(Klass* k) const;
 
+#ifdef ASSERT
+  // check whether this class or one of its superclasses was redefined
+  bool has_redefined_this_or_super() const;
+#endif
+
   // Access to the implementor of an interface.
   Klass* implementor() const
   {
@@ -811,8 +816,8 @@
 
   // Casting from Klass*
   static InstanceKlass* cast(Klass* k) {
-    assert(k->is_klass(), "must be");
-    assert(k->oop_is_instance(), "cast to InstanceKlass");
+    assert(k == NULL || k->is_klass(), "must be");
+    assert(k == NULL || k->oop_is_instance(), "cast to InstanceKlass");
     return (InstanceKlass*) k;
   }
 
--- a/hotspot/src/share/vm/oops/oopsHierarchy.hpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/oops/oopsHierarchy.hpp	Wed Jun 18 13:12:58 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,9 +112,7 @@
 
   // Assignment
   oop& operator=(const oop& o)                            { _o = o.obj(); return *this; }
-#ifndef SOLARIS
   volatile oop& operator=(const oop& o) volatile          { _o = o.obj(); return *this; }
-#endif
   volatile oop& operator=(const volatile oop& o) volatile { _o = o.obj(); return *this; }
 
   // Explict user conversions
@@ -123,11 +121,10 @@
   operator void* () const volatile    { return (void *)obj(); }
 #endif
   operator HeapWord* () const         { return (HeapWord*)obj(); }
-  operator oopDesc* () const          { return obj(); }
+  operator oopDesc* () const volatile { return obj(); }
   operator intptr_t* () const         { return (intptr_t*)obj(); }
   operator PromotedObject* () const   { return (PromotedObject*)obj(); }
   operator markOop () const           { return markOop(obj()); }
-
   operator address   () const         { return (address)obj(); }
 
   // from javaCalls.cpp
@@ -161,11 +158,10 @@
             oop::operator=(o);                                             \
             return *this;                                                  \
        }                                                                   \
-       NOT_SOLARIS(                                                        \
        volatile type##Oop& operator=(const type##Oop& o) volatile {        \
             (void)const_cast<oop&>(oop::operator=(o));                     \
             return *this;                                                  \
-       })                                                                  \
+       }                                                                   \
        volatile type##Oop& operator=(const volatile type##Oop& o) volatile {\
             (void)const_cast<oop&>(oop::operator=(o));                     \
             return *this;                                                  \
--- a/hotspot/src/share/vm/runtime/mutexLocker.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -280,10 +280,10 @@
 
 #ifdef INCLUDE_TRACE
   def(JfrMsg_lock                  , Monitor, leaf,        true);
-  def(JfrBuffer_lock               , Mutex,   nonleaf+1,   true);
-  def(JfrThreadGroups_lock         , Mutex,   nonleaf+1,   true);
-  def(JfrStream_lock               , Mutex,   nonleaf+2,   true);
-  def(JfrStacktrace_lock           , Mutex,   special,     true );
+  def(JfrBuffer_lock               , Mutex,   leaf,        true);
+  def(JfrThreadGroups_lock         , Mutex,   leaf,        true);
+  def(JfrStream_lock               , Mutex,   nonleaf,     true);
+  def(JfrStacktrace_lock           , Mutex,   special,     true);
 #endif
 
 }
--- a/hotspot/src/share/vm/runtime/objectMonitor.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/runtime/objectMonitor.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -385,6 +385,15 @@
       jt->java_suspend_self();
     }
     Self->set_current_pending_monitor(NULL);
+
+    // We cleared the pending monitor info since we've just gotten past
+    // the enter-check-for-suspend dance and we now own the monitor free
+    // and clear, i.e., it is no longer pending. The ThreadBlockInVM
+    // destructor can go to a safepoint at the end of this block. If we
+    // do a thread dump during that safepoint, then this thread will show
+    // as having "-locked" the monitor, but the OS and java.lang.Thread
+    // states will still report that the thread is blocked trying to
+    // acquire it.
   }
 
   Atomic::dec_ptr(&_count);
--- a/hotspot/src/share/vm/runtime/thread.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -1434,7 +1434,7 @@
   _in_deopt_handler = 0;
   _doing_unsafe_access = false;
   _stack_guard_state = stack_guard_unused;
-  (void)const_cast<oop&>(_exception_oop = NULL);
+  (void)const_cast<oop&>(_exception_oop = oop(NULL));
   _exception_pc  = 0;
   _exception_handler_pc = 0;
   _is_method_handle_return = 0;
@@ -3543,6 +3543,8 @@
   // debug stuff, that does not work until all basic classes have been initialized.
   set_init_completed();
 
+  Metaspace::post_initialize();
+
   HOTSPOT_VM_INIT_END();
 
   // record VM initialization completion time
--- a/hotspot/src/share/vm/runtime/vframe.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/runtime/vframe.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -199,6 +199,7 @@
         continue;
       }
       if (monitor->owner() != NULL) {
+        // the monitor is associated with an object, i.e., it is locked
 
         // First, assume we have the monitor locked. If we haven't found an
         // owned monitor before and this is the first frame, then we need to
@@ -209,7 +210,11 @@
         if (!found_first_monitor && frame_count == 0) {
           markOop mark = monitor->owner()->mark();
           if (mark->has_monitor() &&
-              mark->monitor() == thread()->current_pending_monitor()) {
+              ( // we have marked ourself as pending on this monitor
+                mark->monitor() == thread()->current_pending_monitor() ||
+                // we are not the owner of this monitor
+                !mark->monitor()->is_entered(thread())
+              )) {
             lock_state = "waiting to lock";
           }
         }
--- a/hotspot/src/share/vm/services/attachListener.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/services/attachListener.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -162,10 +162,7 @@
     java_lang_Throwable::print(PENDING_EXCEPTION, out);
     out->cr();
     CLEAR_PENDING_EXCEPTION;
-    // The exception has been printed on the output stream
-    // If the JVM returns JNI_ERR, the attachAPI throws a generic I/O
-    // exception and the content of the output stream is not processed.
-    // By returning JNI_OK, the exception will be displayed on the client side
+    return JNI_ERR;
   }
   return JNI_OK;
 }
--- a/hotspot/src/share/vm/services/memoryManager.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/services/memoryManager.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 
 MemoryManager::MemoryManager() {
   _num_pools = 0;
-  (void)const_cast<instanceOop&>(_memory_mgr_obj = NULL);
+  (void)const_cast<instanceOop&>(_memory_mgr_obj = instanceOop(NULL));
 }
 
 void MemoryManager::add_pool(MemoryPool* pool) {
--- a/hotspot/src/share/vm/services/memoryPool.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/services/memoryPool.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
   _name = name;
   _initial_size = init_size;
   _max_size = max_size;
-  (void)const_cast<instanceOop&>(_memory_pool_obj = NULL);
+  (void)const_cast<instanceOop&>(_memory_pool_obj = instanceOop(NULL));
   _available_for_allocation = true;
   _num_managers = 0;
   _type = type;
--- a/hotspot/src/share/vm/utilities/debug.cpp	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/src/share/vm/utilities/debug.cpp	Wed Jun 18 13:12:58 2014 -0700
@@ -263,13 +263,11 @@
 
 void report_out_of_shared_space(SharedSpaceType shared_space) {
   static const char* name[] = {
-    "native memory for metadata",
     "shared read only space",
     "shared read write space",
     "shared miscellaneous data space"
   };
   static const char* flag[] = {
-    "Metaspace",
     "SharedReadOnlySize",
     "SharedReadWriteSize",
     "SharedMiscDataSize"
--- a/hotspot/test/TEST.groups	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/TEST.groups	Wed Jun 18 13:12:58 2014 -0700
@@ -81,6 +81,7 @@
   runtime/NMT/ThreadedVirtualAllocTestType.java \
   runtime/NMT/VirtualAllocTestType.java \
   runtime/RedefineObject/TestRedefineObject.java \
+  runtime/Thread/TestThreadDumpMonitorContention.java \
   runtime/XCheckJniJsig/XCheckJSig.java \
   serviceability/attach/AttachWithStalePidFile.java \
   serviceability/jvmti/8036666/GetObjectLockCount.java \
--- a/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,6 +22,7 @@
 */
 
 /*
+ * @ignore 8027915
  * @test TestParallelHeapSizeFlags
  * @key gc
  * @bug 8006088
--- a/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,6 +22,7 @@
 */
 
 /*
+ * @ignore 8025645
  * @test TestUseCompressedOopsErgo
  * @key gc
  * @bug 8010722
--- a/hotspot/test/gc/g1/TestHumongousShrinkHeap.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/gc/g1/TestHumongousShrinkHeap.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,6 +22,7 @@
  */
 
 /**
+ * @ignore 8041506, 8041946, 8042051
  * @test TestHumongousShrinkHeap
  * @bug 8036025
  * @summary Verify that heap shrinks after GC in the presence of fragmentation due to humongous objects
--- a/hotspot/test/gc/g1/TestStringDeduplicationMemoryUsage.java	Mon Jun 09 11:58:07 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute 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 TestStringDeduplicationMemoryUsage
- * @summary Test string deduplication memory usage
- * @bug 8029075
- * @key gc
- * @library /testlibrary
- */
-
-public class TestStringDeduplicationMemoryUsage {
-    public static void main(String[] args) throws Exception {
-        TestStringDeduplicationTools.testMemoryUsage();
-    }
-}
--- a/hotspot/test/gc/g1/TestStringDeduplicationTools.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/gc/g1/TestStringDeduplicationTools.java	Wed Jun 18 13:12:58 2014 -0700
@@ -294,55 +294,6 @@
         }
     }
 
-    private static class MemoryUsageTest {
-        public static void main(String[] args) {
-            System.out.println("Begin: MemoryUsageTest");
-
-            final boolean useStringDeduplication = Boolean.parseBoolean(args[0]);
-            final int numberOfStrings = LargeNumberOfStrings;
-            final int numberOfUniqueStrings = 1;
-
-            ArrayList<String> list = createStrings(numberOfStrings, numberOfUniqueStrings);
-            forceDeduplication(DefaultAgeThreshold, FullGC);
-
-            if (useStringDeduplication) {
-                verifyStrings(list, numberOfUniqueStrings);
-            }
-
-            System.gc();
-
-            System.out.println("Heap Memory Usage: " + ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed());
-            System.out.println("Array Header Size: " + unsafe.ARRAY_CHAR_BASE_OFFSET);
-
-            System.out.println("End: MemoryUsageTest");
-        }
-
-        public static OutputAnalyzer run(boolean useStringDeduplication) throws Exception {
-            String[] extraArgs = new String[0];
-
-            if (useStringDeduplication) {
-                extraArgs = new String[] {
-                    "-XX:+UseStringDeduplication",
-                    "-XX:+PrintStringDeduplicationStatistics",
-                    "-XX:StringDeduplicationAgeThreshold=" + DefaultAgeThreshold
-                };
-            }
-
-            String[] defaultArgs = new String[] {
-                "-XX:+PrintGC",
-                "-XX:+PrintGCDetails",
-                MemoryUsageTest.class.getName(),
-                "" + useStringDeduplication
-            };
-
-            ArrayList<String> args = new ArrayList<String>();
-            args.addAll(Arrays.asList(extraArgs));
-            args.addAll(Arrays.asList(defaultArgs));
-
-            return runTest(args.toArray(new String[args.size()]));
-        }
-    }
-
     /*
      * Tests
      */
@@ -480,44 +431,4 @@
         OutputAnalyzer output = InternedTest.run();
         output.shouldHaveExitValue(0);
     }
-
-    public static void testMemoryUsage() throws Exception {
-        // Test that memory usage is reduced after deduplication
-        OutputAnalyzer output;
-        final String heapMemoryUsagePattern = "Heap Memory Usage: (\\d+)";
-        final String arrayHeaderSizePattern = "Array Header Size: (\\d+)";
-
-        // Run without deduplication
-        output = MemoryUsageTest.run(false);
-        output.shouldHaveExitValue(0);
-        final long heapMemoryUsageWithoutDedup = Long.parseLong(output.firstMatch(heapMemoryUsagePattern, 1));
-        final long arrayHeaderSizeWithoutDedup = Long.parseLong(output.firstMatch(arrayHeaderSizePattern, 1));
-
-        // Run with deduplication
-        output = MemoryUsageTest.run(true);
-        output.shouldHaveExitValue(0);
-        final long heapMemoryUsageWithDedup = Long.parseLong(output.firstMatch(heapMemoryUsagePattern, 1));
-        final long arrayHeaderSizeWithDedup = Long.parseLong(output.firstMatch(arrayHeaderSizePattern, 1));
-
-        // Sanity check to make sure one instance isn't using compressed class pointers and the other not
-        if (arrayHeaderSizeWithoutDedup != arrayHeaderSizeWithDedup) {
-            throw new Exception("Unexpected difference between array header sizes");
-        }
-
-        // Calculate expected memory usage with deduplication enabled. This calculation does
-        // not take alignment and padding into account, so it's a conservative estimate.
-        final long sizeOfChar = unsafe.ARRAY_CHAR_INDEX_SCALE;
-        final long sizeOfCharArray = StringLength * sizeOfChar + arrayHeaderSizeWithoutDedup;
-        final long bytesSaved = (LargeNumberOfStrings - 1) * sizeOfCharArray;
-        final long heapMemoryUsageWithDedupExpected = heapMemoryUsageWithoutDedup - bytesSaved;
-
-        System.out.println("Memory usage summary:");
-        System.out.println("   heapMemoryUsageWithoutDedup:      " + heapMemoryUsageWithoutDedup);
-        System.out.println("   heapMemoryUsageWithDedup:         " + heapMemoryUsageWithDedup);
-        System.out.println("   heapMemoryUsageWithDedupExpected: " + heapMemoryUsageWithDedupExpected);
-
-        if (heapMemoryUsageWithDedup > heapMemoryUsageWithDedupExpected) {
-            throw new Exception("Unexpected memory usage, heapMemoryUsageWithDedup should be less or equal to heapMemoryUsageWithDedupExpected");
-        }
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/metaspace/TestMetaspaceInitialization.java	Wed Jun 18 13:12:58 2014 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.ArrayList;
+
+/* @test TestMetaspaceInitialization
+ * @bug 8042933
+ * @summary Tests to initialize metaspace with a very low MetaspaceSize
+ * @library /testlibrary
+ * @run main/othervm -XX:MetaspaceSize=2m TestMetaspaceInitialization
+ */
+public class TestMetaspaceInitialization {
+    private class Internal {
+        public int x;
+        public Internal(int x) {
+            this.x = x;
+        }
+    }
+
+    private void test() {
+        ArrayList<Internal> l = new ArrayList<>();
+        l.add(new Internal(17));
+    }
+
+    public static void main(String[] args) {
+        new TestMetaspaceInitialization().test();
+    }
+}
--- a/hotspot/test/gc/parallelScavenge/TestDynShrinkHeap.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/gc/parallelScavenge/TestDynShrinkHeap.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,6 +22,7 @@
  */
 
 /**
+ * @ignore 8042051
  * @test TestDynShrinkHeap
  * @bug 8016479
  * @summary Verify that the heap shrinks after full GC according to the current values of the Min/MaxHeapFreeRatio flags
--- a/hotspot/test/runtime/CommandLine/TestHexArguments.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/runtime/CommandLine/TestHexArguments.java	Wed Jun 18 13:12:58 2014 -0700
@@ -35,14 +35,14 @@
 public class TestHexArguments {
     public static void main(String args[]) throws Exception {
       String[] javaArgs = {"-XX:SharedBaseAddress=0x1D000000", "-version"};
-      ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, javaArgs);
+      ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(javaArgs);
 
       OutputAnalyzer output = new OutputAnalyzer(pb.start());
       output.shouldNotContain("Could not create the Java Virtual Machine");
       output.shouldHaveExitValue(0);
 
       String[] javaArgs1 = {"-XX:SharedBaseAddress=1D000000", "-version"};
-      pb = ProcessTools.createJavaProcessBuilder(true, javaArgs1);
+      pb = ProcessTools.createJavaProcessBuilder(javaArgs1);
       output = new OutputAnalyzer(pb.start());
       output.shouldContain("Could not create the Java Virtual Machine");
   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/RedefineFinalizer/RedefineFinalizer.java	Wed Jun 18 13:12:58 2014 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 6904403
+ * @summary Don't assert if we redefine finalize method
+ * @library /testlibrary
+ * @build RedefineClassHelper
+ * @run main RedefineClassHelper
+ * @run main/othervm -javaagent:redefineagent.jar RedefineFinalizer
+ */
+
+/*
+ * Regression test for hitting:
+ *
+ * assert(f == k->has_finalizer()) failed: inconsistent has_finalizer
+ *
+ * when redefining finalizer method
+ */
+public class RedefineFinalizer {
+
+    public static String newB =
+                "class RedefineFinalizer$B {" +
+                "   protected void finalize() { " +
+                "       System.out.println(\"Finalizer called\");" +
+                "   }" +
+                "}";
+
+    public static void main(String[] args) throws Exception {
+        RedefineClassHelper.redefineClass(B.class, newB);
+
+        A a = new A();
+    }
+
+    static class A extends B {
+    }
+
+    static class B {
+        protected void finalize() {
+            // should be empty
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java	Wed Jun 18 13:12:58 2014 -0700
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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.
+ */
+
+/* @ignore JDK-8043896
+ * @test LimitSharedSizes
+ * @summary Test handling of limits on shared space size
+ * @library /testlibrary
+ * @run main LimitSharedSizes
+ */
+
+import com.oracle.java.testlibrary.*;
+
+public class LimitSharedSizes {
+    private static class SharedSizeTestData {
+        public String optionName;
+        public String optionValue;
+        public String expectedErrorMsg;
+
+        public SharedSizeTestData(String name, String value, String msg) {
+            optionName = name;
+            optionValue = value;
+            expectedErrorMsg = msg;
+        }
+    }
+
+    private static final SharedSizeTestData[] testTable = {
+        // values in this part of the test table should cause failure
+        // (shared space sizes are deliberately too small)
+        new SharedSizeTestData("-XX:SharedReadOnlySize", "4M",      "read only"),
+        new SharedSizeTestData("-XX:SharedReadWriteSize","4M",      "read write"),
+
+        // Known issue, JDK-8038422 (assert() on Windows)
+        // new SharedSizeTestData("-XX:SharedMiscDataSize", "500k",    "miscellaneous data"),
+
+        // This will cause a VM crash; commenting out for now; see bug JDK-8038268
+        // @ignore JDK-8038268
+        // new SharedSizeTestData("-XX:SharedMiscCodeSize", "20k",     "miscellaneous code"),
+
+        // these values are larger than default ones, but should
+        // be acceptable and not cause failure
+        new SharedSizeTestData("-XX:SharedReadOnlySize",    "20M", null),
+        new SharedSizeTestData("-XX:SharedReadWriteSize",   "20M", null),
+        new SharedSizeTestData("-XX:SharedMiscDataSize",    "20M", null),
+        new SharedSizeTestData("-XX:SharedMiscCodeSize",    "20M", null)
+    };
+
+    public static void main(String[] args) throws Exception {
+        String fileName = "test.jsa";
+
+        for (SharedSizeTestData td : testTable) {
+            String option = td.optionName + "=" + td.optionValue;
+            System.out.println("testing option <" + option + ">");
+
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+               "-XX:+UnlockDiagnosticVMOptions",
+               "-XX:SharedArchiveFile=./" + fileName,
+               option,
+               "-Xshare:dump");
+
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+
+            if (td.expectedErrorMsg != null) {
+                output.shouldContain("The shared " + td.expectedErrorMsg
+                    + " space is not large enough");
+
+                output.shouldHaveExitValue(2);
+            } else {
+                output.shouldNotContain("space is not large enough");
+                output.shouldHaveExitValue(0);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/SharedArchiveFile/SharedBaseAddress.java	Wed Jun 18 13:12:58 2014 -0700
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 SharedBaseAddress
+ * @summary Test variety of values for SharedBaseAddress, making sure
+ *          VM handles normal values as well as edge values w/o a crash.
+ * @library /testlibrary
+ * @run main SharedBaseAddress
+ */
+
+import com.oracle.java.testlibrary.*;
+
+public class SharedBaseAddress {
+
+    // shared base address test table
+    private static final String[] testTable = {
+        "1g", "8g", "64g","512g", "4t",
+        "32t", "128t", "0",
+        "1", "64k", "64M"
+    };
+
+    public static void main(String[] args) throws Exception {
+        // Known issue on Solaris-Sparc
+        // @ignore JDK-8044600
+        if (Platform.isSolaris() && Platform.isSparc())
+            return;
+
+        for (String testEntry : testTable) {
+            System.out.println("sharedBaseAddress = " + testEntry);
+
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+               "-XX:+UnlockDiagnosticVMOptions",
+               "-XX:SharedArchiveFile=test.jsa",
+               "-XX:SharedBaseAddress=" + testEntry,
+               "-Xshare:dump");
+
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+
+            output.shouldContain("Loading classes to share");
+
+            try {
+                pb = ProcessTools.createJavaProcessBuilder(
+                    "-XX:+UnlockDiagnosticVMOptions",
+                    "-XX:SharedArchiveFile=test.jsa",
+                    "-Xshare:on",
+                    "-version");
+                output = new OutputAnalyzer(pb.start());
+                output.shouldContain("sharing");
+                output.shouldHaveExitValue(0);
+            } catch (RuntimeException e) {
+                output.shouldContain("Unable to use shared archive");
+                output.shouldHaveExitValue(1);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/SharedArchiveFile/SpaceUtilizationCheck.java	Wed Jun 18 13:12:58 2014 -0700
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 SpaceUtilizationCheck
+ * @summary Check if the space utilization for shared spaces is adequate
+ * @library /testlibrary
+ * @run main SpaceUtilizationCheck
+ */
+
+import com.oracle.java.testlibrary.*;
+
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.util.ArrayList;
+import java.lang.Integer;
+
+public class SpaceUtilizationCheck {
+    // Minimum allowed utilization value (percent)
+    // The goal is to have this number to be 50% for RO and RW regions
+    // Once that feature is implemented, increase the MIN_UTILIZATION to 50
+    private static final int MIN_UTILIZATION = 30;
+
+    // Only RO and RW regions are considered for this check, since they
+    // currently account for the bulk of the shared space
+    private static final int NUMBER_OF_CHECKED_SHARED_REGIONS = 2;
+
+    public static void main(String[] args) throws Exception {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+           "-XX:+UnlockDiagnosticVMOptions",
+           "-XX:SharedArchiveFile=./test.jsa",
+           "-Xshare:dump");
+
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        String stdout = output.getStdout();
+        ArrayList<String> utilization = findUtilization(stdout);
+
+        if (utilization.size() != NUMBER_OF_CHECKED_SHARED_REGIONS )
+            throw new RuntimeException("The output format of sharing summary has changed");
+
+        for(String str : utilization) {
+            int value = Integer.parseInt(str);
+            if (value < MIN_UTILIZATION) {
+                System.out.println(stdout);
+                throw new RuntimeException("Utilization for one of the regions" +
+                    "is below a threshold of " + MIN_UTILIZATION + "%");
+            }
+        }
+    }
+
+    public static ArrayList<String> findUtilization(String input) {
+        ArrayList<String> regions = filterRegionsOfInterest(input.split("\n"));
+        return filterByPattern(filterByPattern(regions, "bytes \\[.*% used\\]"), "\\d+");
+    }
+
+    private static ArrayList<String> filterByPattern(Iterable<String> input, String pattern) {
+        ArrayList<String> result = new ArrayList<String>();
+        for (String str : input) {
+            Matcher matcher = Pattern.compile(pattern).matcher(str);
+            if (matcher.find()) {
+                result.add(matcher.group());
+            }
+        }
+        return result;
+    }
+
+    private static ArrayList<String> filterRegionsOfInterest(String[] inputLines) {
+        ArrayList<String> result = new ArrayList<String>();
+        for (String str : inputLines) {
+            if (str.contains("ro space:") || str.contains("rw space:")) {
+                result.add(str);
+            }
+        }
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Thread/TestThreadDumpMonitorContention.java	Wed Jun 18 13:12:58 2014 -0700
@@ -0,0 +1,405 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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     8036823
+ * @summary Creates two threads contending for the same lock and checks
+ *      whether jstack reports "locked" by more than one thread.
+ *
+ * @library /testlibrary
+ * @run main/othervm TestThreadDumpMonitorContention
+ */
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.oracle.java.testlibrary.*;
+
+public class TestThreadDumpMonitorContention {
+    // jstack tends to be closely bound to the VM that we are running
+    // so use getTestJDKTool() instead of getCompileJDKTool() or even
+    // getJDKTool() which can fall back to "compile.jdk".
+    final static String JSTACK = JDKToolFinder.getTestJDKTool("jstack");
+    final static String PID = getPid();
+
+    // looking for header lines with these patterns:
+    // "ContendingThread-1" #19 prio=5 os_prio=64 tid=0x000000000079c000 nid=0x23 runnable [0xffff80ffb8b87000]
+    // "ContendingThread-2" #21 prio=5 os_prio=64 tid=0x0000000000780000 nid=0x2f waiting for monitor entry [0xfffffd7fc1111000]
+    final static Pattern HEADER_PREFIX_PATTERN = Pattern.compile(
+        "^\"ContendingThread-.*");
+    final static Pattern HEADER_WAITING_PATTERN = Pattern.compile(
+        "^\"ContendingThread-.* waiting for monitor entry .*");
+    final static Pattern HEADER_RUNNABLE_PATTERN = Pattern.compile(
+        "^\"ContendingThread-.* runnable .*");
+
+    // looking for thread state lines with these patterns:
+    // java.lang.Thread.State: RUNNABLE
+    // java.lang.Thread.State: BLOCKED (on object monitor)
+    final static Pattern THREAD_STATE_PREFIX_PATTERN = Pattern.compile(
+        " *java\\.lang\\.Thread\\.State: .*");
+    final static Pattern THREAD_STATE_BLOCKED_PATTERN = Pattern.compile(
+        " *java\\.lang\\.Thread\\.State: BLOCKED \\(on object monitor\\)");
+    final static Pattern THREAD_STATE_RUNNABLE_PATTERN = Pattern.compile(
+        " *java\\.lang\\.Thread\\.State: RUNNABLE");
+
+    // looking for duplicates of this pattern:
+    // - locked <0x000000076ac59e20> (a TestThreadDumpMonitorContention$1)
+    final static Pattern LOCK_PATTERN = Pattern.compile(
+        ".* locked \\<.*\\(a TestThreadDumpMonitorContention.*");
+
+    // sanity checking header and thread state lines associated
+    // with this pattern:
+    // - waiting to lock <0x000000076ac59e20> (a TestThreadDumpMonitorContention$1)
+    final static Pattern WAITING_PATTERN = Pattern.compile(
+        ".* waiting to lock \\<.*\\(a TestThreadDumpMonitorContention.*");
+
+    volatile static boolean done = false;
+
+    static int error_cnt = 0;
+    static String header_line = null;
+    static boolean have_header_line = false;
+    static boolean have_thread_state_line = false;
+    static int match_cnt = 0;
+    static String[] match_list = new String[2];
+    static int n_samples = 15;
+    static String thread_state_line = null;
+    static boolean verbose = false;
+
+    public static void main(String[] args) throws Exception {
+        if (args.length != 0) {
+            int arg_i = 0;
+            if (args[arg_i].equals("-v")) {
+                verbose = true;
+                arg_i++;
+            }
+
+            try {
+                n_samples = Integer.parseInt(args[arg_i]);
+            } catch (NumberFormatException nfe) {
+                System.err.println(nfe);
+                usage();
+            }
+        }
+
+        Runnable runnable = new Runnable() {
+            public void run() {
+                while (!done) {
+                    synchronized (this) { }
+                }
+            }
+        };
+        Thread[] thread_list = new Thread[2];
+        thread_list[0] = new Thread(runnable, "ContendingThread-1");
+        thread_list[1] = new Thread(runnable, "ContendingThread-2");
+        thread_list[0].start();
+        thread_list[1].start();
+
+        doSamples();
+
+        done = true;
+
+        thread_list[0].join();
+        thread_list[1].join();
+
+        if (error_cnt == 0) {
+            System.out.println("Test PASSED.");
+        } else {
+            System.out.println("Test FAILED.");
+            throw new AssertionError("error_cnt=" + error_cnt);
+        }
+    }
+
+    // Reached a blank line which is the end of the
+    // stack trace without matching either LOCK_PATTERN
+    // or WAITING_PATTERN. Rare, but it's not an error.
+    //
+    // Example:
+    // "ContendingThread-1" #21 prio=5 os_prio=64 tid=0x00000000007b9000 nid=0x2f runnable [0xfffffd7fc1111000]
+    //    java.lang.Thread.State: RUNNABLE
+    //         at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:67)
+    //         at java.lang.Thread.run(Thread.java:745)
+    //
+    static boolean checkBlankLine(String line) {
+        if (line.length() == 0) {
+            have_header_line = false;
+            have_thread_state_line = false;
+            return true;
+        }
+
+        return false;
+    }
+
+    // Process the locked line here if we found one.
+    //
+    // Example 1:
+    // "ContendingThread-1" #21 prio=5 os_prio=64 tid=0x00000000007b9000 nid=0x2f runnable [0xfffffd7fc1111000]
+    //    java.lang.Thread.State: RUNNABLE
+    //         at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:67)
+    //         - locked <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1)
+    //         at java.lang.Thread.run(Thread.java:745)
+    //
+    // Example 2:
+    // "ContendingThread-1" #21 prio=5 os_prio=64 tid=0x00000000007b9000 nid=0x2f waiting for monitor entry [0xfffffd7fc1111000]
+    //    java.lang.Thread.State: BLOCKED (on object monitor)
+    //         at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:67)
+    //         - locked <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1)
+    //         at java.lang.Thread.run(Thread.java:745)
+    //
+    static boolean checkLockedLine(String line) {
+        Matcher matcher = LOCK_PATTERN.matcher(line);
+        if (matcher.matches()) {
+            if (verbose) {
+                System.out.println("locked_line='" + line + "'");
+            }
+            match_list[match_cnt] = new String(line);
+            match_cnt++;
+
+            matcher = HEADER_RUNNABLE_PATTERN.matcher(header_line);
+            if (!matcher.matches()) {
+                // It's strange, but a locked line can also
+                // match the HEADER_WAITING_PATTERN.
+                matcher = HEADER_WAITING_PATTERN.matcher(header_line);
+                if (!matcher.matches()) {
+                    System.err.println();
+                    System.err.println("ERROR: header line does " +
+                        "not match runnable or waiting patterns.");
+                    System.err.println("ERROR: header_line='" +
+                        header_line + "'");
+                    System.err.println("ERROR: locked_line='" + line + "'");
+                    error_cnt++;
+                }
+            }
+
+            matcher = THREAD_STATE_RUNNABLE_PATTERN.matcher(thread_state_line);
+            if (!matcher.matches()) {
+                // It's strange, but a locked line can also
+                // match the THREAD_STATE_BLOCKED_PATTERN.
+                matcher = THREAD_STATE_BLOCKED_PATTERN.matcher(
+                              thread_state_line);
+                if (!matcher.matches()) {
+                    System.err.println();
+                    System.err.println("ERROR: thread state line does not " +
+                        "match runnable or waiting patterns.");
+                    System.err.println("ERROR: " + "thread_state_line='" +
+                        thread_state_line + "'");
+                    System.err.println("ERROR: locked_line='" + line + "'");
+                    error_cnt++;
+                }
+            }
+
+            // Have everything we need from this thread stack
+            // that matches the LOCK_PATTERN.
+            have_header_line = false;
+            have_thread_state_line = false;
+            return true;
+        }
+
+        return false;
+    }
+
+    // Process the waiting line here if we found one.
+    //
+    // Example:
+    // "ContendingThread-2" #22 prio=5 os_prio=64 tid=0x00000000007b9800 nid=0x30 waiting for monitor entry [0xfffffd7fc1010000]
+    //    java.lang.Thread.State: BLOCKED (on object monitor)
+    //         at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:67)
+    //         - waiting to lock <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1)
+    //         at java.lang.Thread.run(Thread.java:745)
+    //
+    static boolean checkWaitingLine(String line) {
+        Matcher matcher = WAITING_PATTERN.matcher(line);
+        if (matcher.matches()) {
+            if (verbose) {
+                System.out.println("waiting_line='" + line + "'");
+            }
+
+            matcher = HEADER_WAITING_PATTERN.matcher(header_line);
+            if (!matcher.matches()) {
+                System.err.println();
+                System.err.println("ERROR: header line does " +
+                    "not match a waiting pattern.");
+                System.err.println("ERROR: header_line='" + header_line + "'");
+                System.err.println("ERROR: waiting_line='" + line + "'");
+                error_cnt++;
+            }
+
+            matcher = THREAD_STATE_BLOCKED_PATTERN.matcher(thread_state_line);
+            if (!matcher.matches()) {
+                System.err.println();
+                System.err.println("ERROR: thread state line " +
+                    "does not match a waiting pattern.");
+                System.err.println("ERROR: thread_state_line='" +
+                    thread_state_line + "'");
+                System.err.println("ERROR: waiting_line='" + line + "'");
+                error_cnt++;
+            }
+
+            // Have everything we need from this thread stack
+            // that matches the WAITING_PATTERN.
+            have_header_line = false;
+            have_thread_state_line = false;
+            return true;
+        }
+
+        return false;
+    }
+
+    static void doSamples() throws Exception {
+        for (int count = 0; count < n_samples; count++) {
+            match_cnt = 0;
+            // verbose mode or an error has a lot of output so add more space
+            if (verbose || error_cnt > 0) System.out.println();
+            System.out.println("Sample #" + count);
+
+            // We don't use the ProcessTools, OutputBuffer or
+            // OutputAnalyzer classes from the testlibrary because
+            // we have a complicated multi-line parse to perform
+            // on a narrow subset of the JSTACK output.
+            //
+            // - we only care about stack traces that match
+            //   HEADER_PREFIX_PATTERN; only two should match
+            // - we care about at most three lines from each stack trace
+            // - if both stack traces match LOCKED_PATTERN, then that's
+            //   a failure and we report it
+            // - for a stack trace that matches LOCKED_PATTERN, we verify:
+            //   - the header line matches HEADER_RUNNABLE_PATTERN
+            //     or HEADER_WAITING_PATTERN
+            //   - the thread state line matches THREAD_STATE_BLOCKED_PATTERN
+            //     or THREAD_STATE_RUNNABLE_PATTERN
+            //   - we report any mismatches as failures
+            // - for a stack trace that matches WAITING_PATTERN, we verify:
+            //   - the header line matches HEADER_WAITING_PATTERN
+            //   - the thread state line matches THREAD_STATE_BLOCKED_PATTERN
+            //   - we report any mismatches as failures
+            // - the stack traces that match HEADER_PREFIX_PATTERN may
+            //   not match either LOCKED_PATTERN or WAITING_PATTERN
+            //   because we might observe the thread outside of
+            //   monitor operations; this is not considered a failure
+            //
+            // When we do observe LOCKED_PATTERN or WAITING_PATTERN,
+            // then we are checking the header and thread state patterns
+            // that occurred earlier in the current stack trace that
+            // matched HEADER_PREFIX_PATTERN. We don't use data from
+            // stack traces that don't match HEADER_PREFIX_PATTERN and
+            // we don't mix data between the two stack traces that do
+            // match HEADER_PREFIX_PATTERN.
+            //
+            Process process = new ProcessBuilder(JSTACK, PID)
+                .redirectErrorStream(true).start();
+
+            BufferedReader reader = new BufferedReader(new InputStreamReader(
+                                        process.getInputStream()));
+            String line;
+            while ((line = reader.readLine()) != null) {
+                Matcher matcher = null;
+
+                // process the header line here
+                if (!have_header_line) {
+                    matcher = HEADER_PREFIX_PATTERN.matcher(line);
+                    if (matcher.matches()) {
+                        if (verbose) {
+                            System.out.println();
+                            System.out.println("header='" + line + "'");
+                        }
+                        header_line = new String(line);
+                        have_header_line = true;
+                        continue;
+                    }
+                    continue;  // skip until have a header line
+                }
+
+                // process the thread state line here
+                if (!have_thread_state_line) {
+                    matcher = THREAD_STATE_PREFIX_PATTERN.matcher(line);
+                    if (matcher.matches()) {
+                        if (verbose) {
+                            System.out.println("thread_state='" + line + "'");
+                        }
+                        thread_state_line = new String(line);
+                        have_thread_state_line = true;
+                        continue;
+                    }
+                    continue;  // skip until we have a thread state line
+                }
+
+                // process the locked line here if we find one
+                if (checkLockedLine(line)) {
+                    continue;
+                }
+
+                // process the waiting line here if we find one
+                if (checkWaitingLine(line)) {
+                    continue;
+                }
+
+                // process the blank line here if we find one
+                if (checkBlankLine(line)) {
+                    continue;
+                }
+            }
+            process.waitFor();
+
+           if (match_cnt == 2) {
+               if (match_list[0].equals(match_list[1])) {
+                   System.err.println();
+                   System.err.println("ERROR: matching lock lines:");
+                   System.err.println("ERROR: line[0]'" + match_list[0] + "'");
+                   System.err.println("ERROR: line[1]'" + match_list[1] + "'");
+                   error_cnt++;
+               }
+           }
+
+            // slight delay between jstack launches
+            Thread.sleep(500);
+        }
+    }
+
+    // This helper relies on RuntimeMXBean.getName() returning a string
+    // that looks like this: 5436@mt-haku
+    //
+    // The testlibrary has tryFindJvmPid(), but that uses a separate
+    // process which is much more expensive for finding out your own PID.
+    //
+    static String getPid() {
+        RuntimeMXBean runtimebean = ManagementFactory.getRuntimeMXBean();
+        String vmname = runtimebean.getName();
+        int i = vmname.indexOf('@');
+        if (i != -1) {
+            vmname = vmname.substring(0, i);
+        }
+        return vmname;
+    }
+
+    static void usage() {
+        System.err.println("Usage: " +
+            "java TestThreadDumpMonitorContention [-v] [n_samples]");
+        System.exit(1);
+    }
+}
--- a/hotspot/test/serviceability/ParserTest.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/serviceability/ParserTest.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,10 +22,10 @@
  */
 
 /*
- * @test ParserTest
+ * @test
  * @summary Test that the diagnostic command arguemnt parser works
  * @library /testlibrary /testlibrary/whitebox
- * @build ParserTest
+ * @build ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.parser.*
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ParserTest
  */
--- a/hotspot/test/serviceability/attach/AttachWithStalePidFile.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/serviceability/attach/AttachWithStalePidFile.java	Wed Jun 18 13:12:58 2014 -0700
@@ -27,7 +27,7 @@
  * @key regression
  * @summary Regression test for attach issue where stale pid files in /tmp lead to connection issues
  * @library /testlibrary
- * @compile AttachWithStalePidFileTarget.java
+ * @build com.oracle.java.testlibrary.* AttachWithStalePidFileTarget
  * @run main AttachWithStalePidFile
  */
 
--- a/hotspot/test/serviceability/dcmd/DynLibDcmdTest.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/serviceability/dcmd/DynLibDcmdTest.java	Wed Jun 18 13:12:58 2014 -0700
@@ -29,7 +29,7 @@
  * @test
  * @summary Test of VM.dynlib diagnostic command via MBean
  * @library /testlibrary
- * @compile DcmdUtil.java
+ * @build com.oracle.java.testlibrary.* DcmdUtil
  * @run main DynLibDcmdTest
  */
 
--- a/hotspot/test/serviceability/jvmti/GetObjectSizeOverflow.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/serviceability/jvmti/GetObjectSizeOverflow.java	Wed Jun 18 13:12:58 2014 -0700
@@ -29,7 +29,7 @@
  * @test
  * @bug 8027230
  * @library /testlibrary
- * @build GetObjectSizeOverflowAgent
+ * @build ClassFileInstaller com.oracle.java.testlibrary.* GetObjectSizeOverflowAgent
  * @run main ClassFileInstaller GetObjectSizeOverflowAgent
  * @run main GetObjectSizeOverflow
  */
--- a/hotspot/test/serviceability/jvmti/TestRedefineWithUnresolvedClass.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/serviceability/jvmti/TestRedefineWithUnresolvedClass.java	Wed Jun 18 13:12:58 2014 -0700
@@ -26,7 +26,7 @@
  * @summary Redefine a class with an UnresolvedClass reference in the constant pool.
  * @bug 8035150
  * @library /testlibrary
- * @build UnresolvedClassAgent com.oracle.java.testlibrary.ProcessTools com.oracle.java.testlibrary.OutputAnalyzer
+ * @build com.oracle.java.testlibrary.* UnresolvedClassAgent
  * @run main TestRedefineWithUnresolvedClass
  */
 
--- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java	Wed Jun 18 13:12:58 2014 -0700
@@ -26,6 +26,7 @@
  * @bug 8028623
  * @summary Test hashing of extended characters in Serviceability Agent.
  * @library /testlibrary
+ * @build com.oracle.java.testlibrary.*
  * @compile -encoding utf8 Test8028623.java
  * @run main Test8028623
  */
--- a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java	Wed Jun 18 13:12:58 2014 -0700
@@ -44,7 +44,7 @@
  * @key regression
  * @summary Regression test for hprof export issue due to large heaps (>2G)
  * @library /testlibrary
- * @compile JMapHProfLargeHeapProc.java
+ * @build com.oracle.java.testlibrary.* JMapHProfLargeHeapProc
  * @run main JMapHProfLargeHeapTest
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/testlibrary/RedefineClassHelper.java	Wed Jun 18 13:12:58 2014 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.PrintWriter;
+import java.lang.instrument.*;
+import com.oracle.java.testlibrary.*;
+
+/*
+ * Helper class to write tests that redefine classes.
+ * When main method is run, it will create a redefineagent.jar that can be used
+ * with the -javaagent option to support redefining classes in jtreg tests.
+ *
+ * See sample test in test/testlibrary_tests/RedefineClassTest.java
+ */
+public class RedefineClassHelper {
+
+    public static Instrumentation instrumentation;
+    public static void premain(String agentArgs, Instrumentation inst) {
+        instrumentation = inst;
+    }
+
+    /**
+     * Redefine a class
+     *
+     * @param clazz Class to redefine
+     * @param javacode String with the new java code for the class to be redefined
+     */
+    public static void redefineClass(Class clazz, String javacode) throws Exception {
+        byte[] bytecode = InMemoryJavaCompiler.compile(clazz.getName(), javacode);
+        redefineClass(clazz, bytecode);
+    }
+
+    /**
+     * Redefine a class
+     *
+     * @param clazz Class to redefine
+     * @param bytecode byte[] with the new class
+     */
+    public static void redefineClass(Class clazz, byte[] bytecode) throws Exception {
+        instrumentation.redefineClasses(new ClassDefinition(clazz, bytecode));
+    }
+
+    /**
+     * Main method to be invoked before test to create the redefineagent.jar
+     */
+    public static void main(String[] args) throws Exception {
+        ClassFileInstaller.main("RedefineClassHelper");
+
+        PrintWriter pw = new PrintWriter("MANIFEST.MF");
+        pw.println("Premain-Class: RedefineClassHelper");
+        pw.println("Can-Redefine-Classes: true");
+        pw.close();
+
+        sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
+        if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineClassHelper.class" })) {
+            throw new Exception("jar operation failed");
+        }
+    }
+}
--- a/hotspot/test/testlibrary/ctw/test/ClassesDirTest.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/testlibrary/ctw/test/ClassesDirTest.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,10 +22,10 @@
  */
 
 /*
- * @test ClassesDirTest
+ * @test
  * @bug 8012447
  * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
- * @build sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox ClassesDirTest Foo Bar
+ * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  * @run main ClassesDirTest prepare
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Dsun.hotspot.tools.ctw.logfile=ctw.log sun.hotspot.tools.ctw.CompileTheWorld classes
--- a/hotspot/test/testlibrary/ctw/test/ClassesListTest.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/testlibrary/ctw/test/ClassesListTest.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,10 +22,10 @@
  */
 
 /*
- * @test ClassesListTest
+ * @test
  * @bug 8012447
  * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
- * @build sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox ClassesListTest Foo Bar
+ * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  * @run main ClassesListTest prepare
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Dsun.hotspot.tools.ctw.logfile=ctw.log sun.hotspot.tools.ctw.CompileTheWorld classes.lst
--- a/hotspot/test/testlibrary/ctw/test/JarDirTest.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/testlibrary/ctw/test/JarDirTest.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,10 +22,10 @@
  */
 
 /*
- * @test JarDirTest
+ * @test
  * @bug 8012447
  * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
- * @build sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox JarDirTest Foo Bar
+ * @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  * @run main JarDirTest prepare
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Dsun.hotspot.tools.ctw.logfile=ctw.log sun.hotspot.tools.ctw.CompileTheWorld jars/*
--- a/hotspot/test/testlibrary/ctw/test/JarsTest.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/hotspot/test/testlibrary/ctw/test/JarsTest.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,10 +22,10 @@
  */
 
 /*
- * @test JarsTest
+ * @test
  * @bug 8012447
  * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
- * @build sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox JarsTest Foo Bar
+ * @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  * @run main JarsTest prepare
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Dsun.hotspot.tools.ctw.logfile=ctw.log sun.hotspot.tools.ctw.CompileTheWorld foo.jar bar.jar
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/testlibrary_tests/RedefineClassTest.java	Wed Jun 18 13:12:58 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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
+ * @library /testlibrary
+ * @summary Proof of concept test for RedefineClassHelper
+ * @build RedefineClassHelper
+ * @run main RedefineClassHelper
+ * @run main/othervm -javaagent:redefineagent.jar RedefineClassTest
+ */
+
+import static com.oracle.java.testlibrary.Asserts.*;
+import com.oracle.java.testlibrary.*;
+
+/*
+ * Proof of concept test for the test utility class RedefineClassHelper
+ */
+public class RedefineClassTest {
+
+    public static String newClass = "class RedefineClassTest$A { public int Method() { return 2; } }";
+    public static void main(String[] args) throws Exception {
+        A a = new A();
+        assertTrue(a.Method() == 1);
+        RedefineClassHelper.redefineClass(A.class, newClass);
+        assertTrue(a.Method() == 2);
+    }
+
+    static class A {
+        public int Method() {
+            return 1;
+        }
+    }
+}
--- a/jaxp/.hgtags	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/.hgtags	Wed Jun 18 13:12:58 2014 -0700
@@ -259,3 +259,5 @@
 32b3fc4bc7374a34d52b7f4e2391b4b4b0c084e8 jdk9-b14
 6bad71866c7598587860e0981b0b0e51ec8c0476 jdk9-b15
 a1461221b05d4620e4d7d1907e2a0282aaedf31c jdk9-b16
+6f923fcbe5129eceb9617a9a18dbdd743980e785 jdk9-b17
+5afa90c28742d175431be75f9098745510bd2b30 jdk9-b18
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java	Wed Jun 18 13:12:58 2014 -0700
@@ -3,9 +3,11 @@
  * DO NOT REMOVE OR ALTER!
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
@@ -32,7 +34,6 @@
 import java.text.DecimalFormatSymbols;
 import java.util.ArrayList;
 import java.util.Enumeration;
-import java.util.Vector;
 import javax.xml.transform.Templates;
 import javax.xml.parsers.DocumentBuilderFactory;
 import org.w3c.dom.Document;
@@ -51,6 +52,7 @@
 import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
 import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
+import com.sun.org.apache.xml.internal.serializer.ToStream;
 
 /**
  * @author Jacek Ambroziak
@@ -74,7 +76,7 @@
     public String  _doctypeSystem = null;
     public boolean _indent = false;
     public String  _mediaType = null;
-    public Vector _cdata = null;
+    public ArrayList<String> _cdata = null;
     public int _indentamount = -1;
 
     public static final int FIRST_TRANSLET_VERSION = 100;
@@ -642,7 +644,7 @@
      */
     public void addCdataElement(String name) {
         if (_cdata == null) {
-            _cdata = new Vector();
+            _cdata = new ArrayList<>();
         }
 
         int lastColon = name.lastIndexOf(':');
@@ -650,11 +652,11 @@
         if (lastColon > 0) {
             String uri = name.substring(0, lastColon);
             String localName = name.substring(lastColon+1);
-            _cdata.addElement(uri);
-            _cdata.addElement(localName);
+            _cdata.add(uri);
+            _cdata.add(localName);
         } else {
-            _cdata.addElement(null);
-            _cdata.addElement(name);
+            _cdata.add(null);
+            _cdata.add(name);
         }
     }
 
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java	Wed Jun 18 13:12:58 2014 -0700
@@ -3,9 +3,11 @@
  * DO NOT REMOVE OR ALTER!
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
@@ -40,7 +42,7 @@
 import java.util.Enumeration;
 import java.util.Properties;
 import java.util.StringTokenizer;
-import java.util.Vector;
+import java.util.ArrayList;
 import java.lang.reflect.Constructor;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -1084,7 +1086,7 @@
             else if (name.equals(OutputKeys.CDATA_SECTION_ELEMENTS)) {
                 if (value != null) {
                     StringTokenizer e = new StringTokenizer(value);
-                    Vector uriAndLocalNames = null;
+                    ArrayList<String> uriAndLocalNames = null;
                     while (e.hasMoreTokens()) {
                         final String token = e.nextToken();
 
@@ -1104,11 +1106,11 @@
                         }
 
                         if (uriAndLocalNames == null) {
-                            uriAndLocalNames = new Vector();
+                            uriAndLocalNames = new ArrayList<>();
                         }
                         // add the uri/localName as a pair, in that order
-                        uriAndLocalNames.addElement(uri);
-                        uriAndLocalNames.addElement(localName);
+                        uriAndLocalNames.add(uri);
+                        uriAndLocalNames.add(localName);
                     }
                     handler.setCdataSectionElements(uriAndLocalNames);
                 }
--- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/EntityReferenceImpl.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/EntityReferenceImpl.java	Wed Jun 18 13:12:58 2014 -0700
@@ -347,7 +347,7 @@
      * @see DocumentTypeImpl
      * @see EntityImpl
      */
-    // The Xerces parser invokes callbacks for startEnityReference
+    // The Xerces parser invokes callbacks for startEntityReference
     // the parsed value of the entity EACH TIME, so it is actually
     // easier to create the nodes through the callbacks rather than
     // clone the Entity.
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Wed Jun 18 13:12:58 2014 -0700
@@ -585,7 +585,7 @@
         boolean reportEntity = fReportEntity;
         if (name.startsWith("%")) {
             reportEntity = peekReportEntity();
-            // check well-formedness of the enity
+            // check well-formedness of the entity
             int startMarkUpDepth = popPEStack();
             // throw fatalError if this entity was incomplete and
             // was a freestanding decl
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Wed Jun 18 13:12:58 2014 -0700
@@ -2728,7 +2728,7 @@
                     //if the last section was character data
                     if(fLastSectionWasCharacterData){
 
-                        //if we dont encounter any CDATA or ENITY REFERENCE and current state is also not SCANNER_STATE_CHARACTER_DATA
+                        //if we dont encounter any CDATA or ENTITY REFERENCE and current state is also not SCANNER_STATE_CHARACTER_DATA
                         //return the last scanned charactrer data.
                         if((fScannerState != SCANNER_STATE_CDATA) && (fScannerState != SCANNER_STATE_REFERENCE)
                         && (fScannerState != SCANNER_STATE_CHARACTER_DATA)){
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java	Wed Jun 18 13:12:58 2014 -0700
@@ -1218,7 +1218,7 @@
                     // references appear in the document.
                     // REVISIT: this can be combined to a single check in
                     // startEntity if we add one more argument in
-                    // startEnity, inAttrValue
+                    // startEntity, inAttrValue
                     String nonNormalizedValue = attributes.getNonNormalizedValue(i);
                     if (nonNormalizedValue != null) {
                         String entityName = getExternalEntityRefInAttrValue(nonNormalizedValue);
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java	Wed Jun 18 13:12:58 2014 -0700
@@ -559,11 +559,13 @@
          * @param token The token string
          */
         private void addToken(String tokenStr) {
-            if (!fTokenNames.containsValue(tokenStr)) {
-                Integer tokenInt = new Integer(fTokenNames.size());
+            String str = fTokenNames.get(tokenStr);
+            Integer tokenInt = str == null ? null : Integer.parseInt(str);
+            if (tokenInt == null) {
+                tokenInt = new Integer(fTokenNames.size());
                 fTokenNames.put(tokenInt, tokenStr);
-                addToken(tokenInt.intValue());
             }
+            addToken(tokenInt.intValue());
         }
 
         /**
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerHandler.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerHandler.java	Wed Jun 18 13:12:58 2014 -0700
@@ -524,11 +524,13 @@
          * @param token The token string
          */
         private void addToken(String tokenStr) {
-            if (!fTokenNames.containsValue(tokenStr)) {
-                Integer tokenInt = new Integer(fTokenNames.size());
+            String str = fTokenNames.get(tokenStr);
+            Integer tokenInt = str == null ? null : Integer.parseInt(str);
+            if (tokenInt == null) {
+                tokenInt = new Integer(fTokenNames.size());
                 fTokenNames.put(tokenInt, tokenStr);
-                addToken(tokenInt.intValue());
             }
+            addToken(tokenInt.intValue());
         }
 
         /**
@@ -1251,4 +1253,4 @@
         super.setProperty(propertyId, value);
     }
 
-}
+}
\ No newline at end of file
--- a/jaxp/src/com/sun/org/apache/xml/internal/dtm/DTMConfigurationException.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/dtm/DTMConfigurationException.java	Wed Jun 18 13:12:58 2014 -0700
@@ -32,7 +32,7 @@
 
     /**
      * Create a new <code>DTMConfigurationException</code> with no
-     * detail mesage.
+     * detail message.
      */
     public DTMConfigurationException() {
         super("Configuration Error");
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java	Wed Jun 18 13:12:58 2014 -0700
@@ -3,9 +3,11 @@
  * DO NOT REMOVE OR ALTER!
  */
 /*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
@@ -27,7 +29,7 @@
 import java.io.Writer;
 import java.util.Hashtable;
 import java.util.Properties;
-import java.util.Vector;
+import java.util.ArrayList;
 
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.Transformer;
@@ -150,9 +152,9 @@
         couldThrowIOException();
     }
     /**
-     * @see SerializationHandler#setCdataSectionElements(java.util.Vector)
+     * @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
      */
-    public void setCdataSectionElements(Vector URI_and_localNames)
+    public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
     {
         aMethodIsCalled();
     }
@@ -763,4 +765,25 @@
         aMethodIsCalled();
 
     }
+
+
+    public String getOutputProperty(String name) {
+        aMethodIsCalled();
+        return null;
+    }
+
+    public String getOutputPropertyDefault(String name) {
+        aMethodIsCalled();
+        return null;
+    }
+
+    public void setOutputProperty(String name, String val) {
+        aMethodIsCalled();
+
+    }
+
+    public void setOutputPropertyDefault(String name, String val) {
+        aMethodIsCalled();
+
+    }
 }
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java	Wed Jun 18 13:12:58 2014 -0700
@@ -3,9 +3,11 @@
  * DO NOT REMOVE OR ALTER!
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
@@ -23,8 +25,11 @@
 package com.sun.org.apache.xml.internal.serializer;
 
 import java.io.IOException;
-import java.util.Vector;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.ArrayList;
 
+import javax.xml.transform.OutputKeys;
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.Transformer;
 
@@ -108,12 +113,12 @@
     /**
      * The System ID for the doc type.
      */
-    private String m_doctypeSystem;
+    protected String m_doctypeSystem;
 
     /**
      * The public ID for the doc type.
      */
-    private String m_doctypePublic;
+    protected String m_doctypePublic;
 
     /**
      * Flag to tell that we need to add the doctype decl, which we can't do
@@ -122,15 +127,9 @@
     boolean m_needToOutputDocTypeDecl = true;
 
     /**
-     * The character encoding.  Must match the encoding used for the
-     * printWriter.
-     */
-    private String m_encoding = null;
-
-    /**
      * Tells if we should write the XML declaration.
      */
-    private boolean m_shouldNotWriteXMLHeader = false;
+    protected boolean m_shouldNotWriteXMLHeader = false;
 
     /**
      * The standalone value for the doctype.
@@ -159,12 +158,12 @@
     /**
      * Tells the XML version, for writing out to the XML decl.
      */
-    private String m_version = null;
+    protected String m_version = null;
 
     /**
      * The mediatype.  Not used right now.
      */
-    private String m_mediatype;
+    protected String m_mediatype;
 
     /**
      * The transformer that was around when this output handler was created (if
@@ -173,13 +172,6 @@
     private Transformer m_transformer;
 
     /**
-     * Pairs of local names and corresponding URIs of CDATA sections. This list
-     * comes from the cdata-section-elements attribute. Every second one is a
-     * local name, and every other second one is the URI for the local name.
-     */
-    protected Vector m_cdataSectionElements = null;
-
-    /**
      * Namespace support, that keeps track of currently defined
      * prefix/uri mappings. As processed elements come and go, so do
      * the associated mappings for that element.
@@ -538,16 +530,16 @@
      */
     public String getEncoding()
     {
-        return m_encoding;
+        return getOutputProperty(OutputKeys.ENCODING);
     }
 
    /**
      * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
      * @param m_encoding the character encoding
      */
-    public void setEncoding(String m_encoding)
+    public void setEncoding(String encoding)
     {
-        this.m_encoding = m_encoding;
+        setOutputProperty(OutputKeys.ENCODING,encoding);
     }
 
     /**
@@ -557,7 +549,8 @@
      */
     public void setOmitXMLDeclaration(boolean b)
     {
-        this.m_shouldNotWriteXMLHeader = b;
+        String val = b ? "yes":"no";
+        setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,val);
     }
 
 
@@ -588,7 +581,7 @@
       */
     public void setDoctypePublic(String doctypePublic)
     {
-        this.m_doctypePublic = doctypePublic;
+        setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
     }
 
 
@@ -610,7 +603,7 @@
       */
     public void setDoctypeSystem(String doctypeSystem)
     {
-        this.m_doctypeSystem = doctypeSystem;
+        setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
     }
 
     /** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
@@ -621,8 +614,8 @@
      */
     public void setDoctype(String doctypeSystem, String doctypePublic)
     {
-        this.m_doctypeSystem = doctypeSystem;
-        this.m_doctypePublic = doctypePublic;
+        setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
+        setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
     }
 
     /**
@@ -634,12 +627,9 @@
      */
     public void setStandalone(String standalone)
     {
-        if (standalone != null)
-        {
-            m_standaloneWasSpecified = true;
-            setStandaloneInternal(standalone);
-        }
+        setOutputProperty(OutputKeys.STANDALONE, standalone);
     }
+
     /**
      * Sets the XSL standalone attribute, but does not remember if this is a
      * default or explicite setting.
@@ -700,7 +690,7 @@
      */
     public void setVersion(String version)
     {
-        m_version = version;
+        setOutputProperty(OutputKeys.VERSION, version);
     }
 
     /**
@@ -712,7 +702,7 @@
      */
     public void setMediaType(String mediaType)
     {
-        m_mediatype = mediaType;
+        setOutputProperty(OutputKeys.MEDIA_TYPE,mediaType);
     }
 
     /**
@@ -741,7 +731,8 @@
      */
     public void setIndent(boolean doIndent)
     {
-        m_doIndent = doIndent;
+        String val = doIndent ? "yes":"no";
+        setOutputProperty(OutputKeys.INDENT,val);
     }
 
     /**
@@ -787,59 +778,6 @@
     }
 
     /**
-     * Push a boolean state based on if the name of the current element
-     * is found in the list of qnames.  A state is only pushed if
-     * there were some cdata-section-names were specified.
-     * <p>
-     * Hidden parameters are the vector of qualified elements specified in
-     * cdata-section-names attribute, and the m_cdataSectionStates stack
-     * onto which whether the current element is in the list is pushed (true or
-     * false). Other hidden parameters are the current elements namespaceURI,
-     * localName and qName
-     */
-    protected boolean isCdataSection()
-    {
-
-        boolean b = false;
-
-        if (null != m_cdataSectionElements)
-        {
-            if (m_elemContext.m_elementLocalName == null)
-                m_elemContext.m_elementLocalName =
-                    getLocalName(m_elemContext.m_elementName);
-            if (m_elemContext.m_elementURI == null)
-            {
-                String prefix = getPrefixPart(m_elemContext.m_elementName);
-                if (prefix != null)
-                    m_elemContext.m_elementURI =
-                        m_prefixMap.lookupNamespace(prefix);
-
-            }
-
-            if ((null != m_elemContext.m_elementURI)
-                && m_elemContext.m_elementURI.length() == 0)
-                m_elemContext.m_elementURI = null;
-
-            int nElems = m_cdataSectionElements.size();
-
-            // loop through 2 at a time, as these are pairs of URI and localName
-            for (int i = 0; i < nElems; i += 2)
-            {
-                String uri = (String) m_cdataSectionElements.elementAt(i);
-                String loc = (String) m_cdataSectionElements.elementAt(i + 1);
-                if (loc.equals(m_elemContext.m_elementLocalName)
-                    && subPartMatch(m_elemContext.m_elementURI, uri))
-                {
-                    b = true;
-
-                    break;
-                }
-            }
-        }
-        return b;
-    }
-
-    /**
      * Tell if two strings are equal, without worry if the first string is null.
      *
      * @param p String reference, which may be null.
@@ -1312,12 +1250,11 @@
     private void resetSerializerBase()
     {
         this.m_attributes.clear();
-        this.m_cdataSectionElements = null;
+        this.m_StringOfCDATASections = null;
         this.m_elemContext = new ElemContext();
         this.m_doctypePublic = null;
         this.m_doctypeSystem = null;
         this.m_doIndent = false;
-        this.m_encoding = null;
         this.m_indentAmount = 0;
         this.m_inEntityRef = false;
         this.m_inExternalDTD = false;
@@ -1399,4 +1336,333 @@
         // A particular sub-class of SerializerBase provides the implementation (if desired)
     }
 
+
+    /**
+     * The CDATA section names stored in a whitespace separateed list with
+     * each element being a word of the form "{uri}localName" This list
+     * comes from the cdata-section-elements attribute.
+     *
+     * This field replaces m_cdataSectionElements Vector.
+     */
+    protected String m_StringOfCDATASections = null;
+
+    boolean m_docIsEmpty = true;
+    void initCdataElems(String s)
+    {
+        if (s != null)
+        {
+            int max = s.length();
+
+            // true if we are in the middle of a pair of curly braces that delimit a URI
+            boolean inCurly = false;
+
+            // true if we found a URI but haven't yet processed the local name
+            boolean foundURI = false;
+
+            StringBuilder buf = new StringBuilder();
+            String uri = null;
+            String localName = null;
+
+            // parse through string, breaking on whitespaces.  I do this instead
+            // of a tokenizer so I can track whitespace inside of curly brackets,
+            // which theoretically shouldn't happen if they contain legal URLs.
+            for (int i = 0; i < max; i++)
+            {
+                char c = s.charAt(i);
+
+                if (Character.isWhitespace(c))
+                {
+                    if (!inCurly)
+                    {
+                        if (buf.length() > 0)
+                        {
+                            localName = buf.toString();
+                            if (!foundURI)
+                                uri = "";
+                            addCDATAElement(uri,localName);
+                            buf.setLength(0);
+                            foundURI = false;
+                        }
+                        continue;
+                    }
+                    else
+                        buf.append(c); // add whitespace to the URI
+                }
+                else if ('{' == c) // starting a URI
+                    inCurly = true;
+                else if ('}' == c)
+                {
+                    // we just ended a URI
+                    foundURI = true;
+                    uri = buf.toString();
+                    buf.setLength(0);
+                    inCurly = false;
+                }
+                else
+                {
+                    // append non-whitespace, non-curly to current URI or localName being gathered.
+                    buf.append(c);
+                }
+
+            }
+
+            if (buf.length() > 0)
+            {
+                // We have one last localName to process.
+                localName = buf.toString();
+                if (!foundURI)
+                    uri = "";
+                addCDATAElement(uri,localName);
+            }
+        }
+    }
+
+    protected java.util.HashMap<String, HashMap<String, String>> m_CdataElems = null;
+    private void addCDATAElement(String uri, String localName)
+    {
+        if (m_CdataElems == null) {
+            m_CdataElems = new java.util.HashMap<>();
+        }
+
+        HashMap<String,String> h = m_CdataElems.get(localName);
+        if (h == null) {
+            h = new HashMap<>();
+            m_CdataElems.put(localName,h);
+        }
+        h.put(uri,uri);
+
+    }
+
+
+    /**
+     * Return true if nothing has been sent to this result tree yet.
+     * <p>
+     * This is not a public API.
+     *
+     * @xsl.usage internal
+     */
+    public boolean documentIsEmpty() {
+        // If we haven't called startDocument() yet, then this document is empty
+        return m_docIsEmpty && (m_elemContext.m_currentElemDepth == 0);
+    }
+
+    /**
+     * Return true if the current element in m_elemContext
+     * is a CDATA section.
+     * CDATA sections are specified in the <xsl:output> attribute
+     * cdata-section-names or in the JAXP equivalent property.
+     * In any case the format of the value of such a property is:
+     * <pre>
+     * "{uri1}localName1 {uri2}localName2 . . . "
+     * </pre>
+     *
+     * <p>
+     * This method is not a public API, but is only used internally by the serializer.
+     */
+    protected boolean isCdataSection() {
+        boolean b = false;
+
+        if (null != m_StringOfCDATASections) {
+            if (m_elemContext.m_elementLocalName == null) {
+                String localName =  getLocalName(m_elemContext.m_elementName);
+                m_elemContext.m_elementLocalName = localName;
+            }
+
+            if ( m_elemContext.m_elementURI == null) {
+
+                m_elemContext.m_elementURI = getElementURI();
+            }
+            else if ( m_elemContext.m_elementURI.length() == 0) {
+                if ( m_elemContext.m_elementName == null) {
+                    m_elemContext.m_elementName = m_elemContext.m_elementLocalName;
+                    // leave URI as "", meaning in no namespace
+                }
+                else if (m_elemContext.m_elementLocalName.length() < m_elemContext.m_elementName.length()){
+                    // We were told the URI was "", yet the name has a prefix since the name is longer than the localname.
+                    // So we will fix that incorrect information here.
+                    m_elemContext.m_elementURI = getElementURI();
+                }
+            }
+
+            HashMap<String, String> h = null;
+            if (m_CdataElems != null) {
+                h = m_CdataElems.get(m_elemContext.m_elementLocalName);
+            }
+            if (h != null) {
+                Object obj = h.get(m_elemContext.m_elementURI);
+                if (obj != null)
+                    b = true;
+            }
+
+        }
+        return b;
+    }
+
+    /**
+     * Before this call m_elementContext.m_elementURI is null,
+     * which means it is not yet known. After this call it
+     * is non-null, but possibly "" meaning that it is in the
+     * default namespace.
+     *
+     * @return The URI of the element, never null, but possibly "".
+     */
+    private String getElementURI() {
+        String uri = null;
+        // At this point in processing we have received all the
+        // namespace mappings
+        // As we still don't know the elements namespace,
+        // we now figure it out.
+
+        String prefix = getPrefixPart(m_elemContext.m_elementName);
+
+        if (prefix == null) {
+            // no prefix so lookup the URI of the default namespace
+            uri = m_prefixMap.lookupNamespace("");
+        } else {
+            uri = m_prefixMap.lookupNamespace(prefix);
+        }
+        if (uri == null) {
+            // We didn't find the namespace for the
+            // prefix ... ouch, that shouldn't happen.
+            // This is a hack, we really don't know
+            // the namespace
+            uri = EMPTYSTRING;
+        }
+
+        return uri;
+    }
+
+
+    /**
+     * Get the value of an output property,
+     * the explicit value, if any, otherwise the
+     * default value, if any, otherwise null.
+     */
+    public String getOutputProperty(String name) {
+        String val = getOutputPropertyNonDefault(name);
+        // If no explicit value, try to get the default value
+        if (val == null)
+            val = getOutputPropertyDefault(name);
+        return val;
+
+    }
+    /**
+     * Get the value of an output property,
+     * not the default value. If there is a default
+     * value, but no non-default value this method
+     * will return null.
+     * <p>
+     *
+     */
+    public String getOutputPropertyNonDefault(String name) {
+        return getProp(name,false);
+    }
+
+    /**
+     * Get the default value of an xsl:output property,
+     * which would be null only if no default value exists
+     * for the property.
+     */
+    public String getOutputPropertyDefault(String name) {
+        return getProp(name, true);
+    }
+
+    /**
+     * Set the value for the output property, typically from
+     * an xsl:output element, but this does not change what
+     * the default value is.
+     */
+    public void setOutputProperty(String name, String val) {
+        setProp(name,val,false);
+    }
+
+    /**
+     * Set the default value for an output property, but this does
+     * not impact any explicitly set value.
+     */
+    public void setOutputPropertyDefault(String name, String val) {
+        setProp(name,val,true);
+
+    }
+
+    /**
+     * A mapping of keys to explicitly set values, for example if
+     * and <xsl:output/> has an "encoding" attribute, this
+     * map will have what that attribute maps to.
+     */
+    private HashMap<String, String> m_OutputProps;
+    /**
+     * A mapping of keys to default values, for example if
+     * the default value of the encoding is "UTF-8" then this
+     * map will have that "encoding" maps to "UTF-8".
+     */
+    private HashMap<String, String> m_OutputPropsDefault;
+
+    Set<String> getOutputPropDefaultKeys() {
+        return m_OutputPropsDefault.keySet();
+    }
+    Set<String> getOutputPropKeys() {
+        return m_OutputProps.keySet();
+    }
+
+    private String getProp(String name, boolean defaultVal) {
+        if (m_OutputProps == null) {
+            m_OutputProps = new HashMap<>();
+            m_OutputPropsDefault = new HashMap<>();
+        }
+
+        String val;
+        if (defaultVal)
+            val = m_OutputPropsDefault.get(name);
+        else
+            val = m_OutputProps.get(name);
+
+        return val;
+    }
+    /**
+     *
+     * @param name The name of the property, e.g. "{http://myprop}indent-tabs" or "indent".
+     * @param val The value of the property, e.g. "4"
+     * @param defaultVal true if this is a default value being set for the property as
+     * opposed to a user define on, set say explicitly in the stylesheet or via JAXP
+     */
+    void setProp(String name, String val, boolean defaultVal) {
+        if (m_OutputProps == null) {
+            m_OutputProps = new HashMap<>();
+            m_OutputPropsDefault = new HashMap<>();
+        }
+
+        if (defaultVal)
+            m_OutputPropsDefault.put(name,val);
+        else {
+            if (OutputKeys.CDATA_SECTION_ELEMENTS.equals(name) && val != null) {
+                initCdataElems(val);
+                String oldVal = m_OutputProps.get(name);
+                String newVal;
+                if (oldVal == null)
+                    newVal = oldVal + ' ' + val;
+                else
+                    newVal = val;
+                m_OutputProps.put(name,newVal);
+            }
+            else {
+                m_OutputProps.put(name,val);
+            }
+        }
+    }
+
+    /**
+     * Get the first char of the local name
+     * @param name Either a local name, or a local name
+     * preceeded by a uri enclosed in curly braces.
+     */
+    static char getFirstCharLocName(String name) {
+        final char first;
+        int i = name.indexOf('}');
+        if (i < 0)
+            first = name.charAt(0);
+        else
+            first = name.charAt(i+1);
+        return first;
+    }
 }
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java	Wed Jun 18 13:12:58 2014 -0700
@@ -3,9 +3,11 @@
  * DO NOT REMOVE OR ALTER!
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
@@ -349,84 +351,84 @@
 
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("A");
+        elemDesc = (ElemDesc) m_elementFlags.get("a");
         elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
         elemDesc.setAttr("NAME", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("AREA");
+        elemDesc = (ElemDesc) m_elementFlags.get("area");
         elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
         elemDesc.setAttr("NOHREF", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("BASE");
+        elemDesc = (ElemDesc) m_elementFlags.get("base");
         elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("BUTTON");
+        elemDesc = (ElemDesc) m_elementFlags.get("button");
         elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("BLOCKQUOTE");
+        elemDesc = (ElemDesc) m_elementFlags.get("blockquote");
         elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("DEL");
+        elemDesc = (ElemDesc) m_elementFlags.get("del");
         elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("DIR");
+        elemDesc = (ElemDesc) m_elementFlags.get("dir");
         elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
 
-        elemDesc = (ElemDesc) m_elementFlags.get("DIV");
+        elemDesc = (ElemDesc) m_elementFlags.get("div");
         elemDesc.setAttr("SRC", ElemDesc.ATTRURL); // Netscape 4 extension
         elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("DL");
+        elemDesc = (ElemDesc) m_elementFlags.get("dl");
         elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("FORM");
+        elemDesc = (ElemDesc) m_elementFlags.get("form");
         elemDesc.setAttr("ACTION", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
         // Attribution to: "Voytenko, Dimitry" <DVoytenko@SECTORBASE.COM>
-        elemDesc = (ElemDesc) m_elementFlags.get("FRAME");
+        elemDesc = (ElemDesc) m_elementFlags.get("frame");
         elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
         elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
         elemDesc.setAttr("NORESIZE",ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("HEAD");
+        elemDesc = (ElemDesc) m_elementFlags.get("head");
         elemDesc.setAttr("PROFILE", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("HR");
+        elemDesc = (ElemDesc) m_elementFlags.get("hr");
         elemDesc.setAttr("NOSHADE", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
         // HTML 4.0, section 16.5
-        elemDesc = (ElemDesc) m_elementFlags.get("IFRAME");
+        elemDesc = (ElemDesc) m_elementFlags.get("iframe");
         elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
         elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
         // Netscape 4 extension
-        elemDesc = (ElemDesc) m_elementFlags.get("ILAYER");
+        elemDesc = (ElemDesc) m_elementFlags.get("ilayer");
         elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("IMG");
+        elemDesc = (ElemDesc) m_elementFlags.get("img");
         elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
         elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
         elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
         elemDesc.setAttr("ISMAP", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("INPUT");
+        elemDesc = (ElemDesc) m_elementFlags.get("input");
         elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
         elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
         elemDesc.setAttr("CHECKED", ElemDesc.ATTREMPTY);
@@ -435,24 +437,24 @@
         elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("INS");
+        elemDesc = (ElemDesc) m_elementFlags.get("ins");
         elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
         // Netscape 4 extension
-        elemDesc = (ElemDesc) m_elementFlags.get("LAYER");
+        elemDesc = (ElemDesc) m_elementFlags.get("layer");
         elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("LINK");
+        elemDesc = (ElemDesc) m_elementFlags.get("link");
         elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("MENU");
+        elemDesc = (ElemDesc) m_elementFlags.get("menu");
         elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("OBJECT");
+        elemDesc = (ElemDesc) m_elementFlags.get("object");
         elemDesc.setAttr("CLASSID", ElemDesc.ATTRURL);
         elemDesc.setAttr("CODEBASE", ElemDesc.ATTRURL);
         elemDesc.setAttr("DATA", ElemDesc.ATTRURL);
@@ -461,58 +463,58 @@
         elemDesc.setAttr("DECLARE", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("OL");
+        elemDesc = (ElemDesc) m_elementFlags.get("ol");
         elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("OPTGROUP");
+        elemDesc = (ElemDesc) m_elementFlags.get("optgroup");
         elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("OPTION");
+        elemDesc = (ElemDesc) m_elementFlags.get("option");
         elemDesc.setAttr("SELECTED", ElemDesc.ATTREMPTY);
         elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("Q");
+        elemDesc = (ElemDesc) m_elementFlags.get("q");
         elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("SCRIPT");
+        elemDesc = (ElemDesc) m_elementFlags.get("script");
         elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
         elemDesc.setAttr("FOR", ElemDesc.ATTRURL);
         elemDesc.setAttr("DEFER", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("SELECT");
+        elemDesc = (ElemDesc) m_elementFlags.get("select");
         elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
         elemDesc.setAttr("MULTIPLE", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("TABLE");
+        elemDesc = (ElemDesc) m_elementFlags.get("table");
         elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("TD");
+        elemDesc = (ElemDesc) m_elementFlags.get("td");
         elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("TEXTAREA");
+        elemDesc = (ElemDesc) m_elementFlags.get("textarea");
         elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
         elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("TH");
+        elemDesc = (ElemDesc) m_elementFlags.get("th");
         elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
         // The nowrap attribute of a tr element is both
         // a Netscape and Internet-Explorer extension
-        elemDesc = (ElemDesc) m_elementFlags.get("TR");
+        elemDesc = (ElemDesc) m_elementFlags.get("tr");
         elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
 
         // ----------------------------------------------
-        elemDesc = (ElemDesc) m_elementFlags.get("UL");
+        elemDesc = (ElemDesc) m_elementFlags.get("ul");
         elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
     }
 
@@ -1762,7 +1764,7 @@
              * lets determine if the current element is specified in the cdata-
              * section-elements list.
              */
-            if (m_cdataSectionElements != null)
+            if (m_StringOfCDATASections != null)
                 m_elemContext.m_isCdataSection = isCdataSection();
             if (m_doIndent)
             {
@@ -1776,55 +1778,8 @@
                 throw new SAXException(e);
             }
     }
-    /**
-     * Initialize the serializer with the specified output stream and output
-     * format. Must be called before calling any of the serialize methods.
-     *
-     * @param output The output stream to use
-     * @param format The output format
-     * @throws UnsupportedEncodingException The encoding specified   in the
-     * output format is not supported
-     */
-    protected synchronized void init(OutputStream output, Properties format)
-        throws UnsupportedEncodingException
-    {
-        if (null == format)
-        {
-            format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
-         }
-        super.init(output,format, false);
-    }
 
         /**
-         * Specifies an output stream to which the document should be
-         * serialized. This method should not be called while the
-         * serializer is in the process of serializing a document.
-         * <p>
-         * The encoding specified in the output properties is used, or
-         * if no encoding was specified, the default for the selected
-         * output method.
-         *
-         * @param output The output stream
-         */
-        public void setOutputStream(OutputStream output)
-        {
-
-            try
-            {
-                Properties format;
-                if (null == m_format)
-                    format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
-                else
-                    format = m_format;
-                init(output, format, true);
-            }
-            catch (UnsupportedEncodingException uee)
-            {
-
-                // Should have been warned in init, I guess...
-            }
-        }
-        /**
          * This method is used when a prefix/uri namespace mapping
          * is indicated after the element was started with a
          * startElement() and before and endElement().
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToSAXHandler.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToSAXHandler.java	Wed Jun 18 13:12:58 2014 -0700
@@ -22,7 +22,7 @@
  */
 package com.sun.org.apache.xml.internal.serializer;
 
-import java.util.Vector;
+import java.util.ArrayList;
 
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -234,9 +234,9 @@
     /**
      * Does nothing. The setting of CDATA section elements has an impact on
      * stream serializers.
-     * @see SerializationHandler#setCdataSectionElements(java.util.Vector)
+     * @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
      */
-    public void setCdataSectionElements(Vector URI_and_localNames)
+    public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
     {
         // do nothing
     }
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToStream.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToStream.java	Wed Jun 18 13:12:58 2014 -0700
@@ -3,9 +3,11 @@
  * DO NOT REMOVE OR ALTER!
  */
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
@@ -25,11 +27,15 @@
 import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.util.Enumeration;
+import java.util.Iterator;
 import java.util.Properties;
+import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.Vector;
+import java.util.ArrayList;
 
 import javax.xml.transform.ErrorListener;
 import javax.xml.transform.OutputKeys;
@@ -186,9 +192,6 @@
        */
     boolean m_isUTF8 = false;
 
-    /** The xsl:output properties. */
-    protected Properties m_format;
-
     /**
      * remembers if we are in between the startCDATA() and endCDATA() callbacks
      */
@@ -306,6 +309,7 @@
         }
     }
 
+    OutputStream m_outputStream;
     /**
      * Get the output stream where the events will be serialized to.
      *
@@ -314,13 +318,7 @@
      */
     public OutputStream getOutputStream()
     {
-
-        if (m_writer instanceof WriterToUTF8Buffered)
-            return ((WriterToUTF8Buffered) m_writer).getOutputStream();
-        if (m_writer instanceof WriterToASCI)
-            return ((WriterToASCI) m_writer).getOutputStream();
-        else
-            return null;
+        return m_outputStream;
     }
 
     // Implement DeclHandler
@@ -419,10 +417,174 @@
      */
     protected final void outputLineSep() throws IOException
     {
-
         m_writer.write(m_lineSep, 0, m_lineSepLen);
     }
 
+    void setProp(String name, String val, boolean defaultVal) {
+        if (val != null) {
+
+            char first = getFirstCharLocName(name);
+            switch (first) {
+            case 'c':
+                if (OutputKeys.CDATA_SECTION_ELEMENTS.equals(name)) {
+                    addCdataSectionElements(val); // val is cdataSectionNames
+                }
+                break;
+            case 'd':
+                if (OutputKeys.DOCTYPE_SYSTEM.equals(name)) {
+                    this.m_doctypeSystem = val;
+                } else if (OutputKeys.DOCTYPE_PUBLIC.equals(name)) {
+                    this.m_doctypePublic = val;
+                    if (val.startsWith("-//W3C//DTD XHTML"))
+                        m_spaceBeforeClose = true;
+                }
+                break;
+            case 'e':
+                String newEncoding = val;
+                if (OutputKeys.ENCODING.equals(name)) {
+                    String possible_encoding = Encodings.getMimeEncoding(val);
+                    if (possible_encoding != null) {
+                        // if the encoding is being set, try to get the
+                        // preferred
+                        // mime-name and set it too.
+                        super.setProp("mime-name", possible_encoding,
+                                defaultVal);
+                    }
+                    final String oldExplicitEncoding = getOutputPropertyNonDefault(OutputKeys.ENCODING);
+                    final String oldDefaultEncoding  = getOutputPropertyDefault(OutputKeys.ENCODING);
+                    if ( (defaultVal && ( oldDefaultEncoding == null || !oldDefaultEncoding.equalsIgnoreCase(newEncoding)))
+                            || ( !defaultVal && (oldExplicitEncoding == null || !oldExplicitEncoding.equalsIgnoreCase(newEncoding) ))) {
+                       // We are trying to change the default or the non-default setting of the encoding to a different value
+                       // from what it was
+
+                       EncodingInfo encodingInfo = Encodings.getEncodingInfo(newEncoding);
+                       if (newEncoding != null && encodingInfo.name == null) {
+                        // We tried to get an EncodingInfo for Object for the given
+                        // encoding, but it came back with an internall null name
+                        // so the encoding is not supported by the JDK, issue a message.
+                        final String msg = Utils.messages.createMessage(
+                                MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ newEncoding });
+
+                        final String msg2 =
+                            "Warning: encoding \"" + newEncoding + "\" not supported, using "
+                                   + Encodings.DEFAULT_MIME_ENCODING;
+                        try {
+                                // Prepare to issue the warning message
+                                final Transformer tran = super.getTransformer();
+                                if (tran != null) {
+                                    final ErrorListener errHandler = tran
+                                            .getErrorListener();
+                                    // Issue the warning message
+                                    if (null != errHandler
+                                            && m_sourceLocator != null) {
+                                        errHandler
+                                                .warning(new TransformerException(
+                                                        msg, m_sourceLocator));
+                                        errHandler
+                                                .warning(new TransformerException(
+                                                        msg2, m_sourceLocator));
+                                    } else {
+                                        System.out.println(msg);
+                                        System.out.println(msg2);
+                                    }
+                                } else {
+                                    System.out.println(msg);
+                                    System.out.println(msg2);
+                                }
+                            } catch (Exception e) {
+                            }
+
+                            // We said we are using UTF-8, so use it
+                            newEncoding = Encodings.DEFAULT_MIME_ENCODING;
+                            val = Encodings.DEFAULT_MIME_ENCODING; // to store the modified value into the properties a little later
+                            encodingInfo = Encodings.getEncodingInfo(newEncoding);
+                        }
+                       // The encoding was good, or was forced to UTF-8 above
+
+
+                       // If there is already a non-default set encoding and we
+                       // are trying to set the default encoding, skip the this block
+                       // as the non-default value is already the one to use.
+                       if (defaultVal == false || oldExplicitEncoding == null) {
+                           m_encodingInfo = encodingInfo;
+                           if (newEncoding != null)
+                               m_isUTF8 = newEncoding.equals(Encodings.DEFAULT_MIME_ENCODING);
+
+                           // if there was a previously set OutputStream
+                           OutputStream os = getOutputStream();
+                           if (os != null) {
+                               Writer w = getWriter();
+
+                               // If the writer was previously set, but
+                               // set by the user, or if the new encoding is the same
+                               // as the old encoding, skip this block
+                               String oldEncoding = getOutputProperty(OutputKeys.ENCODING);
+                               if ((w == null || !m_writer_set_by_user)
+                                       && !newEncoding.equalsIgnoreCase(oldEncoding)) {
+                                   // Make the change of encoding in our internal
+                                   // table, then call setOutputStreamInternal
+                                   // which will stomp on the old Writer (if any)
+                                   // with a new Writer with the new encoding.
+                                   super.setProp(name, val, defaultVal);
+                                   setOutputStreamInternal(os,false);
+                               }
+                           }
+                       }
+                    }
+                }
+                break;
+            case 'i':
+                if (OutputPropertiesFactory.S_KEY_INDENT_AMOUNT.equals(name)) {
+                    setIndentAmount(Integer.parseInt(val));
+                } else if (OutputKeys.INDENT.equals(name)) {
+                    boolean b = "yes".equals(val) ? true : false;
+                    m_doIndent = b;
+                }
+
+                break;
+            case 'l':
+                if (OutputPropertiesFactory.S_KEY_LINE_SEPARATOR.equals(name)) {
+                    m_lineSep = val.toCharArray();
+                    m_lineSepLen = m_lineSep.length;
+                }
+
+                break;
+            case 'm':
+                if (OutputKeys.MEDIA_TYPE.equals(name)) {
+                    m_mediatype = val;
+                }
+                break;
+            case 'o':
+                if (OutputKeys.OMIT_XML_DECLARATION.equals(name)) {
+                    boolean b = "yes".equals(val) ? true : false;
+                    this.m_shouldNotWriteXMLHeader = b;
+                }
+                break;
+            case 's':
+                // if standalone was explicitly specified
+                if (OutputKeys.STANDALONE.equals(name)) {
+                    if (defaultVal) {
+                        setStandaloneInternal(val);
+                    } else {
+                        m_standaloneWasSpecified = true;
+                        setStandaloneInternal(val);
+                    }
+                }
+
+                break;
+            case 'v':
+                if (OutputKeys.VERSION.equals(name)) {
+                    m_version = val;
+                }
+                break;
+            default:
+                break;
+
+            }
+            super.setProp(name, val, defaultVal);
+        }
+    }
+
     /**
      * Specifies an output format for this serializer. It the
      * serializer has already been associated with an output format,
@@ -434,115 +596,34 @@
      */
     public void setOutputFormat(Properties format)
     {
-
         boolean shouldFlush = m_shouldFlush;
 
-        init(m_writer, format, false, false);
-
-        m_shouldFlush = shouldFlush;
-    }
-
-    /**
-     * Initialize the serializer with the specified writer and output format.
-     * Must be called before calling any of the serialize methods.
-     * This method can be called multiple times and the xsl:output properties
-     * passed in the 'format' parameter are accumulated across calls.
-     *
-     * @param writer The writer to use
-     * @param format The output format
-     * @param shouldFlush True if the writer should be flushed at EndDocument.
-     */
-    private synchronized void init(
-        Writer writer,
-        Properties format,
-        boolean defaultProperties,
-        boolean shouldFlush)
-    {
-
-        m_shouldFlush = shouldFlush;
-
-
-        // if we are tracing events we need to trace what
-        // characters are written to the output writer.
-        if (m_tracer != null
-         && !(writer instanceof SerializerTraceWriter)  )
-            m_writer = new SerializerTraceWriter(writer, m_tracer);
-        else
-            m_writer = writer;
-
-
-        m_format = format;
-        //        m_cdataSectionNames =
-        //            OutputProperties.getQNameProperties(
-        //                OutputKeys.CDATA_SECTION_ELEMENTS,
-        //                format);
-        setCdataSectionElements(OutputKeys.CDATA_SECTION_ELEMENTS, format);
-
-        setIndentAmount(
-            OutputPropertyUtils.getIntProperty(
-                OutputPropertiesFactory.S_KEY_INDENT_AMOUNT,
-                format));
-        setIndent(
-            OutputPropertyUtils.getBooleanProperty(OutputKeys.INDENT, format));
-
+        if (format != null)
         {
-            String sep =
-                    format.getProperty(OutputPropertiesFactory.S_KEY_LINE_SEPARATOR);
-            if (sep != null) {
-                m_lineSep = sep.toCharArray();
-                m_lineSepLen = sep.length();
+            // Set the default values first,
+            // and the non-default values after that,
+            // just in case there is some unexpected
+            // residual values left over from over-ridden default values
+            Enumeration propNames;
+            propNames = format.propertyNames();
+            while (propNames.hasMoreElements())
+            {
+                String key = (String) propNames.nextElement();
+                // Get the value, possibly a default value
+                String value = format.getProperty(key);
+                // Get the non-default value (if any).
+                String explicitValue = (String) format.get(key);
+                if (explicitValue == null && value != null) {
+                    // This is a default value
+                    this.setOutputPropertyDefault(key,value);
+                }
+                if (explicitValue != null) {
+                    // This is an explicit non-default value
+                    this.setOutputProperty(key,explicitValue);
+                }
             }
         }
 
-        boolean shouldNotWriteXMLHeader =
-            OutputPropertyUtils.getBooleanProperty(
-                OutputKeys.OMIT_XML_DECLARATION,
-                format);
-        setOmitXMLDeclaration(shouldNotWriteXMLHeader);
-        setDoctypeSystem(format.getProperty(OutputKeys.DOCTYPE_SYSTEM));
-        String doctypePublic = format.getProperty(OutputKeys.DOCTYPE_PUBLIC);
-        setDoctypePublic(doctypePublic);
-
-        // if standalone was explicitly specified
-        if (format.get(OutputKeys.STANDALONE) != null)
-        {
-            String val = format.getProperty(OutputKeys.STANDALONE);
-            if (defaultProperties)
-                setStandaloneInternal(val);
-            else
-                setStandalone(val);
-        }
-
-        setMediaType(format.getProperty(OutputKeys.MEDIA_TYPE));
-
-        if (null != doctypePublic)
-        {
-            if (doctypePublic.startsWith("-//W3C//DTD XHTML"))
-                m_spaceBeforeClose = true;
-        }
-
-        /*
-         * This code is added for XML 1.1 Version output.
-         */
-        String version = getVersion();
-        if (null == version)
-        {
-            version = format.getProperty(OutputKeys.VERSION);
-            setVersion(version);
-        }
-
-        // initCharsMap();
-        String encoding = getEncoding();
-        if (null == encoding)
-        {
-            encoding =
-                Encodings.getMimeEncoding(
-                    format.getProperty(OutputKeys.ENCODING));
-            setEncoding(encoding);
-        }
-
-        m_isUTF8 = encoding.equals(Encodings.DEFAULT_MIME_ENCODING);
-
         // Access this only from the Hashtable level... we don't want to
         // get default properties.
         String entitiesFileName =
@@ -557,107 +638,10 @@
             m_charInfo = CharInfo.getCharInfo(entitiesFileName, method);
         }
 
-    }
-
-    /**
-     * Initialize the serializer with the specified writer and output format.
-     * Must be called before calling any of the serialize methods.
-     *
-     * @param writer The writer to use
-     * @param format The output format
-     */
-    private synchronized void init(Writer writer, Properties format)
-    {
-        init(writer, format, false, false);
-    }
-    /**
-     * Initialize the serializer with the specified output stream and output
-     * format. Must be called before calling any of the serialize methods.
-     *
-     * @param output The output stream to use
-     * @param format The output format
-     * @param defaultProperties true if the properties are the default
-     * properties
-     *
-     * @throws UnsupportedEncodingException The encoding specified   in the
-     * output format is not supported
-     */
-    protected synchronized void init(
-        OutputStream output,
-        Properties format,
-        boolean defaultProperties)
-        throws UnsupportedEncodingException
-    {
-
-        String encoding = getEncoding();
-        if (encoding == null)
-        {
-            // if not already set then get it from the properties
-            encoding =
-                Encodings.getMimeEncoding(
-                    format.getProperty(OutputKeys.ENCODING));
-            setEncoding(encoding);
-        }
-
-        if (encoding.equalsIgnoreCase("UTF-8"))
-        {
-            m_isUTF8 = true;
-            //            if (output instanceof java.io.BufferedOutputStream)
-            //            {
-            //                init(new WriterToUTF8(output), format, defaultProperties, true);
-            //            }
-            //            else if (output instanceof java.io.FileOutputStream)
-            //            {
-            //                init(new WriterToUTF8Buffered(output), format, defaultProperties, true);
-            //            }
-            //            else
-            //            {
-            //                // Not sure what to do in this case.  I'm going to be conservative
-            //                // and not buffer.
-            //                init(new WriterToUTF8(output), format, defaultProperties, true);
-            //            }
-
-
-                init(
-                    new WriterToUTF8Buffered(output),
-                    format,
-                    defaultProperties,
-                    true);
-
-
-        }
-        else if (
-            encoding.equals("WINDOWS-1250")
-                || encoding.equals("US-ASCII")
-                || encoding.equals("ASCII"))
-        {
-            init(new WriterToASCI(output), format, defaultProperties, true);
-        }
-        else
-        {
-            Writer osw;
-
-            try
-            {
-                osw = Encodings.getWriter(output, encoding);
-            }
-            catch (UnsupportedEncodingException uee)
-            {
-                System.out.println(
-                    "Warning: encoding \""
-                        + encoding
-                        + "\" not supported"
-                        + ", using "
-                        + Encodings.DEFAULT_MIME_ENCODING);
-
-                encoding = Encodings.DEFAULT_MIME_ENCODING;
-                setEncoding(encoding);
-                osw = Encodings.getWriter(output, encoding);
-            }
-
-            init(osw, format, defaultProperties, true);
-        }
-
+
+
+
+        m_shouldFlush = shouldFlush;
     }
 
     /**
@@ -665,9 +649,26 @@
      *
      * @return The output format in use
      */
-    public Properties getOutputFormat()
-    {
-        return m_format;
+    public Properties getOutputFormat() {
+        Properties def = new Properties();
+        {
+            Set<String> s = getOutputPropDefaultKeys();
+            for (String key : s) {
+                String val = getOutputPropertyDefault(key);
+                def.put(key, val);
+            }
+        }
+
+        Properties props = new Properties(def);
+        {
+            Set<String> s = getOutputPropKeys();
+            for (String key : s) {
+                String val = getOutputPropertyNonDefault(key);
+                if (val != null)
+                    props.put(key, val);
+            }
+        }
+        return props;
     }
 
     /**
@@ -679,13 +680,28 @@
      */
     public void setWriter(Writer writer)
     {
+        setWriterInternal(writer, true);
+    }
+
+    private boolean m_writer_set_by_user;
+    private void setWriterInternal(Writer writer, boolean setByUser) {
+        m_writer_set_by_user = setByUser;
+        m_writer = writer;
         // if we are tracing events we need to trace what
         // characters are written to the output writer.
-        if (m_tracer != null
-         && !(writer instanceof SerializerTraceWriter)  )
-            m_writer = new SerializerTraceWriter(writer, m_tracer);
-        else
-            m_writer = writer;
+        if (m_tracer != null) {
+            boolean noTracerYet = true;
+            Writer w2 = m_writer;
+            while (w2 instanceof WriterChain) {
+                if (w2 instanceof SerializerTraceWriter) {
+                    noTracerYet = false;
+                    break;
+                }
+                w2 = ((WriterChain)w2).getWriter();
+            }
+            if (noTracerYet)
+                m_writer = new SerializerTraceWriter(m_writer, m_tracer);
+        }
     }
 
     /**
@@ -720,25 +736,68 @@
      */
     public void setOutputStream(OutputStream output)
     {
-
-        try
+        setOutputStreamInternal(output, true);
+    }
+
+    private void setOutputStreamInternal(OutputStream output, boolean setByUser)
+    {
+        m_outputStream = output;
+        String encoding = getOutputProperty(OutputKeys.ENCODING);
+        if (Encodings.DEFAULT_MIME_ENCODING.equalsIgnoreCase(encoding))
         {
-            Properties format;
-            if (null == m_format)
-                format =
-                    OutputPropertiesFactory.getDefaultMethodProperties(
-                        Method.XML);
-            else
-                format = m_format;
-            init(output, format, true);
+            // We wrap the OutputStream with a writer, but
+            // not one set by the user
+            try {
+                setWriterInternal(new WriterToUTF8Buffered(output), false);
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+        } else if (
+                "WINDOWS-1250".equals(encoding)
+                || "US-ASCII".equals(encoding)
+                || "ASCII".equals(encoding))
+        {
+            setWriterInternal(new WriterToASCI(output), false);
+        } else if (encoding != null) {
+            Writer osw = null;
+                try
+                {
+                    osw = Encodings.getWriter(output, encoding);
+                }
+                catch (UnsupportedEncodingException uee)
+                {
+                    osw = null;
+                }
+
+
+            if (osw == null) {
+                System.out.println(
+                    "Warning: encoding \""
+                        + encoding
+                        + "\" not supported"
+                        + ", using "
+                        + Encodings.DEFAULT_MIME_ENCODING);
+
+                encoding = Encodings.DEFAULT_MIME_ENCODING;
+                setEncoding(encoding);
+                try {
+                    osw = Encodings.getWriter(output, encoding);
+                } catch (UnsupportedEncodingException e) {
+                    // We can't really get here, UTF-8 is always supported
+                    // This try-catch exists to make the compiler happy
+                    e.printStackTrace();
+                }
+            }
+            setWriterInternal(osw,false);
         }
-        catch (UnsupportedEncodingException uee)
-        {
-
-            // Should have been warned in init, I guess...
+        else {
+            // don't have any encoding, but we have an OutputStream
+            Writer osw = new OutputStreamWriter(output);
+            setWriterInternal(osw,false);
         }
     }
 
+
     /**
      * @see SerializationHandler#setEscaping(boolean)
      */
@@ -2455,7 +2514,7 @@
              * lets determine if the current element is specified in the cdata-
              * section-elements list.
              */
-            if (m_cdataSectionElements != null)
+            if (m_StringOfCDATASections != null)
                 m_elemContext.m_isCdataSection = isCdataSection();
 
             if (m_doIndent)
@@ -2532,12 +2591,12 @@
      * @param   key   the property key.
      * @param props the list of properties to search in.
      *
-     * Sets the vector of local-name/URI pairs of the cdata section elements
+     * Sets the ArrayList of local-name/URI pairs of the cdata section elements
      * specified in the cdata-section-elements property.
      *
      * This method is essentially a copy of getQNameProperties() from
      * OutputProperties. Eventually this method should go away and a call
-     * to setCdataSectionElements(Vector v) should be made directly.
+     * to setCdataSectionElements(ArrayList<String> v) should be made directly.
      */
     private void setCdataSectionElements(String key, Properties props)
     {
@@ -2546,11 +2605,11 @@
 
         if (null != s)
         {
-            // Vector of URI/LocalName pairs
-            Vector v = new Vector();
+            // ArrayList<String> of URI/LocalName pairs
+            ArrayList<String> v = new ArrayList<>();
             int l = s.length();
             boolean inCurly = false;
-            StringBuffer buf = new StringBuffer();
+            StringBuilder buf = new StringBuilder();
 
             // parse through string, breaking on whitespaces.  I do this instead
             // of a tokenizer so I can track whitespace inside of curly brackets,
@@ -2597,7 +2656,7 @@
      *
      * @return a QName object
      */
-    private void addCdataSectionElement(String URI_and_localName, Vector v)
+    private void addCdataSectionElement(String URI_and_localName, ArrayList<String> v)
     {
 
         StringTokenizer tokenizer =
@@ -2608,14 +2667,14 @@
         if (null == s2)
         {
             // add null URI and the local name
-            v.addElement(null);
-            v.addElement(s1);
+            v.add(null);
+            v.add(s1);
         }
         else
         {
             // add URI, then local name
-            v.addElement(s1);
-            v.addElement(s2);
+            v.add(s1);
+            v.add(s2);
         }
     }
 
@@ -2624,11 +2683,38 @@
      * The "official way to set URI and localName pairs.
      * This method should be used by both Xalan and XSLTC.
      *
-     * @param URI_and_localNames a vector of pairs of Strings (URI/local)
+     * @param URI_and_localNames an ArrayList of pairs of Strings (URI/local)
      */
-    public void setCdataSectionElements(Vector URI_and_localNames)
+    public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
     {
-        m_cdataSectionElements = URI_and_localNames;
+        // convert to the new way.
+        if (URI_and_localNames != null)
+        {
+            final int len = URI_and_localNames.size() - 1;
+            if (len > 0)
+            {
+                final StringBuilder sb = new StringBuilder();
+                for (int i = 0; i < len; i += 2)
+                {
+                    // whitspace separated "{uri1}local1 {uri2}local2 ..."
+                    if (i != 0)
+                        sb.append(' ');
+                    final String uri = (String) URI_and_localNames.get(i);
+                    final String localName =
+                        (String) URI_and_localNames.get(i + 1);
+                    if (uri != null)
+                    {
+                        // If there is no URI don't put this in, just the localName then.
+                        sb.append('{');
+                        sb.append(uri);
+                        sb.append('}');
+                    }
+                    sb.append(localName);
+                }
+                m_StringOfCDATASections = sb.toString();
+            }
+        }
+        initCdataElems(m_StringOfCDATASections);
     }
 
     /**
@@ -3084,37 +3170,7 @@
       */
      public void setEncoding(String encoding)
      {
-         String old = getEncoding();
-         super.setEncoding(encoding);
-         if (old == null || !old.equals(encoding)) {
-            // If we have changed the setting of the
-            m_encodingInfo = Encodings.getEncodingInfo(encoding);
-
-            if (encoding != null && m_encodingInfo.name == null) {
-                // We tried to get an EncodingInfo for Object for the given
-                // encoding, but it came back with an internall null name
-                // so the encoding is not supported by the JDK, issue a message.
-                String msg = Utils.messages.createMessage(
-                                MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
-                try
-                {
-                        // Prepare to issue the warning message
-                        Transformer tran = super.getTransformer();
-                        if (tran != null) {
-                                ErrorListener errHandler = tran.getErrorListener();
-                                // Issue the warning message
-                                if (null != errHandler && m_sourceLocator != null)
-                                        errHandler.warning(new TransformerException(msg, m_sourceLocator));
-                                else
-                                        System.out.println(msg);
-                    }
-                        else
-                                System.out.println(msg);
-                }
-                catch (Exception e){}
-            }
-         }
-         return;
+         setOutputProperty(OutputKeys.ENCODING,encoding);
      }
 
     /**
@@ -3386,4 +3442,24 @@
     public void setDTDEntityExpansion(boolean expand) {
         m_expandDTDEntities = expand;
     }
+
+    /**
+     * Remembers the cdata sections specified in the cdata-section-elements by appending the given
+     * cdata section elements to the list. This method can be called multiple times, but once an
+     * element is put in the list of cdata section elements it can not be removed.
+     * This method should be used by both Xalan and XSLTC.
+     *
+     * @param URI_and_localNames a whitespace separated list of element names, each element
+     * is a URI in curly braces (optional) and a local name. An example of such a parameter is:
+     * "{http://company.com}price {myURI2}book chapter"
+     */
+    public void addCdataSectionElements(String URI_and_localNames)
+    {
+        if (URI_and_localNames != null)
+            initCdataElems(URI_and_localNames);
+        if (m_StringOfCDATASections == null)
+            m_StringOfCDATASections = URI_and_localNames;
+        else
+            m_StringOfCDATASections += (" " + URI_and_localNames);
+    }
 }
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java	Wed Jun 18 13:12:58 2014 -0700
@@ -26,7 +26,7 @@
 import java.io.OutputStream;
 import java.io.Writer;
 import java.util.Properties;
-import java.util.Vector;
+import java.util.ArrayList;
 
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.Transformer;
@@ -100,12 +100,12 @@
      * A collection of namespace URI's (only for first element).
      * _namespacePrefix has the matching prefix for these URI's
      */
-    private Vector m_namespaceURI = null;
+    private ArrayList<String> m_namespaceURI = null;
     /**
      * A collection of namespace Prefix (only for first element)
      * _namespaceURI has the matching URIs for these prefix'
      */
-    private Vector m_namespacePrefix = null;
+    private ArrayList<String> m_namespacePrefix = null;
 
     /**
      * true if startDocument() was called before the underlying handler
@@ -421,11 +421,11 @@
             {
                 if (m_namespacePrefix == null)
                 {
-                    m_namespacePrefix = new Vector();
-                    m_namespaceURI = new Vector();
+                    m_namespacePrefix = new ArrayList<>();
+                    m_namespaceURI = new ArrayList<>();
                 }
-                m_namespacePrefix.addElement(prefix);
-                m_namespaceURI.addElement(uri);
+                m_namespacePrefix.add(prefix);
+                m_namespaceURI.add(uri);
 
                 if (m_firstElementURI == null)
                 {
@@ -1092,8 +1092,8 @@
                 for (int i = 0; i < n; i++)
                 {
                     final String prefix =
-                        (String) m_namespacePrefix.elementAt(i);
-                    final String uri = (String) m_namespaceURI.elementAt(i);
+                        (String) m_namespacePrefix.get(i);
+                    final String uri = (String) m_namespaceURI.get(i);
                     m_handler.startPrefixMapping(prefix, uri, false);
                 }
                 m_namespacePrefix = null;
@@ -1165,8 +1165,8 @@
             final int max = m_namespacePrefix.size();
             for (int i = 0; i < max; i++)
             {
-                final String prefix = (String) m_namespacePrefix.elementAt(i);
-                final String uri = (String) m_namespaceURI.elementAt(i);
+                final String prefix = m_namespacePrefix.get(i);
+                final String uri = m_namespaceURI.get(i);
 
                 if (m_firstElementPrefix != null
                     && m_firstElementPrefix.equals(prefix)
@@ -1194,7 +1194,7 @@
      * specified in the cdata-section-elements attribute.
      * @see SerializationHandler#setCdataSectionElements(java.util.Vector)
      */
-    public void setCdataSectionElements(Vector URI_and_localNames)
+    public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
     {
         m_handler.setCdataSectionElements(URI_and_localNames);
     }
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/WriterToUTF8Buffered.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/WriterToUTF8Buffered.java	Wed Jun 18 13:12:58 2014 -0700
@@ -3,9 +3,11 @@
  * DO NOT REMOVE OR ALTER!
  */
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/XSLOutputAttributes.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/XSLOutputAttributes.java	Wed Jun 18 13:12:58 2014 -0700
@@ -3,9 +3,11 @@
  * DO NOT REMOVE OR ALTER!
  */
 /*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
@@ -22,7 +24,7 @@
  */
 package com.sun.org.apache.xml.internal.serializer;
 
-import java.util.Vector;
+import java.util.ArrayList;
 
 /**
  * This interface has methods associated with the XSLT xsl:output attribues
@@ -105,11 +107,6 @@
      */
     public String getVersion();
 
-
-
-
-
-
     /**
      * Sets the value coming from the xsl:output cdata-section-elements
      * stylesheet property.
@@ -124,7 +121,7 @@
      * relevant in specifying which elements have their text to be output as
      * CDATA sections.
      */
-    public void setCdataSectionElements(Vector URI_and_localNames);
+    public void setCdataSectionElements(ArrayList<String> URI_and_localNames);
 
     /** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
      * @param system the system identifier to be used in the DOCTYPE declaration
@@ -181,4 +178,58 @@
      */
     public void setVersion(String version);
 
+    /**
+     * Get the value for a property that affects seraialization,
+     * if a property was set return that value, otherwise return
+     * the default value, otherwise return null.
+     * @param name The name of the property, which is just the local name
+     * if it is in no namespace, but is the URI in curly braces followed by
+     * the local name if it is in a namespace, for example:
+     * <ul>
+     * <li> "encoding"
+     * <li> "method"
+     * <li> "{http://xml.apache.org/xalan}indent-amount"
+     * <li> "{http://xml.apache.org/xalan}line-separator"
+     * </ul>
+     * @return The value of the parameter
+     */
+    public String getOutputProperty(String name);
+    /**
+     * Get the default value for a property that affects seraialization,
+     * or null if there is none. It is possible that a non-default value
+     * was set for the property, however the value returned by this method
+     * is unaffected by any non-default settings.
+     * @param name The name of the property.
+     * @return The default value of the parameter, or null if there is no default value.
+     */
+    public String getOutputPropertyDefault(String name);
+    /**
+     * Set the non-default value for a property that affects seraialization.
+     * @param name The name of the property, which is just the local name
+     * if it is in no namespace, but is the URI in curly braces followed by
+     * the local name if it is in a namespace, for example:
+     * <ul>
+     * <li> "encoding"
+     * <li> "method"
+     * <li> "{http://xml.apache.org/xalan}indent-amount"
+     * <li> "{http://xml.apache.org/xalan}line-separator"
+     * </ul>
+     * @val The non-default value of the parameter
+     */
+    public void   setOutputProperty(String name, String val);
+
+    /**
+     * Set the default value for a property that affects seraialization.
+     * @param name The name of the property, which is just the local name
+     * if it is in no namespace, but is the URI in curly braces followed by
+     * the local name if it is in a namespace, for example:
+     * <ul>
+     * <li> "encoding"
+     * <li> "method"
+     * <li> "{http://xml.apache.org/xalan}indent-amount"
+     * <li> "{http://xml.apache.org/xalan}line-separator"
+     * </ul>
+     * @val The default value of the parameter
+     */
+    public void   setOutputPropertyDefault(String name, String val);
 }
--- a/jaxp/src/com/sun/xml/internal/stream/Entity.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/xml/internal/stream/Entity.java	Wed Jun 18 13:12:58 2014 -0700
@@ -352,7 +352,7 @@
         }
 
         /**each 'external' parsed entity may have xml/text declaration containing version information
-         * @return String version of the enity, for an internal entity version would be null
+         * @return String version of the entity, for an internal entity version would be null
          */
         public String getEntityVersion(){
             return version ;
--- a/jaxp/src/com/sun/xml/internal/stream/StaxXMLInputSource.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/com/sun/xml/internal/stream/StaxXMLInputSource.java	Wed Jun 18 13:12:58 2014 -0700
@@ -34,7 +34,7 @@
  * @author  Neeraj
  *
  * This class wraps XMLInputSource and is also capable of telling wether application
- * returned XMLStreamReader or not when XMLResolver.resolveEnity
+ * returned XMLStreamReader or not when XMLResolver.resolveEntity
  * was called.
  */
 public class StaxXMLInputSource {
--- a/jaxp/src/javax/xml/datatype/DatatypeConfigurationException.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/datatype/DatatypeConfigurationException.java	Wed Jun 18 13:12:58 2014 -0700
@@ -36,7 +36,7 @@
 
     /**
      * <p>Create a new <code>DatatypeConfigurationException</code> with
-     * no specified detail mesage and cause.</p>
+     * no specified detail message and cause.</p>
      */
 
     public DatatypeConfigurationException() {
--- a/jaxp/src/javax/xml/datatype/DatatypeFactory.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/datatype/DatatypeFactory.java	Wed Jun 18 13:12:58 2014 -0700
@@ -119,7 +119,7 @@
         Pattern.compile("[^YM]*[DT].*");
 
     /**
-     * <p>Protected constructor to prevent instaniation outside of package.</p>
+     * <p>Protected constructor to prevent instantiation outside of package.</p>
      *
      * <p>Use {@link #newInstance()} to create a <code>DatatypeFactory</code>.</p>
      */
--- a/jaxp/src/javax/xml/namespace/QName.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/namespace/QName.java	Wed Jun 18 13:12:58 2014 -0700
@@ -83,7 +83,7 @@
      *
      * <p>To workaround this issue, serialVersionUID is set with either
      * a default value or a compatibility value.  To use the
-     * compatiblity value, set the system property:</p>
+     * compatibility value, set the system property:</p>
      *
      * <code>com.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0</code>
      *
--- a/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java	Wed Jun 18 13:12:58 2014 -0700
@@ -423,7 +423,7 @@
      * <ul>
      *   <li>
      *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
-     *     Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
+     *     Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
      *     If XML processing is limited for security reasons, it will be reported via a call to the registered
      *    {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
      *     See {@link  DocumentBuilder#setErrorHandler(org.xml.sax.ErrorHandler errorHandler)}.
@@ -517,7 +517,7 @@
      * modified DOM trees.
      *
      * <p>
-     * Initialy, null is set as the {@link Schema}.
+     * Initially, null is set as the {@link Schema}.
      *
      * <p>
      * This processing will take effect even if
@@ -531,7 +531,7 @@
      * exception when the {@link #newDocumentBuilder()} is invoked.</p>
      *
      *
-     * <h4>Note for implmentors</h4>
+     * <h4>Note for implementors</h4>
      *
      * <p>
      * A parser must be able to work with any {@link Schema}
--- a/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java	Wed Jun 18 13:12:58 2014 -0700
@@ -45,7 +45,7 @@
 
     /**
      * Create a new <code>FactoryConfigurationError</code> with no
-     * detail mesage.
+     * detail message.
      */
 
     public FactoryConfigurationError() {
--- a/jaxp/src/javax/xml/parsers/ParserConfigurationException.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/parsers/ParserConfigurationException.java	Wed Jun 18 13:12:58 2014 -0700
@@ -35,7 +35,7 @@
 
     /**
      * Create a new <code>ParserConfigurationException</code> with no
-     * detail mesage.
+     * detail message.
      */
 
     public ParserConfigurationException() {
--- a/jaxp/src/javax/xml/parsers/SAXParser.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/parsers/SAXParser.java	Wed Jun 18 13:12:58 2014 -0700
@@ -69,7 +69,7 @@
  * given {@link org.xml.sax.HandlerBase} or the
  * {@link org.xml.sax.helpers.DefaultHandler} are called.<p>
  *
- * Implementors of this class which wrap an underlaying implementation
+ * Implementors of this class which wrap an underlying implementation
  * can consider using the {@link org.xml.sax.helpers.ParserAdapter}
  * class to initially adapt their SAX1 implementation to work under
  * this revised class.
@@ -79,7 +79,7 @@
 public abstract class SAXParser {
 
     /**
-     * <p>Protected constructor to prevent instaniation.
+     * <p>Protected constructor to prevent instantiation.
      * Use {@link javax.xml.parsers.SAXParserFactory#newSAXParser()}.</p>
      */
     protected SAXParser () {
@@ -393,10 +393,10 @@
     }
 
     /**
-     * Returns the SAX parser that is encapsultated by the
+     * Returns the SAX parser that is encapsulated by the
      * implementation of this class.
      *
-     * @return The SAX parser that is encapsultated by the
+     * @return The SAX parser that is encapsulated by the
      *         implementation of this class.
      *
      * @throws SAXException If any SAX errors occur during processing.
--- a/jaxp/src/javax/xml/parsers/SAXParserFactory.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/parsers/SAXParserFactory.java	Wed Jun 18 13:12:58 2014 -0700
@@ -359,7 +359,7 @@
      * is responsible to make sure that the application will receive
      * those modified event stream.</p>
      *
-     * <p>Initialy, <code>null</code> is set as the {@link Schema}.</p>
+     * <p>Initially, <code>null</code> is set as the {@link Schema}.</p>
      *
      * <p>This processing will take effect even if
      * the {@link #isValidating()} method returns <code>false</code>.
--- a/jaxp/src/javax/xml/transform/ErrorListener.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/transform/ErrorListener.java	Wed Jun 18 13:12:58 2014 -0700
@@ -28,7 +28,7 @@
 /**
  * <p>To provide customized error handling, implement this interface and
  * use the <code>setErrorListener</code> method to register an instance of the
- * implmentation with the {@link javax.xml.transform.Transformer}.  The
+ * implementation with the {@link javax.xml.transform.Transformer}.  The
  * <code>Transformer</code> then reports all errors and warnings through this
  * interface.</p>
  *
--- a/jaxp/src/javax/xml/transform/TransformerConfigurationException.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/transform/TransformerConfigurationException.java	Wed Jun 18 13:12:58 2014 -0700
@@ -32,7 +32,7 @@
 
     /**
      * Create a new <code>TransformerConfigurationException</code> with no
-     * detail mesage.
+     * detail message.
      */
     public TransformerConfigurationException() {
         super("Configuration Error");
--- a/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java	Wed Jun 18 13:12:58 2014 -0700
@@ -42,7 +42,7 @@
 
     /**
      * Create a new <code>TransformerFactoryConfigurationError</code> with no
-     * detail mesage.
+     * detail message.
      */
     public TransformerFactoryConfigurationError() {
 
--- a/jaxp/src/javax/xml/validation/SchemaFactory.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/validation/SchemaFactory.java	Wed Jun 18 13:12:58 2014 -0700
@@ -358,7 +358,7 @@
      * <ul>
      *   <li>
      *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
-     *     Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
+     *     Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
      *     If XML processing is limited for security reasons, it will be reported via a call to the registered
      *    {@link ErrorHandler#fatalError(SAXParseException exception)}.
      *     See {@link #setErrorHandler(ErrorHandler errorHandler)}.
--- a/jaxp/src/javax/xml/validation/ValidatorHandler.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxp/src/javax/xml/validation/ValidatorHandler.java	Wed Jun 18 13:12:58 2014 -0700
@@ -379,7 +379,7 @@
      * <ul>
      *   <li>
      *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
-     *     Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
+     *     Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
      *     If XML processing is limited for security reasons, it will be reported via a call to the registered
      *    {@link ErrorHandler#fatalError(SAXParseException exception)}.
      *     See {@link #setErrorHandler(ErrorHandler errorHandler)}.
--- a/jaxws/.hgtags	Mon Jun 09 11:58:07 2014 -0700
+++ b/jaxws/.hgtags	Wed Jun 18 13:12:58 2014 -0700
@@ -262,3 +262,5 @@
 02e58850b7062825308413d420f2b02c1f25a724 jdk9-b14
 e9780330017a6b464a385356d77e5136f9de8d09 jdk9-b15
 1e1a3b2215b7551d88e89d1ca8c1e1ebe3d3c0ab jdk9-b16
+6b159e727dac283f424b7d19f5be3ddd9f85acf5 jdk9-b17
+275f2385aed80c84297840638d58656366350c58 jdk9-b18
--- a/jdk/.hgtags	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/.hgtags	Wed Jun 18 13:12:58 2014 -0700
@@ -259,3 +259,5 @@
 5c7a17a81afd0906b53ee31d95a3211c96ff6b25 jdk9-b14
 4537360f09fe23ab339ee588747b657feb12d0c8 jdk9-b15
 ab7d2c565b0de5bee1361d282d4029371327fc9e jdk9-b16
+fd8e675f141b9bdb2f46d1ae8251f4ee3a895d64 jdk9-b17
+6ad17b31f0d30593392b1e8695b9709dbbd7fb70 jdk9-b18
--- a/jdk/src/aix/native/java/net/aix_close.c	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/aix/native/java/net/aix_close.c	Wed Jun 18 13:12:58 2014 -0700
@@ -370,7 +370,57 @@
 }
 
 int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
-    BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
+    int crc = -1, prc = -1;
+    threadEntry_t self;
+    fdEntry_t* fdEntry = getFdEntry(s);
+
+    if (fdEntry == NULL) {
+        errno = EBADF;
+        return -1;
+    }
+
+    /* On AIX, when the system call connect() is interrupted, the connection
+     * is not aborted and it will be established asynchronously by the kernel.
+     * Hence, no need to restart connect() when EINTR is received
+     */
+    startOp(fdEntry, &self);
+    crc = connect(s, addr, addrlen);
+    endOp(fdEntry, &self);
+
+    if (crc == -1 && errno == EINTR) {
+        struct pollfd s_pollfd;
+        int sockopt_arg = 0;
+        socklen_t len;
+
+        s_pollfd.fd = s;
+        s_pollfd.events = POLLOUT | POLLERR;
+
+        /* poll the file descriptor */
+        do {
+            startOp(fdEntry, &self);
+            prc = poll(&s_pollfd, 1, -1);
+            endOp(fdEntry, &self);
+        } while (prc == -1  && errno == EINTR);
+
+        if (prc < 0)
+            return prc;
+
+        len = sizeof(sockopt_arg);
+
+        /* Check whether the connection has been established */
+        if (getsockopt(s, SOL_SOCKET, SO_ERROR, &sockopt_arg, &len) == -1)
+            return -1;
+
+        if (sockopt_arg != 0 ) {
+            errno = sockopt_arg;
+            return -1;
+        }
+    } else {
+        return crc;
+    }
+
+    /* At this point, fd is connected. Set successful return code */
+    return 0;
 }
 
 int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Wed Jun 18 13:12:58 2014 -0700
@@ -523,7 +523,7 @@
      *                 that is used for menu shortcuts on this toolkit.
      * @see       java.awt.MenuBar
      * @see       java.awt.MenuShortcut
-     * @since     JDK1.1
+     * @since     1.1
      */
     @Override
     public int getMenuShortcutKeyMask() {
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java	Wed Jun 18 13:12:58 2014 -0700
@@ -839,7 +839,7 @@
         return parts;
     }
 
-    /** @since JDK 7, JSR 292 */
+    /** @since 1.7, JSR 292 */
     public static
     class MethodHandleEntry extends Entry {
         final int refKind;
@@ -889,7 +889,7 @@
         }
     }
 
-    /** @since JDK 7, JSR 292 */
+    /** @since 1.7, JSR 292 */
     public static
     class MethodTypeEntry extends Entry {
         final SignatureEntry typeRef;
@@ -924,7 +924,7 @@
         }
     }
 
-    /** @since JDK 7, JSR 292 */
+    /** @since 1.7, JSR 292 */
     public static
     class InvokeDynamicEntry extends Entry {
         final BootstrapMethodEntry bssRef;
@@ -977,7 +977,7 @@
         }
     }
 
-    /** @since JDK 7, JSR 292 */
+    /** @since 1.7, JSR 292 */
     public static
     class BootstrapMethodEntry extends Entry {
         final MethodHandleEntry bsmRef;
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/package.html	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/package.html	Wed Jun 18 13:12:58 2014 -0700
@@ -97,7 +97,7 @@
 </ul>
 
 <li>
-@since JDK1.5.0</li>
+@since 1.5</li>
 
 <br><!-- Put @see and @since tags down here. -->
 </body>
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java	Wed Jun 18 13:12:58 2014 -0700
@@ -562,7 +562,7 @@
                 }
                 if (readMethod != null) {
                     ReflectUtil.checkPackageAccess(readMethod.getDeclaringClass());
-                    return MethodUtil.invoke(readMethod, complex, new Class[0]);
+                    return MethodUtil.invoke(readMethod, complex, new Class<?>[0]);
                 }
 
                 throw new AttributeNotFoundException(
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Wed Jun 18 13:12:58 2014 -0700
@@ -757,7 +757,7 @@
         }
     }
 
-    private static void ensureClassAccess(Class clazz)
+    private static void ensureClassAccess(Class<?> clazz)
             throws IllegalAccessException
     {
         int mod = clazz.getModifiers();
--- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Wed Jun 18 13:12:58 2014 -0700
@@ -58,7 +58,7 @@
 
     private final AccessControlContext acc;
 
-    public ClientNotifForwarder(Map env) {
+    public ClientNotifForwarder(Map<String, ?> env) {
         this(null, env);
     }
 
--- a/jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java	Wed Jun 18 13:12:58 2014 -0700
@@ -310,10 +310,10 @@
                     }
                 });
         if (s == null) return; /* security has not been enabled */
-        final Set principals = s.getPrincipals();
+        final Set<Principal> principals = s.getPrincipals();
         String newPropertyValue = null;
-        for (Iterator i = principals.iterator(); i.hasNext(); ) {
-            final Principal p = (Principal) i.next();
+        for (Iterator<Principal> i = principals.iterator(); i.hasNext(); ) {
+            final Principal p = i.next();
             Access access = accessMap.get(p.getName());
             if (access != null) {
                 boolean ok;
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpRequestTree.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpRequestTree.java	Wed Jun 18 13:12:58 2014 -0700
@@ -535,7 +535,7 @@
 
                 // Save old vectors
                 SnmpOid[]     olde = entryoids;
-                Vector[]      oldl = entrylists;
+                Vector<SnmpVarBind>[]      oldl = entrylists;
                 boolean[]     oldn = isentrynew;
                 SnmpVarBind[] oldr = rowstatus;
 
--- a/jdk/src/share/classes/com/sun/management/DiagnosticCommandMBean.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/management/DiagnosticCommandMBean.java	Wed Jun 18 13:12:58 2014 -0700
@@ -212,7 +212,7 @@
  * {@linkplain javax.management.Notification#getUserData() userData} that
  * is the new {@code MBeanInfo}.
  *
- * @since 8
+ * @since 1.8
  */
 public interface DiagnosticCommandMBean extends DynamicMBean
 {
--- a/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java	Wed Jun 18 13:12:58 2014 -0700
@@ -7697,7 +7697,7 @@
      * @param columnIndex the first column is 1, the second is 2, ...
      * @return a SQLXML object that maps an SQL XML value
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public SQLXML getSQLXML(int columnIndex) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7723,7 +7723,7 @@
      * @return the column value if the value is a SQL <code>NULL</code> the
      *     value returned is <code>null</code>
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public RowId getRowId(int columnIndex) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7738,7 +7738,7 @@
      * @return the column value if the value is a SQL <code>NULL</code> the
      *     value returned is <code>null</code>
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public RowId getRowId(String columnName) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7754,7 +7754,7 @@
      * @param columnIndex the first column is 1, the second 2, ...
      * @param x the column value
      * @throws SQLException if a database access occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateRowId(int columnIndex, RowId x) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7770,7 +7770,7 @@
      * @param columnName the name of the column
      * @param x the column value
      * @throws SQLException if a database access occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateRowId(String columnName, RowId x) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7780,7 +7780,7 @@
      * Retrieves the holdability of this ResultSet object
      * @return  either ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
      * @throws SQLException if a database error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public int getHoldability() throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7791,7 +7791,7 @@
      * method close has been called on it, or if it is automatically closed.
      * @return true if this ResultSet object is closed; false if it is still open
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public boolean isClosed() throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7803,7 +7803,7 @@
      * @param columnIndex the first column is 1, the second 2, ...
      * @param nString the value for the column to be updated
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateNString(int columnIndex, String nString) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7815,7 +7815,7 @@
      * @param columnName name of the Column
      * @param nString the value for the column to be updated
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateNString(String columnName, String nString) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7828,7 +7828,7 @@
      * @param columnIndex the first column is 1, the second 2, ...
      * @param nClob the value for the column to be updated
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7840,7 +7840,7 @@
      * @param columnName name of the column
      * @param nClob the value for the column to be updated
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateNClob(String columnName, NClob nClob) throws SQLException {
        throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7855,7 +7855,7 @@
      * @return a <code>NClob</code> object representing the SQL
      *         <code>NCLOB</code> value in the specified column
      * @exception SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public NClob getNClob(int i) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
@@ -7871,7 +7871,7 @@
      * @return a <code>NClob</code> object representing the SQL <code>NCLOB</code>
      * value in the specified column
      * @exception SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public NClob getNClob(String colName) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("cachedrowsetimpl.opnotysupp").toString());
--- a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java	Wed Jun 18 13:12:58 2014 -0700
@@ -4505,7 +4505,7 @@
      * @param columnIndex the first column is 1, the second is 2, ...
      * @return a SQLXML object that maps an SQL XML value
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public SQLXML getSQLXML(int columnIndex) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4531,7 +4531,7 @@
      * @return the column value if the value is a SQL <code>NULL</code> the
      *     value returned is <code>null</code>
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public RowId getRowId(int columnIndex) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4546,7 +4546,7 @@
      * @return the column value if the value is a SQL <code>NULL</code> the
      *     value returned is <code>null</code>
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public RowId getRowId(String columnName) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4562,7 +4562,7 @@
      * @param columnIndex the first column is 1, the second 2, ...
      * @param x the column value
      * @throws SQLException if a database access occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateRowId(int columnIndex, RowId x) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4578,7 +4578,7 @@
      * @param columnName the name of the column
      * @param x the column value
      * @throws SQLException if a database access occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateRowId(String columnName, RowId x) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4588,7 +4588,7 @@
      * Retrieves the holdability of this ResultSet object
      * @return  either ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
      * @throws SQLException if a database error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public int getHoldability() throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4599,7 +4599,7 @@
      * method close has been called on it, or if it is automatically closed.
      * @return true if this ResultSet object is closed; false if it is still open
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public boolean isClosed() throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4611,7 +4611,7 @@
      * @param columnIndex the first column is 1, the second 2, ...
      * @param nString the value for the column to be updated
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateNString(int columnIndex, String nString) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4623,7 +4623,7 @@
      * @param columnName name of the Column
      * @param nString the value for the column to be updated
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateNString(String columnName, String nString) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4636,7 +4636,7 @@
      * @param columnIndex the first column is 1, the second 2, ...
      * @param nClob the value for the column to be updated
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4648,7 +4648,7 @@
      * @param columnName name of the column
      * @param nClob the value for the column to be updated
      * @throws SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public void updateNClob(String columnName, NClob nClob) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4663,7 +4663,7 @@
      * @return a <code>NClob</code> object representing the SQL
      *         <code>NCLOB</code> value in the specified column
      * @exception SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public NClob getNClob(int i) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
@@ -4679,7 +4679,7 @@
      * @return a <code>NClob</code> object representing the SQL <code>NCLOB</code>
      * value in the specified column
      * @exception SQLException if a database access error occurs
-     * @since 6.0
+     * @since 1.6
      */
     public NClob getNClob(String colName) throws SQLException {
         throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString());
--- a/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java	Wed Jun 18 13:12:58 2014 -0700
@@ -76,16 +76,10 @@
  *      // attach to target VM
  *      VirtualMachine vm = VirtualMachine.attach("2177");
  *
- *      // get system properties in target VM
- *      Properties props = vm.getSystemProperties();
- *
- *      // construct path to management agent
- *      String home = props.getProperty("java.home");
- *      String agent = home + File.separator + "lib" + File.separator
- *          + "management-agent.jar";
- *
- *      // load agent into target VM
- *      vm.loadAgent(agent, "com.sun.management.jmxremote.port=5000");
+ *      // start management agent
+ *      Properties props = new Properties();
+ *      props.put("com.sun.management.jmxremote.port", "5000");
+ *      vm.startManagementAgent(props);
  *
  *      // detach
  *      vm.detach();
@@ -93,9 +87,9 @@
  * </pre>
  *
  * <p> In this example we attach to a Java virtual machine that is identified by
- * the process identifier <code>2177</code>. The system properties from the target
- * VM are then used to construct the path to a <i>management agent</i> which is then
- * loaded into the target VM. Once loaded the client detaches from the target VM. </p>
+ * the process identifier <code>2177</code>. Then the JMX management agent is
+ * started in the target process using the supplied arguments. Finally, the
+ * client detaches from the target VM. </p>
  *
  * <p> A VirtualMachine is safe for use by multiple concurrent threads. </p>
  *
@@ -611,6 +605,68 @@
     public abstract Properties getAgentProperties() throws IOException;
 
     /**
+     * Starts the JMX management agent in the target virtual machine.
+     *
+     * <p> The configuration properties are the same as those specified on
+     * the command line when starting the JMX management agent. In the same
+     * way as on the command line, you need to specify at least the
+     * {@code com.sun.management.jmxremote.port} property.
+     *
+     * <p> See the online documentation for <a
+     * href="../../../../../../../../technotes/guides/management/agent.html">
+     * Monitoring and Management Using JMX Technology</a> for further details.
+     *
+     * @param   agentProperties
+     *          A Properties object containing the configuration properties
+     *          for the agent.
+     *
+     * @throws  AttachOperationFailedException
+     *          If the target virtual machine is unable to complete the
+     *          attach operation. A more specific error message will be
+     *          given by {@link AttachOperationFailedException#getMessage()}.
+     *
+     * @throws  IOException
+     *          If an I/O error occurs, a communication error for example,
+     *          that cannot be identified as an error to indicate that the
+     *          operation failed in the target VM.
+     *
+     * @throws  IllegalArgumentException
+     *          If keys or values in agentProperties are invalid.
+     *
+     * @throws  NullPointerException
+     *          If agentProperties is null.
+     *
+     * @since   1.9
+     */
+    public abstract void startManagementAgent(Properties agentProperties) throws IOException;
+
+    /**
+     * Starts the local JMX management agent in the target virtual machine.
+     *
+     * <p> See the online documentation for <a
+     * href="../../../../../../../../technotes/guides/management/agent.html">
+     * Monitoring and Management Using JMX Technology</a> for further details.
+     *
+     * @return  The String representation of the local connector's service address.
+     *          The value can be parsed by the
+     *          {@link javax.management.remote.JMXServiceURL#JMXServiceURL(String)}
+     *          constructor.
+     *
+     * @throws  AttachOperationFailedException
+     *          If the target virtual machine is unable to complete the
+     *          attach operation. A more specific error message will be
+     *          given by {@link AttachOperationFailedException#getMessage()}.
+     *
+     * @throws  IOException
+     *          If an I/O error occurs, a communication error for example,
+     *          that cannot be identified as an error to indicate that the
+     *          operation failed in the target VM.
+     *
+     * @since   1.9
+     */
+    public abstract String startLocalManagementAgent() throws IOException;
+
+    /**
      * Returns a hash-code value for this VirtualMachine. The hash
      * code is based upon the VirtualMachine's components, and satifies
      * the general contract of the {@link java.lang.Object#hashCode()
--- a/jdk/src/share/classes/java/applet/Applet.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/applet/Applet.java	Wed Jun 18 13:12:58 2014 -0700
@@ -45,7 +45,7 @@
  *
  * @author      Arthur van Hoff
  * @author      Chris Warth
- * @since       JDK1.0
+ * @since       1.0
  */
 public class Applet extends Panel {
 
@@ -375,7 +375,7 @@
      *
      * @return  the locale of the applet; if no locale has
      *          been set, the default locale is returned.
-     * @since   JDK1.1
+     * @since   1.1
      */
     public Locale getLocale() {
       Locale locale = super.getLocale();
--- a/jdk/src/share/classes/java/applet/AppletContext.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/applet/AppletContext.java	Wed Jun 18 13:12:58 2014 -0700
@@ -43,7 +43,7 @@
  * information about its environment.
  *
  * @author      Arthur van Hoff
- * @since       JDK1.0
+ * @since       1.0
  */
 public interface AppletContext {
     /**
--- a/jdk/src/share/classes/java/applet/AppletStub.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/applet/AppletStub.java	Wed Jun 18 13:12:58 2014 -0700
@@ -35,7 +35,7 @@
  *
  * @author      Arthur van Hoff
  * @see         java.applet.Applet#setStub(java.applet.AppletStub)
- * @since       JDK1.0
+ * @since       1.0
  */
 public interface AppletStub {
     /**
--- a/jdk/src/share/classes/java/applet/AudioClip.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/applet/AudioClip.java	Wed Jun 18 13:12:58 2014 -0700
@@ -32,7 +32,7 @@
  * together to produce a composite.
  *
  * @author      Arthur van Hoff
- * @since       JDK1.0
+ * @since       1.0
  */
 public interface AudioClip {
     /**
--- a/jdk/src/share/classes/java/applet/package.html	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/applet/package.html	Wed Jun 18 13:12:58 2014 -0700
@@ -55,6 +55,6 @@
 </ul>
 -->
 
-@since JDK1.0
+@since 1.0
 </body>
 </html>
--- a/jdk/src/share/classes/java/awt/AWTError.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/AWTError.java	Wed Jun 18 13:12:58 2014 -0700
@@ -41,7 +41,7 @@
      * Constructs an instance of <code>AWTError</code> with the specified
      * detail message.
      * @param   msg   the detail message.
-     * @since   JDK1.0
+     * @since   1.0
      */
     public AWTError(String msg) {
         super(msg);
--- a/jdk/src/share/classes/java/awt/AWTException.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/AWTException.java	Wed Jun 18 13:12:58 2014 -0700
@@ -43,7 +43,7 @@
      * instance of <code>String</code> that describes this particular
      * exception.
      * @param   msg     the detail message
-     * @since   JDK1.0
+     * @since   1.0
      */
     public AWTException(String msg) {
         super(msg);
--- a/jdk/src/share/classes/java/awt/BorderLayout.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/BorderLayout.java	Wed Jun 18 13:12:58 2014 -0700
@@ -119,7 +119,7 @@
  * @author      Arthur van Hoff
  * @see         java.awt.Container#add(String, Component)
  * @see         java.awt.ComponentOrientation
- * @since       JDK1.0
+ * @since       1.0
  */
 public class BorderLayout implements LayoutManager2,
                                      java.io.Serializable {
@@ -367,7 +367,7 @@
 
     /**
      * Returns the horizontal gap between components.
-     * @since   JDK1.1
+     * @since   1.1
      */
     public int getHgap() {
         return hgap;
@@ -376,7 +376,7 @@
     /**
      * Sets the horizontal gap between components.
      * @param hgap the horizontal gap between components
-     * @since   JDK1.1
+     * @since   1.1
      */
     public void setHgap(int hgap) {
         this.hgap = hgap;
@@ -384,7 +384,7 @@
 
     /**
      * Returns the vertical gap between components.
-     * @since   JDK1.1
+     * @since   1.1
      */
     public int getVgap() {
         return vgap;
@@ -393,7 +393,7 @@
     /**
      * Sets the vertical gap between components.
      * @param vgap the vertical gap between components
-     * @since   JDK1.1
+     * @since   1.1
      */
     public void setVgap(int vgap) {
         this.vgap = vgap;
@@ -415,7 +415,7 @@
      * @see     java.awt.Container#add(java.awt.Component, java.lang.Object)
      * @exception   IllegalArgumentException  if the constraint object is not
      *              a string, or if it not one of the five specified constants.
-     * @since   JDK1.1
+     * @since   1.1
      */
     public void addLayoutComponent(Component comp, Object constraints) {
       synchronized (comp.getTreeLock()) {
--- a/jdk/src/share/classes/java/awt/Button.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Button.java	Wed Jun 18 13:12:58 2014 -0700
@@ -82,7 +82,7 @@
  * @see         java.awt.event.ActionListener
  * @see         java.awt.Component#processMouseEvent
  * @see         java.awt.Component#addMouseListener
- * @since       JDK1.0
+ * @since       1.0
  */
 public class Button extends Component implements Accessible {
 
@@ -228,7 +228,7 @@
      *            If the string is <code>null</code> then the action command
      *            is set to match the label of the button.
      * @see       java.awt.event.ActionEvent
-     * @since     JDK1.1
+     * @since     1.1
      */
     public void setActionCommand(String command) {
         actionCommand = command;
@@ -255,7 +255,7 @@
      * @see           #removeActionListener
      * @see           #getActionListeners
      * @see           java.awt.event.ActionListener
-     * @since         JDK1.1
+     * @since         1.1
      */
     public synchronized void addActionListener(ActionListener l) {
         if (l == null) {
@@ -277,7 +277,7 @@
      * @see             #addActionListener
      * @see             #getActionListeners
      * @see             java.awt.event.ActionListener
-     * @since           JDK1.1
+     * @since           1.1
      */
     public synchronized void removeActionListener(ActionListener l) {
         if (l == null) {
@@ -370,7 +370,7 @@
      * @param        e the event
      * @see          java.awt.event.ActionEvent
      * @see          java.awt.Button#processActionEvent
-     * @since        JDK1.1
+     * @since        1.1
      */
     protected void processEvent(AWTEvent e) {
         if (e instanceof ActionEvent) {
@@ -401,7 +401,7 @@
      * @see         java.awt.event.ActionListener
      * @see         java.awt.Button#addActionListener
      * @see         java.awt.Component#enableEvents
-     * @since       JDK1.1
+     * @since       1.1
      */
     protected void processActionEvent(ActionEvent e) {
         ActionListener listener = actionListener;
--- a/jdk/src/share/classes/java/awt/Canvas.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Canvas.java	Wed Jun 18 13:12:58 2014 -0700
@@ -39,7 +39,7 @@
  * in order to perform custom graphics on the canvas.
  *
  * @author      Sami Shaio
- * @since       JDK1.0
+ * @since       1.0
  */
 public class Canvas extends Component implements Accessible {
 
--- a/jdk/src/share/classes/java/awt/CardLayout.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/CardLayout.java	Wed Jun 18 13:12:58 2014 -0700
@@ -53,7 +53,7 @@
  *
  * @author      Arthur van Hoff
  * @see         java.awt.Container
- * @since       JDK1.0
+ * @since       1.0
  */
 
 public class CardLayout implements LayoutManager2,
@@ -148,7 +148,7 @@
      * @return    the horizontal gap between components.
      * @see       java.awt.CardLayout#setHgap(int)
      * @see       java.awt.CardLayout#getVgap()
-     * @since     JDK1.1
+     * @since     1.1
      */
     public int getHgap() {
         return hgap;
@@ -159,7 +159,7 @@
      * @param hgap the horizontal gap between components.
      * @see       java.awt.CardLayout#getHgap()
      * @see       java.awt.CardLayout#setVgap(int)
-     * @since     JDK1.1
+     * @since     1.1
      */
     public void setHgap(int hgap) {
         this.hgap = hgap;
@@ -180,7 +180,7 @@
      * @param     vgap the vertical gap between components.
      * @see       java.awt.CardLayout#getVgap()
      * @see       java.awt.CardLayout#setHgap(int)
-     * @since     JDK1.1
+     * @since     1.1
      */
     public void setVgap(int vgap) {
         this.vgap = vgap;
--- a/jdk/src/share/classes/java/awt/Checkbox.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Checkbox.java	Wed Jun 18 13:12:58 2014 -0700
@@ -71,7 +71,7 @@
  * @author      Sami Shaio
  * @see         java.awt.GridLayout
  * @see         java.awt.CheckboxGroup
- * @since       JDK1.0
+ * @since       1.0
  */
 public class Checkbox extends Component implements ItemSelectable, Accessible {
 
@@ -190,7 +190,7 @@
      *     <code>GraphicsEnvironment.isHeadless</code>
      *     returns <code>true</code>
      * @see java.awt.GraphicsEnvironment#isHeadless
-     * @since     JDK1.1
+     * @since     1.1
      */
     public Checkbox(String label, boolean state, CheckboxGroup group)
         throws HeadlessException {
@@ -216,7 +216,7 @@
      *    <code>GraphicsEnvironment.isHeadless</code>
      *    returns <code>true</code>
      * @see java.awt.GraphicsEnvironment#isHeadless
-     * @since     JDK1.1
+     * @since     1.1
      */
     public Checkbox(String label, CheckboxGroup group, boolean state)
         throws HeadlessException {
@@ -424,7 +424,7 @@
      * @see           #setState
      * @see           java.awt.event.ItemEvent
      * @see           java.awt.event.ItemListener
-     * @since         JDK1.1
+     * @since         1.1
      */
     public synchronized void addItemListener(ItemListener l) {
         if (l == null) {
@@ -446,7 +446,7 @@
      * @see           #getItemListeners
      * @see           java.awt.event.ItemEvent
      * @see           java.awt.event.ItemListener
-     * @since         JDK1.1
+     * @since         1.1
      */
     public synchronized void removeItemListener(ItemListener l) {
         if (l == null) {
@@ -540,7 +540,7 @@
      * @param         e the event
      * @see           java.awt.event.ItemEvent
      * @see           #processItemEvent
-     * @since         JDK1.1
+     * @since         1.1
      */
     protected void processEvent(AWTEvent e) {
         if (e instanceof ItemEvent) {
@@ -572,7 +572,7 @@
      * @see         java.awt.event.ItemListener
      * @see         #addItemListener
      * @see         java.awt.Component#enableEvents
-     * @since       JDK1.1
+     * @since       1.1
      */
     protected void processItemEvent(ItemEvent e) {
         ItemListener listener = itemListener;
--- a/jdk/src/share/classes/java/awt/CheckboxGroup.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/CheckboxGroup.java	Wed Jun 18 13:12:58 2014 -0700
@@ -52,7 +52,7 @@
  *
  * @author      Sami Shaio
  * @see         java.awt.Checkbox
- * @since       JDK1.0
+ * @since       1.0
  */
 public class CheckboxGroup implements java.io.Serializable {
     /**
@@ -84,7 +84,7 @@
      *                 "on" state, or <code>null</code>.
      * @see      java.awt.Checkbox
      * @see      java.awt.CheckboxGroup#setSelectedCheckbox
-     * @since    JDK1.1
+     * @since    1.1
      */
     public Checkbox getSelectedCheckbox() {
         return getCurrent();
@@ -113,7 +113,7 @@
      *                      current selection.
      * @see      java.awt.Checkbox
      * @see      java.awt.CheckboxGroup#getSelectedCheckbox
-     * @since    JDK1.1
+     * @since    1.1
      */
     public void setSelectedCheckbox(Checkbox box) {
         setCurrent(box);
--- a/jdk/src/share/classes/java/awt/CheckboxMenuItem.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/CheckboxMenuItem.java	Wed Jun 18 13:12:58 2014 -0700
@@ -59,7 +59,7 @@
  * @author      Sami Shaio
  * @see         java.awt.event.ItemEvent
  * @see         java.awt.event.ItemListener
- * @since       JDK1.0
+ * @since       1.0
  */
 public class CheckboxMenuItem extends MenuItem implements ItemSelectable, Accessible {
 
@@ -102,7 +102,7 @@
      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
      * returns true
      * @see java.awt.GraphicsEnvironment#isHeadless
-     * @since   JDK1.1
+     * @since   1.1
      */
     public CheckboxMenuItem() throws HeadlessException {
         this("", false);
@@ -132,7 +132,7 @@
      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
      * returns true
      * @see java.awt.GraphicsEnvironment#isHeadless
-     * @since      JDK1.1
+     * @since      1.1
      */
     public CheckboxMenuItem(String label, boolean state)
         throws HeadlessException {
@@ -231,7 +231,7 @@
      * @see           #setState
      * @see           java.awt.event.ItemEvent
      * @see           java.awt.event.ItemListener
-     * @since         JDK1.1
+     * @since         1.1
      */
     public synchronized void addItemListener(ItemListener l) {
         if (l == null) {
@@ -253,7 +253,7 @@
      * @see           #getItemListeners
      * @see           java.awt.event.ItemEvent
      * @see           java.awt.event.ItemListener
-     * @since         JDK1.1
+     * @since         1.1
      */
     public synchronized void removeItemListener(ItemListener l) {
         if (l == null) {
@@ -350,7 +350,7 @@
      * @param        e the event
      * @see          java.awt.event.ItemEvent
      * @see          #processItemEvent
-     * @since        JDK1.1
+     * @since        1.1
      */
     protected void processEvent(AWTEvent e) {
         if (e instanceof ItemEvent) {
@@ -381,7 +381,7 @@
      * @see         java.awt.event.ItemListener
      * @see         #addItemListener
      * @see         java.awt.MenuItem#enableEvents
-     * @since       JDK1.1
+     * @since       1.1
      */
     protected void processItemEvent(ItemEvent e) {
         ItemListener listener = itemListener;
--- a/jdk/src/share/classes/java/awt/Choice.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Choice.java	Wed Jun 18 13:12:58 2014 -0700
@@ -68,7 +68,7 @@
  *
  * @author      Sami Shaio
  * @author      Arthur van Hoff
- * @since       JDK1.0
+ * @since       1.0
  */
 public class Choice extends Component implements ItemSelectable, Accessible {
     /**
@@ -158,7 +158,7 @@
      * Returns the number of items in this <code>Choice</code> menu.
      * @return the number of items in this <code>Choice</code> menu
      * @see     #getItem
-     * @since   JDK1.1
+     * @since   1.1
      */
     public int getItemCount() {
         return countItems();
@@ -196,7 +196,7 @@
      * @param      item    the item to be added
      * @exception  NullPointerException   if the item's value is
      *                  <code>null</code>
-     * @since      JDK1.1
+     * @since      1.1
      */
     public void add(String item) {
         addItem(item);
@@ -291,7 +291,7 @@
      * @param      item  the item to remove from this <code>Choice</code> menu
      * @exception  IllegalArgumentException  if the item doesn't
      *                     exist in the choice menu
-     * @since      JDK1.1
+     * @since      1.1
      */
     public void remove(String item) {
         synchronized (this) {
@@ -319,7 +319,7 @@
      * @param      position the position of the item
      * @throws IndexOutOfBoundsException if the specified
      *          position is out of bounds
-     * @since      JDK1.1
+     * @since      1.1
      */
     public void remove(int position) {
         synchronized (this) {
@@ -357,7 +357,7 @@
     /**
      * Removes all items from the choice menu.
      * @see       #remove
-     * @since     JDK1.1
+     * @since     1.1
      */
     public void removeAll() {
         synchronized (this) {
@@ -475,7 +475,7 @@
      * @see           #select
      * @see           java.awt.event.ItemEvent
      * @see           java.awt.event.ItemListener
-     * @since         JDK1.1
+     * @since         1.1
      */
     public synchronized void addItemListener(ItemListener l) {
         if (l == null) {
@@ -497,7 +497,7 @@
      * @see           #getItemListeners
      * @see           java.awt.event.ItemEvent
      * @see           java.awt.event.ItemListener
-     * @since         JDK1.1
+     * @since         1.1
      */
     public synchronized void removeItemListener(ItemListener l) {
         if (l == null) {
@@ -591,7 +591,7 @@
      * @param      e the event
      * @see        java.awt.event.ItemEvent
      * @see        #processItemEvent
-     * @since      JDK1.1
+     * @since      1.1
      */
     protected void processEvent(AWTEvent e) {
         if (e instanceof ItemEvent) {
@@ -623,7 +623,7 @@
      * @see         java.awt.event.ItemListener
      * @see         #addItemListener(ItemListener)
      * @see         java.awt.Component#enableEvents
-     * @since       JDK1.1
+     * @since       1.1
      */
     protected void processItemEvent(ItemEvent e) {
         ItemListener listener = itemListener;
--- a/jdk/src/share/classes/java/awt/Color.java	Mon Jun 09 11:58:07 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Color.java	Wed Jun 18 13:12:58 2014 -0700
@@ -597,7 +597,7 @@
      * @see #getRed
      * @see #getGreen
      * @see #getBlue
-     * @since JDK1.0
+     * @since 1.0
      */
     public int getRGB() {
         return value;
@@ -621,7 +621,7 @@
      *                 a brighter version of this <code>Color</code>
      *                 with the same {@code alpha} value.
      * @see        java.awt.Color#darker
-     * @since      JDK1.0
+     * @since      1.0
      */
     public Color brighter() {
         int r = getRed();
@@ -664,7 +664,7 @@
      *                    a darker version of this <code>Color&l