changeset 16278:9488936fe014

Merge
author duke
date Wed, 05 Jul 2017 18:45:29 +0200
parents fd698c5ee684 f3a0da53819f
children 58be9cf66111
files corba/src/share/classes/com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3_1.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3_1.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3_1.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3_1.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryId_1_3.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryId_1_3_1.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3.java corba/src/share/classes/com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3_1.java jdk/make/tools/javazic/Makefile jdk/make/tools/src/build/tools/javazic/BackEnd.java jdk/make/tools/src/build/tools/javazic/Checksum.java jdk/make/tools/src/build/tools/javazic/DayOfWeek.java jdk/make/tools/src/build/tools/javazic/Gen.java jdk/make/tools/src/build/tools/javazic/GenDoc.java jdk/make/tools/src/build/tools/javazic/Main.java jdk/make/tools/src/build/tools/javazic/Mappings.java jdk/make/tools/src/build/tools/javazic/Month.java jdk/make/tools/src/build/tools/javazic/Rule.java jdk/make/tools/src/build/tools/javazic/RuleDay.java jdk/make/tools/src/build/tools/javazic/RuleRec.java jdk/make/tools/src/build/tools/javazic/Simple.java jdk/make/tools/src/build/tools/javazic/Time.java jdk/make/tools/src/build/tools/javazic/Timezone.java jdk/make/tools/src/build/tools/javazic/Zone.java jdk/make/tools/src/build/tools/javazic/ZoneRec.java jdk/make/tools/src/build/tools/javazic/Zoneinfo.java jdk/src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java jdk/src/share/classes/java/util/function/Block.java jdk/src/share/classes/java/util/function/DoubleBlock.java jdk/src/share/classes/java/util/function/IntBlock.java jdk/src/share/classes/java/util/function/LongBlock.java jdk/src/share/classes/sun/security/util/KeyLength.java jdk/test/javax/script/RhinoExceptionTest.java
diffstat 601 files changed, 17498 insertions(+), 13640 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags-top-repo	Sat Mar 09 21:49:32 2013 +0530
+++ b/.hgtags-top-repo	Wed Jul 05 18:45:29 2017 +0200
@@ -202,3 +202,4 @@
 fd1a5574cf68af24bfd52decc37ac6361afb278a jdk8-b78
 91d35211e74464dca5edf9b66ab01d0d0d8cded7 jdk8-b79
 907a926d3c96472f357617b48b6b968ea855c23c jdk8-b80
+145dbc56f931c134e837b675b9e6e7bf08902e93 jdk8-b81
--- a/Makefile	Sat Mar 09 21:49:32 2013 +0530
+++ b/Makefile	Wed Jul 05 18:45:29 2017 +0200
@@ -90,6 +90,7 @@
 include ./make/jaxp-rules.gmk
 include ./make/jaxws-rules.gmk
 include ./make/jdk-rules.gmk
+include ./make/nashorn-rules.gmk
 include ./make/install-rules.gmk
 include ./make/sponsors-rules.gmk
 include ./make/deploy-rules.gmk
@@ -174,6 +175,11 @@
   clobber:: jdk-clobber
 endif
 
+ifeq ($(BUILD_NASHORN), true)
+  generic_build_repo_series:: $(NASHORN)
+  clobber:: nashorn-clobber
+endif
+
 ifeq ($(BUILD_DEPLOY), true)
   generic_build_repo_series:: $(DEPLOY)
   clobber:: deploy-clobber
@@ -336,6 +342,7 @@
 	    BUILD_HOTSPOT=false \
 	    BUILD_JDK=false \
 	    BUILD_LANGTOOLS=false \
+	    BUILD_NASHORN=false \
 	    BUILD_CORBA=false \
 	    BUILD_JAXP=false \
 	    BUILD_JAXWS=false \
--- a/common/autoconf/configure.ac	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/autoconf/configure.ac	Wed Jul 05 18:45:29 2017 +0200
@@ -194,6 +194,7 @@
 ###############################################################################
 
 JDKOPT_SETUP_BUILD_TWEAKS
+JDKOPT_DETECT_INTREE_EC
 
 ###############################################################################
 #
--- a/common/autoconf/generated-configure.sh	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/autoconf/generated-configure.sh	Wed Jul 05 18:45:29 2017 +0200
@@ -612,6 +612,7 @@
 JOBS
 MEMORY_SIZE
 NUM_CORES
+ENABLE_INTREE_EC
 SALIB_NAME
 HOTSPOT_MAKE_ARGS
 FIXPATH
@@ -749,6 +750,7 @@
 OVERRIDE_SRC_ROOT
 ADD_SRC_ROOT
 JDK_TOPDIR
+NASHORN_TOPDIR
 HOTSPOT_TOPDIR
 JAXWS_TOPDIR
 JAXP_TOPDIR
@@ -3751,7 +3753,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1363150186
+DATE_WHEN_GENERATED=1363706268
 
 ###############################################################################
 #
@@ -10785,6 +10787,12 @@
 
 ###############################################################################
 #
+# Enable or disable the elliptic curve crypto implementation
+#
+
+
+###############################################################################
+#
 # Compress jars
 #
 COMPRESS_JARS=false
@@ -15682,6 +15690,7 @@
 JAXP_TOPDIR="$SRC_ROOT/jaxp"
 JAXWS_TOPDIR="$SRC_ROOT/jaxws"
 HOTSPOT_TOPDIR="$SRC_ROOT/hotspot"
+NASHORN_TOPDIR="$SRC_ROOT/nashorn"
 JDK_TOPDIR="$SRC_ROOT/jdk"
 
 
@@ -15692,6 +15701,7 @@
 
 
 
+
 ###############################################################################
 #
 # Pickup additional source for a component from outside of the source root
@@ -15922,6 +15932,19 @@
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $HOTSPOT_TOPDIR" >&5
 $as_echo "yes with $HOTSPOT_TOPDIR" >&6; }
 fi
+if test "x$with_override_nashorn" != x; then
+    CURDIR="$PWD"
+    cd "$with_override_nashorn"
+    NASHORN_TOPDIR="`pwd`"
+    cd "$CURDIR"
+    if ! test -f $NASHORN_TOPDIR/makefiles/BuildNashorn.gmk; then
+        as_fn_error $? "You have to override nashorn with a full nashorn repo!" "$LINENO" 5
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if nashorn should be overridden" >&5
+$as_echo_n "checking if nashorn should be overridden... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $NASHORN_TOPDIR" >&5
+$as_echo "yes with $NASHORN_TOPDIR" >&6; }
+fi
 if test "x$with_override_jdk" != x; then
     CURDIR="$PWD"
     cd "$with_override_jdk"
@@ -18534,14 +18557,18 @@
 
 ### Locate C compiler (CC)
 
-# gcc is almost always present, but on Windows we
-# prefer cl.exe and on Solaris we prefer CC.
-# Thus test for them in this order.
-if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-  # Do not probe for cc on MacOSX.
-  COMPILER_CHECK_LIST="cl gcc"
-else
-  COMPILER_CHECK_LIST="cl cc gcc"
+# On windows, only cl.exe is supported.
+# On Solaris, cc is preferred to gcc.
+# Elsewhere, gcc is preferred to cc.
+
+if test "x$CC" != x; then
+  COMPILER_CHECK_LIST="$CC"
+elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+  COMPILER_CHECK_LIST="cl"
+elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
+  COMPILER_CHECK_LIST="cc gcc"
+else
+  COMPILER_CHECK_LIST="gcc cc"
 fi
 
 
@@ -19505,7 +19532,7 @@
 $as_echo "$as_me: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&6;}
 
 
-# Now that we have resolved CC ourself, let autoconf have it's go at it
+# Now that we have resolved CC ourself, let autoconf have its go at it
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -20107,12 +20134,16 @@
 
 ### Locate C++ compiler (CXX)
 
-if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-  # Do not probe for CC on MacOSX.
-  COMPILER_CHECK_LIST="cl g++"
-else
-  COMPILER_CHECK_LIST="cl CC g++"
-fi
+if test "x$CXX" != x; then
+  COMPILER_CHECK_LIST="$CXX"
+elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+  COMPILER_CHECK_LIST="cl"
+elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
+  COMPILER_CHECK_LIST="CC g++"
+else
+  COMPILER_CHECK_LIST="g++ CC"
+fi
+
 
   COMPILER_NAME=C++
 
@@ -21074,7 +21105,7 @@
 $as_echo "$as_me: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&6;}
 
 
-# Now that we have resolved CXX ourself, let autoconf have it's go at it
+# Now that we have resolved CXX ourself, let autoconf have its go at it
 ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -29799,7 +29830,7 @@
 _ACEOF
  X11_A_OK=yes
 else
-  X11_A_OK=no
+  X11_A_OK=no; break
 fi
 
 done
@@ -31670,6 +31701,22 @@
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if elliptic curve crypto implementation is present" >&5
+$as_echo_n "checking if elliptic curve crypto implementation is present... " >&6; }
+
+if test -d "${SRC_ROOT}/jdk/src/share/native/sun/security/ec/impl"; then
+    ENABLE_INTREE_EC=yes
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+    ENABLE_INTREE_EC=no
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
 ###############################################################################
 #
 # Configure parts of the build that only affect the build performance,
--- a/common/autoconf/jdk-options.m4	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/autoconf/jdk-options.m4	Wed Jul 05 18:45:29 2017 +0200
@@ -366,6 +366,25 @@
 
 ###############################################################################
 #
+# Enable or disable the elliptic curve crypto implementation
+#
+AC_DEFUN_ONCE([JDKOPT_DETECT_INTREE_EC],
+[
+AC_MSG_CHECKING([if elliptic curve crypto implementation is present])
+
+if test -d "${SRC_ROOT}/jdk/src/share/native/sun/security/ec/impl"; then
+    ENABLE_INTREE_EC=yes
+    AC_MSG_RESULT([yes])
+else
+    ENABLE_INTREE_EC=no
+    AC_MSG_RESULT([no])
+fi
+
+AC_SUBST(ENABLE_INTREE_EC)
+])
+
+###############################################################################
+#
 # Compress jars
 #
 COMPRESS_JARS=false
--- a/common/autoconf/libraries.m4	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/autoconf/libraries.m4	Wed Jul 05 18:45:29 2017 +0200
@@ -182,7 +182,7 @@
 # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
 AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h],
                  [X11_A_OK=yes],
-                 [X11_A_OK=no],
+                 [X11_A_OK=no; break],
                  [ # include <X11/Xlib.h>
                    # include <X11/Xutil.h>
                  ])
--- a/common/autoconf/source-dirs.m4	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/autoconf/source-dirs.m4	Wed Jul 05 18:45:29 2017 +0200
@@ -33,12 +33,14 @@
 JAXP_TOPDIR="$SRC_ROOT/jaxp"
 JAXWS_TOPDIR="$SRC_ROOT/jaxws"
 HOTSPOT_TOPDIR="$SRC_ROOT/hotspot"
+NASHORN_TOPDIR="$SRC_ROOT/nashorn"
 JDK_TOPDIR="$SRC_ROOT/jdk"
 AC_SUBST(LANGTOOLS_TOPDIR)
 AC_SUBST(CORBA_TOPDIR)
 AC_SUBST(JAXP_TOPDIR)
 AC_SUBST(JAXWS_TOPDIR)
 AC_SUBST(HOTSPOT_TOPDIR)
+AC_SUBST(NASHORN_TOPDIR)
 AC_SUBST(JDK_TOPDIR)
 ])
 
@@ -233,7 +235,18 @@
     fi
     AC_MSG_CHECKING([if hotspot should be overridden])
     AC_MSG_RESULT([yes with $HOTSPOT_TOPDIR])
-fi    
+fi
+if test "x$with_override_nashorn" != x; then
+    CURDIR="$PWD"
+    cd "$with_override_nashorn"
+    NASHORN_TOPDIR="`pwd`"
+    cd "$CURDIR"
+    if ! test -f $NASHORN_TOPDIR/makefiles/BuildNashorn.gmk; then
+        AC_MSG_ERROR([You have to override nashorn with a full nashorn repo!])
+    fi
+    AC_MSG_CHECKING([if nashorn should be overridden])
+    AC_MSG_RESULT([yes with $NASHORN_TOPDIR])
+fi
 if test "x$with_override_jdk" != x; then
     CURDIR="$PWD"
     cd "$with_override_jdk"
--- a/common/autoconf/spec.gmk.in	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/autoconf/spec.gmk.in	Wed Jul 05 18:45:29 2017 +0200
@@ -141,6 +141,7 @@
 JAXP_TOPDIR:=@JAXP_TOPDIR@
 JAXWS_TOPDIR:=@JAXWS_TOPDIR@
 HOTSPOT_TOPDIR:=@HOTSPOT_TOPDIR@
+NASHORN_TOPDIR:=@NASHORN_TOPDIR@
 COPYRIGHT_YEAR:=@COPYRIGHT_YEAR@
 
 # Location where build customization files may be found
@@ -230,6 +231,7 @@
 JAXWS_OUTPUTDIR=$(BUILD_OUTPUT)/jaxws
 HOTSPOT_OUTPUTDIR=$(BUILD_OUTPUT)/hotspot
 JDK_OUTPUTDIR=$(BUILD_OUTPUT)/jdk
+NASHORN_OUTPUTDIR=$(BUILD_OUTPUT)/nashorn
 IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images
 JCE_OUTPUTDIR=$(BUILD_OUTPUT)/jce-release
 
@@ -238,6 +240,7 @@
 JAXP_DIST=$(JAXP_OUTPUTDIR)/dist
 JAXWS_DIST=$(JAXWS_OUTPUTDIR)/dist
 HOTSPOT_DIST=@HOTSPOT_DIST@
+NASHORN_DIST=$(NASHORN_OUTPUTDIR)/dist
 
 BUILD_HOTSPOT=@BUILD_HOTSPOT@
 
@@ -536,6 +539,7 @@
 
 # Build setup
 ENABLE_JFR=@ENABLE_JFR@
+ENABLE_INTREE_EC=@ENABLE_INTREE_EC@
 USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@
 USE_EXTERNAL_LIBGIF:=@USE_EXTERNAL_LIBGIF@
 USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@
--- a/common/autoconf/toolchain.m4	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/autoconf/toolchain.m4	Wed Jul 05 18:45:29 2017 +0200
@@ -249,30 +249,38 @@
 
 ### Locate C compiler (CC)
 
-# gcc is almost always present, but on Windows we
-# prefer cl.exe and on Solaris we prefer CC.
-# Thus test for them in this order.
-if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-  # Do not probe for cc on MacOSX.
-  COMPILER_CHECK_LIST="cl gcc"
+# On windows, only cl.exe is supported.
+# On Solaris, cc is preferred to gcc.
+# Elsewhere, gcc is preferred to cc.
+
+if test "x$CC" != x; then
+  COMPILER_CHECK_LIST="$CC"
+elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+  COMPILER_CHECK_LIST="cl"
+elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
+  COMPILER_CHECK_LIST="cc gcc"
 else
-  COMPILER_CHECK_LIST="cl cc gcc"
+  COMPILER_CHECK_LIST="gcc cc"
 fi
 
 TOOLCHAIN_FIND_COMPILER([CC],[C],[$COMPILER_CHECK_LIST])
-# Now that we have resolved CC ourself, let autoconf have it's go at it
+# Now that we have resolved CC ourself, let autoconf have its go at it
 AC_PROG_CC([$CC])
 
 ### Locate C++ compiler (CXX)
 
-if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-  # Do not probe for CC on MacOSX.
-  COMPILER_CHECK_LIST="cl g++"
+if test "x$CXX" != x; then
+  COMPILER_CHECK_LIST="$CXX"
+elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+  COMPILER_CHECK_LIST="cl"
+elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
+  COMPILER_CHECK_LIST="CC g++"
 else
-  COMPILER_CHECK_LIST="cl CC g++"
+  COMPILER_CHECK_LIST="g++ CC"
 fi
+
 TOOLCHAIN_FIND_COMPILER([CXX],[C++],[$COMPILER_CHECK_LIST])
-# Now that we have resolved CXX ourself, let autoconf have it's go at it
+# Now that we have resolved CXX ourself, let autoconf have its go at it
 AC_PROG_CXX([$CXX])
 
 ### Locate other tools
--- a/common/bin/hgforest.sh	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/bin/hgforest.sh	Wed Jul 05 18:45:29 2017 +0200
@@ -96,7 +96,7 @@
 repos=""
 repos_extra=""
 if [ "${command}" = "clone" -o "${command}" = "fclone" ] ; then
-  subrepos="corba jaxp jaxws langtools jdk hotspot"
+  subrepos="corba jaxp jaxws langtools jdk hotspot nashorn"
   if [ -f .hg/hgrc ] ; then
     pull_default=`hg paths default`
     if [ "${pull_default}" = "" ] ; then
--- a/common/makefiles/Main.gmk	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/makefiles/Main.gmk	Wed Jul 05 18:45:29 2017 +0200
@@ -120,6 +120,12 @@
 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk $(JDK_TARGET))
 	@$(call TargetExit)
 
+nashorn: jdk nashorn-only
+nashorn-only: start-make
+	@$(call TargetEnter)
+	@($(CD) $(NASHORN_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildNashorn.gmk)
+	@$(call TargetExit)
+
 demos: jdk demos-only
 demos-only: start-make
 	@$(call TargetEnter)
@@ -128,7 +134,7 @@
 
 # Note: This double-colon rule is intentional, to support
 # custom make file integration.
-images:: source-tips demos images-only
+images:: source-tips demos nashorn images-only
 images-only: start-make
 	@$(call TargetEnter)
 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk images)
@@ -175,9 +181,10 @@
 	@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
 	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(dir $(SPEC))bootcycle-spec.gmk images)
 
-test: start-make
+test: images test-only
+test-only: start-make
 	@$(call TargetEnter)
-	@($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 -k MAKEFLAGS= PRODUCT_HOME=$(OUTPUT_ROOT)/jdk JPRT_JAVA_HOME=$(OUTPUT_ROOT)/jdk ALT_OUTPUTDIR=$(OUTPUT_ROOT) $(TEST)) || true
+	@($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 -k MAKEFLAGS= PRODUCT_HOME=$(JDK_IMAGE_DIR) JPRT_JAVA_HOME=$(JDK_IMAGE_DIR) ALT_OUTPUTDIR=$(OUTPUT_ROOT) $(TEST)) || true
 	@$(call TargetExit)
 
 # Stores the tips for each repository. This file is be used when constructing the jdk image and can be
@@ -190,7 +197,7 @@
 
 
 # Remove everything, except the output from configure.
-clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-overlay-images clean-bootcycle-build clean-docs
+clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-nashorn clean-images clean-overlay-images clean-bootcycle-build clean-docs
 	@($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log* build-trace*.log*)
 	@$(ECHO) Cleaned all build artifacts.
 
@@ -220,6 +227,8 @@
 	$(call CleanComponent,hotspot)
 clean-jdk:
 	$(call CleanComponent,jdk)
+clean-nashorn:
+	$(call CleanComponent,nashorn)
 clean-images:
 	$(call CleanComponent,images)
 clean-overlay-images:
@@ -230,10 +239,10 @@
 	$(call CleanComponent,docs)
 	$(call CleanComponent,docstemp)
 
-.PHONY: langtools corba jaxp jaxws hotspot jdk images overlay-images install
-.PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only
+.PHONY: langtools corba jaxp jaxws hotspot jdk nashorn images overlay-images install
+.PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only nashorn-only images-only overlay-images-only install-only
 .PHONY: all test clean dist-clean bootcycle-images start-make
-.PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-overlay-images clean-bootcycle-build
+.PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-nashorn clean-images clean-overlay-images clean-bootcycle-build
 .PHONY: profiles profiles-only profiles-oscheck
 
 FRC: # Force target
--- a/common/makefiles/MakeBase.gmk	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/makefiles/MakeBase.gmk	Wed Jul 05 18:45:29 2017 +0200
@@ -51,8 +51,9 @@
 		     -e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \
 		     -e 's|X00|X|g' | tr '\n' '$2'
 
+# Subst in an extra $ to prevent it from disappearing.
 define ListPathsSafely_If
-    $(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(wordlist $3,$4,$($1)))))
+    $(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(subst $$,$$$$,$(wordlist $3,$4,$($1))))))
 endef
 
 define ListPathsSafely_Printf
--- a/common/makefiles/javadoc/NON_CORE_PKGS.gmk	Sat Mar 09 21:49:32 2013 +0530
+++ b/common/makefiles/javadoc/NON_CORE_PKGS.gmk	Wed Jul 05 18:45:29 2017 +0200
@@ -80,7 +80,8 @@
 
 TREEAPI_PKGS 	 = com.sun.source.doctree \
 		   com.sun.source.tree \
-		   com.sun.source.util
+		   com.sun.source.util \
+		   jdk
 
 SMARTCARDIO_PKGS = javax.smartcardio
 
@@ -93,6 +94,8 @@
                    com.apple.eio
 endif
 
+JDK_PKGS     = jdk
+
 # non-core packages in rt.jar
 NON_CORE_PKGS    = $(DOMAPI_PKGS) \
                    $(MGMT_PKGS) \
@@ -103,5 +106,5 @@
                    $(HTTPSERVER_PKGS) \
                    $(SMARTCARDIO_PKGS) \
                    $(SCTPAPI_PKGS) \
-                   $(APPLE_EXT_PKGS)
-
+                   $(APPLE_EXT_PKGS) \
+                   $(JDK_PKGS)
--- a/corba/.hgtags	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/.hgtags	Wed Jul 05 18:45:29 2017 +0200
@@ -202,3 +202,4 @@
 27d6368ae8ba570c31c2f0e696d39c99fa2f4538 jdk8-b78
 e41fb1aa0329767b2737303c994e38bede1baa07 jdk8-b79
 5f3d4a6bdd027a1631d97e2dfff63fd5e46987a4 jdk8-b80
+2a00aeeb466b9dee22508f6261f63b70f9c696fe jdk8-b81
--- a/corba/make/com/sun/corba/minclude/com_sun_corba_se_impl_orbutil.jmk	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/make/com/sun/corba/minclude/com_sun_corba_se_impl_orbutil.jmk	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -29,10 +29,6 @@
 	com/sun/corba/se/impl/orbutil/DenseIntMapImpl.java \
 	com/sun/corba/se/impl/orbutil/GetPropertyAction.java \
 	com/sun/corba/se/impl/orbutil/HexOutputStream.java \
-	com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3.java \
-	com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3_1.java \
-	com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3.java \
-	com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3_1.java \
 	com/sun/corba/se/impl/orbutil/LegacyHookGetFields.java \
 	com/sun/corba/se/impl/orbutil/LegacyHookPutFields.java \
 	com/sun/corba/se/impl/orbutil/LogKeywords.java \
@@ -45,19 +41,11 @@
 	com/sun/corba/se/impl/orbutil/ORBUtility.java \
 	com/sun/corba/se/impl/orbutil/ORBClassLoader.java \
 	com/sun/corba/se/impl/orbutil/RepIdDelegator.java \
-	com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3.java \
-	com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3_1.java \
-	com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3.java \
-	com/sun/corba/se/impl/orbutil/RepositoryId_1_3.java \
 	com/sun/corba/se/impl/orbutil/RepositoryIdFactory.java \
 	com/sun/corba/se/impl/orbutil/RepositoryIdStrings.java \
 	com/sun/corba/se/impl/orbutil/RepositoryIdUtility.java \
 	com/sun/corba/se/impl/orbutil/RepositoryIdInterface.java \
-	com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3_1.java \
-	com/sun/corba/se/impl/orbutil/RepositoryId_1_3_1.java \
 	com/sun/corba/se/impl/orbutil/StackImpl.java \
-	com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3_1.java \
-	com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3.java \
 	com/sun/corba/se/impl/orbutil/closure/Future.java \
 	com/sun/corba/se/impl/orbutil/closure/Constant.java \
 	com/sun/corba/se/impl/orbutil/concurrent/Sync.java \
--- a/corba/src/share/classes/com/sun/corba/se/impl/activation/ServerMain.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/activation/ServerMain.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -322,9 +322,9 @@
     com.sun.corba.se.spi.activation._ServerImplBase
 {
     private ORB orb;
-    private Method installMethod ;
-    private Method uninstallMethod ;
-    private Method shutdownMethod ;
+    private transient Method installMethod ;
+    private transient Method uninstallMethod ;
+    private transient Method shutdownMethod ;
     private Object methodArgs[] ;
 
     ServerCallback(ORB orb, Method installMethod, Method uninstallMethod,
--- a/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1218,7 +1218,7 @@
         // See bug 4391648 for more info about the tcORB in this
         // case.
         RepositoryIdStrings repStrs
-            = RepositoryIdFactory.getRepIdStringsFactory(tcORB);
+            = RepositoryIdFactory.getRepIdStringsFactory();
 
 
         // Assertion: c instanceof Serializable?
@@ -1251,7 +1251,7 @@
         // Anything else
         // We know that this is a TypeCodeImpl since it is our ORB
         classTC = (TypeCodeImpl)ValueUtility.createTypeCodeForClass(
-            tcORB, c, ORBUtility.createValueHandler(tcORB));
+            tcORB, c, ORBUtility.createValueHandler());
         // Intruct classTC to store its buffer
         classTC.setCaching(true);
         // Update the cache
--- a/corba/src/share/classes/com/sun/corba/se/impl/corba/TypeCodeImpl.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/corba/TypeCodeImpl.java	Wed Jul 05 18:45:29 2017 +0200
@@ -2189,10 +2189,7 @@
 
                 if (labelIndex == _unionLabels.length) {
                     // check if label has not been found
-                    if (_defaultIndex == -1)
-                        // throw exception if default was not expected
-                        throw wrapper.unexpectedUnionDefault() ;
-                    else
+                    if (_defaultIndex != -1)
                         // must be of the default branch type
                         _memberTypes[_defaultIndex].copy(src, dst);
                 }
--- a/corba/src/share/classes/com/sun/corba/se/impl/encoding/CDRInputStream_1_0.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/encoding/CDRInputStream_1_0.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -269,8 +269,8 @@
 
     private final void createRepositoryIdHandlers()
     {
-        repIdUtil = RepositoryIdFactory.getRepIdUtility(orb);
-        repIdStrs = RepositoryIdFactory.getRepIdStringsFactory(orb);
+        repIdUtil = RepositoryIdFactory.getRepIdUtility();
+        repIdStrs = RepositoryIdFactory.getRepIdStringsFactory();
     }
 
     public GIOPVersion getGIOPVersion() {
@@ -564,10 +564,7 @@
 
         checkForNegativeLength(len);
 
-        if (orb != null && ORBUtility.isLegacyORB((ORB)orb))
-            return legacyReadString(len);
-        else
-            return internalReadString(len);
+        return internalReadString(len);
     }
 
     private final String internalReadString(int len) {
@@ -588,54 +585,6 @@
         return new String(result, 0, getCharConverter().getNumChars());
     }
 
-    private final String legacyReadString(int len) {
-
-        //
-        // Workaround for ORBs which send string lengths of
-        // zero to mean empty string.
-        //
-        //
-        // IMPORTANT: Do not replace 'new String("")' with "", it may result
-        // in a Serialization bug (See serialization.zerolengthstring) and
-        // bug id: 4728756 for details
-        if (len == 0)
-            return new String("");
-
-        len--;
-        char[] c = new char[len];
-
-        int n = 0;
-        while (n < len) {
-            int avail;
-            int bytes;
-            int wanted;
-
-            avail = bbwi.buflen - bbwi.position();
-            if (avail <= 0) {
-                grow(1, 1);
-                avail = bbwi.buflen - bbwi.position();
-            }
-            wanted = len - n;
-            bytes = (wanted < avail) ? wanted : avail;
-            // Microbenchmarks are showing a loop of ByteBuffer.get(int) being
-            // faster than ByteBuffer.get(byte[], int, int).
-            for (int i=0; i<bytes; i++) {
-                c[n+i] = (char) (bbwi.byteBuffer.get(bbwi.position()+i) & 0xFF);
-            }
-            bbwi.position(bbwi.position() + bytes);
-            n += bytes;
-        }
-
-        //
-        // Skip past terminating null byte
-        //
-        if (bbwi.position() + 1 > bbwi.buflen)
-            alignAndCheck(1, 1);
-        bbwi.position(bbwi.position() + 1);
-
-        return new String(c);
-    }
-
     public final String read_string() {
         return readStringOrIndirection(false);
     }
@@ -1045,7 +994,7 @@
 
                 try {
                     if (valueHandler == null)
-                        valueHandler = ORBUtility.createValueHandler(orb);
+                        valueHandler = ORBUtility.createValueHandler();
 
                     value = valueHandler.readValue(parent,
                                                    indirection,
--- a/corba/src/share/classes/com/sun/corba/se/impl/encoding/CDROutputStream_1_0.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/encoding/CDROutputStream_1_0.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -189,18 +189,8 @@
 
     private final void createRepositoryIdHandlers()
     {
-        if (orb != null) {
-            // Get the appropriate versions based on the ORB version.  The
-            // ORB versioning info is only in the core ORB.
-            repIdUtil
-                = RepositoryIdFactory.getRepIdUtility(orb);
-            repIdStrs
-                = RepositoryIdFactory.getRepIdStringsFactory(orb);
-        } else {
-            // Get the latest versions
-            repIdUtil = RepositoryIdFactory.getRepIdUtility();
-            repIdStrs = RepositoryIdFactory.getRepIdStringsFactory();
-        }
+        repIdUtil = RepositoryIdFactory.getRepIdUtility();
+        repIdStrs = RepositoryIdFactory.getRepIdStringsFactory();
     }
 
     public BufferManagerWrite getBufferManager()
@@ -705,7 +695,7 @@
     private void writeArray(Serializable array, Class clazz) {
 
         if (valueHandler == null)
-            valueHandler = ORBUtility.createValueHandler(orb); //d11638
+            valueHandler = ORBUtility.createValueHandler(); //d11638
 
         // Write value_tag
         int indirection = writeValueTag(mustChunk, true,
@@ -768,7 +758,7 @@
 
     private void writeRMIIIOPValueType(Serializable object, Class clazz) {
         if (valueHandler == null)
-            valueHandler = ORBUtility.createValueHandler(orb); //d11638
+            valueHandler = ORBUtility.createValueHandler(); //d11638
 
         Serializable key = object;
 
--- a/corba/src/share/classes/com/sun/corba/se/impl/io/FVDCodeBaseImpl.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/io/FVDCodeBaseImpl.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -86,7 +86,7 @@
             // default to using the current ORB version in case the
             // vhandler is not set
             if (vhandler == null) {
-                vhandler = new ValueHandlerImpl(false);
+                vhandler = ValueHandlerImpl.getInstance(false);
             }
 
             // Util.getCodebase may return null which would
@@ -120,7 +120,7 @@
                 // default to using the current ORB version in case the
                 // vhandler is not set
                 if (vhandler == null) {
-                    vhandler = new ValueHandlerImpl(false);
+                    vhandler = ValueHandlerImpl.getInstance(false);
                 }
 
                 try{
@@ -161,7 +161,7 @@
             // default to using the current ORB version in case the
             // vhandler is not set
             if (vhandler == null) {
-                vhandler = new ValueHandlerImpl(false);
+                vhandler = ValueHandlerImpl.getInstance(false);
             }
 
             Stack repIds = new Stack();
--- a/corba/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 /*
  * Licensed Materials - Property of IBM
  * RMI-IIOP v1.0
- * Copyright IBM Corp. 1998 1999  All Rights Reserved
+ * Copyright IBM Corp. 1998 2012  All Rights Reserved
  *
  */
 
@@ -56,7 +56,6 @@
 
 import java.util.Arrays;
 import java.util.Comparator;
-import java.util.Hashtable;
 
 import com.sun.corba.se.impl.util.RepositoryId;
 
@@ -83,8 +82,6 @@
     private static Object noArgsList[] = {};
     private static Class noTypesList[] = {};
 
-    private static Hashtable translatedFields;
-
     /** true if represents enum type */
     private boolean isEnum;
 
@@ -384,6 +381,42 @@
          */
     }
 
+    private static final class PersistentFieldsValue
+            extends ClassValue<ObjectStreamField[]> {
+        PersistentFieldsValue() { }
+
+        protected ObjectStreamField[] computeValue(Class<?> type) {
+            try {
+                Field pf = type.getDeclaredField("serialPersistentFields");
+                int mods = pf.getModifiers();
+                if (Modifier.isPrivate(mods) && Modifier.isStatic(mods) &&
+                        Modifier.isFinal(mods)) {
+                    pf.setAccessible(true);
+                    java.io.ObjectStreamField[] fields =
+                        (java.io.ObjectStreamField[])pf.get(type);
+                    return translateFields(fields);
+                }
+            } catch (NoSuchFieldException | IllegalAccessException |
+                    IllegalArgumentException | ClassCastException e) {
+            }
+            return null;
+        }
+
+        private static ObjectStreamField[] translateFields(
+            java.io.ObjectStreamField[] fields) {
+            ObjectStreamField[] translation =
+                new ObjectStreamField[fields.length];
+            for (int i = 0; i < fields.length; i++) {
+                translation[i] = new ObjectStreamField(fields[i].getName(),
+                        fields[i].getType());
+            }
+            return translation;
+        }
+    }
+
+    private static final PersistentFieldsValue persistentFieldsValue =
+        new PersistentFieldsValue();
+
     /*
      * Initialize class descriptor.  This method is only invoked on class
      * descriptors created via calls to lookupInternal().  This method is kept
@@ -416,35 +449,7 @@
                  * If it is declared, use the declared serialPersistentFields.
                  * Otherwise, extract the fields from the class itself.
                  */
-                try {
-                    Field pf = cl.getDeclaredField("serialPersistentFields");
-                    // serial bug 7; the serialPersistentFields were not
-                    // being read and stored as Accessible bit was not set
-                    pf.setAccessible(true);
-                    // serial bug 7; need to find if the field is of type
-                    // java.io.ObjectStreamField
-                    java.io.ObjectStreamField[] f =
-                           (java.io.ObjectStreamField[])pf.get(cl);
-                    int mods = pf.getModifiers();
-                    if ((Modifier.isPrivate(mods)) &&
-                        (Modifier.isStatic(mods)) &&
-                        (Modifier.isFinal(mods)))
-                    {
-                        fields = (ObjectStreamField[])translateFields((Object[])pf.get(cl));
-                    }
-                } catch (NoSuchFieldException e) {
-                    fields = null;
-                } catch (IllegalAccessException e) {
-                    fields = null;
-                } catch (IllegalArgumentException e) {
-                    fields = null;
-                } catch (ClassCastException e) {
-                    /* Thrown if a field serialPersistentField exists
-                     * but it is not of type ObjectStreamField.
-                     */
-                    fields = null;
-                }
-
+                    fields = persistentFieldsValue.get(cl);
 
                 if (fields == null) {
                     /* Get all of the declared fields for this
@@ -641,43 +646,6 @@
         superclass = null;
     }
 
-    private static Object[] translateFields(Object objs[])
-        throws NoSuchFieldException {
-        try{
-            java.io.ObjectStreamField fields[] = (java.io.ObjectStreamField[])objs;
-            Object translation[] = null;
-
-            if (translatedFields == null)
-                translatedFields = new Hashtable();
-
-            translation = (Object[])translatedFields.get(fields);
-
-            if (translation != null)
-                return translation;
-            else {
-                Class osfClass = Class.forName("com.sun.corba.se.impl.io.ObjectStreamField");
-                translation = (Object[])java.lang.reflect.Array.newInstance(osfClass, objs.length);
-                Object arg[] = new Object[2];
-                Class types[] = {String.class, Class.class};
-                Constructor constructor = osfClass.getDeclaredConstructor(types);
-                for (int i = fields.length -1; i >= 0; i--){
-                    arg[0] = fields[i].getName();
-                    arg[1] = fields[i].getType();
-
-                    translation[i] = constructor.newInstance(arg);
-                }
-                translatedFields.put(fields, translation);
-
-            }
-
-            return (Object[])translation;
-        }
-        catch(Throwable t){
-            NoSuchFieldException nsfe = new NoSuchFieldException();
-            nsfe.initCause( t ) ;
-            throw nsfe ;
-        }
-    }
 
     /*
      * Set the class this version descriptor matches.
@@ -1555,8 +1523,8 @@
     private boolean hasExternalizableBlockData;
     Method writeObjectMethod;
     Method readObjectMethod;
-    private Method writeReplaceObjectMethod;
-    private Method readResolveObjectMethod;
+    private transient Method writeReplaceObjectMethod;
+    private transient Method readResolveObjectMethod;
     private Constructor cons ;
 
     /**
--- a/corba/src/share/classes/com/sun/corba/se/impl/io/ValueHandlerImpl.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/io/ValueHandlerImpl.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
 import com.sun.corba.se.impl.logging.OMGSystemException;
 import com.sun.corba.se.impl.logging.UtilSystemException;
 
-public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat {
+public final class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat {
 
     // Property to override our maximum stream format version
     public static final String FORMAT_VERSION_PROPERTY
@@ -150,14 +150,22 @@
         writeValueWithVersion(out, value, streamFormatVersion);
     }
 
-    public ValueHandlerImpl(){}
+    private ValueHandlerImpl(){}
 
-    public ValueHandlerImpl(boolean isInputStream) {
+    private ValueHandlerImpl(boolean isInputStream) {
         this();
         useHashtables = false;
         this.isInputStream = isInputStream;
     }
 
+    static ValueHandlerImpl getInstance() {
+        return new ValueHandlerImpl();
+    }
+
+    static ValueHandlerImpl getInstance(boolean isInputStream) {
+        return new ValueHandlerImpl(isInputStream);
+    }
+
     /**
      * Writes the value to the stream using java semantics.
      * @param out The stream to write the value to
@@ -458,12 +466,7 @@
         return ObjectStreamClass.lookup(value.getClass()).writeReplace(value);
     }
 
-    /**
-     * Encapsulates writing of Java char arrays so that the 1.3 subclass
-     * can override it without exposing internals across packages.  This
-     * is a fix for bug 4367783.
-     */
-    protected void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out,
+    private void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out,
                                 char[] array,
                                 int offset,
                                 int length)
@@ -576,12 +579,7 @@
         }
     }
 
-    /**
-     * Encapsulates reading of Java char arrays so that the 1.3 subclass
-     * can override it without exposing internals across packages.  This
-     * is a fix for bug 4367783.
-     */
-    protected void readCharArray(org.omg.CORBA_2_3.portable.InputStream in,
+    private void readCharArray(org.omg.CORBA_2_3.portable.InputStream in,
                                  char[] array,
                                  int offset,
                                  int length)
@@ -795,7 +793,7 @@
         return RepositoryId.cache.getId(repId).isSequence();
     }
 
-    protected String getOutputStreamClassName() {
+    private String getOutputStreamClassName() {
         return "com.sun.corba.se.impl.io.IIOPOutputStream";
     }
 
@@ -843,29 +841,11 @@
     private IIOPOutputStream createOutputStreamBuiltInNoPriv(
         final String name
     ) throws IOException {
-        return
-            name.equals(
-                IIOPOutputStream
-                    .class.getName()
-            ) ?
-            new IIOPOutputStream() :
-
-            name.equals(
-                com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3
-                    .class.getName()
-            ) ?
-            new com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3() :
-
-            name.equals(
-                com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1
-                    .class.getName()
-            ) ?
-            new com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1() :
-
-            null;
+        return name.equals(IIOPOutputStream.class.getName()) ?
+                new IIOPOutputStream() : null;
     }
 
-    protected String getInputStreamClassName() {
+    private String getInputStreamClassName() {
         return "com.sun.corba.se.impl.io.IIOPInputStream";
     }
 
@@ -913,26 +893,8 @@
      private IIOPInputStream createInputStreamBuiltInNoPriv(
          final String name
      ) throws IOException {
-         return
-             name.equals(
-                 IIOPInputStream
-                     .class.getName()
-             ) ?
-             new IIOPInputStream() :
-
-             name.equals(
-                 com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3
-                     .class.getName()
-             ) ?
-             new com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3() :
-
-             name.equals(
-                 com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1
-                     .class.getName()
-             ) ?
-             new com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1() :
-
-             null;
+         return name.equals(IIOPInputStream.class.getName()) ?
+                new IIOPInputStream() : null;
      }
 
      /**
@@ -958,12 +920,7 @@
 
     }
 
-    /**
-     * Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.
-     * The correct behavior is for a Java char to map to a CORBA wchar,
-     * but our older code mapped it to a CORBA char.
-     */
-    protected TCKind getJavaCharTCKind() {
+    TCKind getJavaCharTCKind() {
         return TCKind.tk_wchar;
     }
 }
--- a/corba/src/share/classes/com/sun/corba/se/impl/io/ValueUtility.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/io/ValueUtility.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -93,6 +93,14 @@
         null,       // tk_abstract_interface 32
     };
 
+    static {
+        sun.corba.SharedSecrets.setJavaCorbaAccess(new sun.corba.JavaCorbaAccess() {
+            public ValueHandlerImpl newValueHandlerImpl() {
+                return ValueHandlerImpl.getInstance();
+            }
+        });
+    }
+
     public static String getSignature(ValueMember member)
         throws ClassNotFoundException {
 
--- a/corba/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java	Wed Jul 05 18:45:29 2017 +0200
@@ -112,6 +112,9 @@
 import com.sun.corba.se.impl.orbutil.ORBClassLoader;
 import com.sun.corba.se.impl.logging.UtilSystemException;
 import com.sun.corba.se.spi.logging.CORBALogDomains;
+import sun.corba.SharedSecrets;
+import sun.corba.JavaCorbaAccess;
+
 
 /**
  * Provides utility methods that can be used by stubs and ties to
@@ -125,7 +128,8 @@
     // Maps targets to ties.
     private static IdentityHashtable exportedServants = new IdentityHashtable();
 
-    private static ValueHandlerImpl valueHandlerSingleton = new ValueHandlerImpl();
+    private static final ValueHandlerImpl valueHandlerSingleton =
+        SharedSecrets.getJavaCorbaAccess().newValueHandlerImpl();
 
     private UtilSystemException utilWrapper = UtilSystemException.get(
                                                   CORBALogDomains.RPC_ENCODING);
--- a/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java	Wed Jul 05 18:45:29 2017 +0200
@@ -840,7 +840,7 @@
         // backward compatability 4365188
         CodeBase cb;
 
-        ValueHandler vh = ORBUtility.createValueHandler(this);
+        ValueHandler vh = ORBUtility.createValueHandler();
 
         cb = (CodeBase)vh.getRunTimeCodeBase();
         return ORBUtility.connectAndGetIOR( this, cb ) ;
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.corba.se.impl.orbutil;
-
-import java.io.*;
-import java.util.Hashtable;
-
-/**
- * Implements legacy behavior from before Ladybird to maintain
- * backwards compatibility.
- */
-public class IIOPInputStream_1_3 extends com.sun.corba.se.impl.io.IIOPInputStream
-{
-    // The newer version in the io package correctly reads a wstring instead.
-    // This concerns bug 4379597.
-    protected String internalReadUTF(org.omg.CORBA.portable.InputStream stream)
-    {
-        return stream.read_string();
-    }
-
-    /**
-     * Before JDK 1.3.1_01, the PutField/GetField implementation
-     * actually sent a Hashtable.
-     */
-    public ObjectInputStream.GetField readFields()
-        throws IOException, ClassNotFoundException, NotActiveException {
-        Hashtable fields = (Hashtable)readObject();
-        return new LegacyHookGetFields(fields);
-    }
-
-    public IIOPInputStream_1_3()
-        throws java.io.IOException {
-        super();
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3_1.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- */
-package com.sun.corba.se.impl.orbutil;
-
-import java.io.*;
-import java.util.Hashtable;
-
-/**
- * Implements legacy behavior from Ladybird to maintain
- * backwards compatibility.
- */
-public class IIOPInputStream_1_3_1 extends com.sun.corba.se.impl.io.IIOPInputStream
-{
-    public IIOPInputStream_1_3_1()
-        throws java.io.IOException {
-        super();
-    }
-
-    /**
-     * Before JDK 1.3.1_01, the PutField/GetField implementation
-     * actually sent a Hashtable.
-     */
-    public ObjectInputStream.GetField readFields()
-        throws IOException, ClassNotFoundException, NotActiveException {
-
-        Hashtable fields = (Hashtable)readObject();
-        return new LegacyHookGetFields(fields);
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.corba.se.impl.orbutil;
-
-import java.io.*;
-
-/**
- * Implements legacy behavior from before Ladybird to maintain
- * backwards compatibility.
- */
-public class IIOPOutputStream_1_3 extends com.sun.corba.se.impl.io.IIOPOutputStream
-{
-    // We can't assume that the superclass's putFields
-    // member will be non-private.  We must allow
-    // the RI to run on JDK 1.3.1 FCS as well as
-    // the JDK 1.3.1_01 patch.
-    private ObjectOutputStream.PutField putFields_1_3;
-
-    // The newer version in the io package correctly writes a wstring instead.
-    // This concerns bug 4379597.
-    protected void internalWriteUTF(org.omg.CORBA.portable.OutputStream stream,
-                                    String data)
-    {
-        stream.write_string(data);
-    }
-
-    public IIOPOutputStream_1_3()
-        throws java.io.IOException {
-        super();
-    }
-
-    /**
-     * Before JDK 1.3.1_01, the PutField/GetField implementation
-     * actually sent a Hashtable.
-     */
-    public ObjectOutputStream.PutField putFields()
-        throws IOException {
-        putFields_1_3 = new LegacyHookPutFields();
-        return putFields_1_3;
-    }
-
-    public void writeFields()
-        throws IOException {
-        putFields_1_3.write(this);
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3_1.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- */
-package com.sun.corba.se.impl.orbutil;
-
-import java.io.*;
-import java.util.Hashtable;
-
-/**
- * Implements legacy behavior from Ladybird to maintain
- * backwards compatibility.
- */
-public class IIOPOutputStream_1_3_1 extends com.sun.corba.se.impl.io.IIOPOutputStream
-{
-    // We can't assume that the superclass's putFields
-    // member will be non-private.  We must allow
-    // the RI to run on JDK 1.3.1 FCS as well as
-    // the JDK 1.3.1_01 patch.
-    private ObjectOutputStream.PutField putFields_1_3_1;
-
-    public IIOPOutputStream_1_3_1()
-        throws java.io.IOException {
-        super();
-    }
-
-    /**
-     * Before JDK 1.3.1_01, the PutField/GetField implementation
-     * actually sent a Hashtable.
-     */
-    public ObjectOutputStream.PutField putFields()
-        throws IOException {
-
-        putFields_1_3_1 = new LegacyHookPutFields();
-        return putFields_1_3_1;
-    }
-
-    public void writeFields()
-        throws IOException {
-
-        putFields_1_3_1.write(this);
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -160,45 +160,13 @@
     }
 
     /**
-     * Creates the correct ValueHandler for the given ORB,
-     * querying ORBVersion information.  If the ORB or
-     * ORBVersion is null, gets the ValueHandler from
-     * Util.createValueHandler.
+     * Return default ValueHandler
      */
-    public static ValueHandler createValueHandler(ORB orb) {
-
-        if (orb == null)
-            return Util.createValueHandler();
-
-        ORBVersion version = orb.getORBVersion();
-
-        if (version == null)
-            return Util.createValueHandler();
-
-        if (version.equals(ORBVersionFactory.getOLD()))
-            return new ValueHandlerImpl_1_3();
-        if (version.equals(ORBVersionFactory.getNEW()))
-            return new ValueHandlerImpl_1_3_1();
-
+    public static ValueHandler createValueHandler() {
         return Util.createValueHandler();
     }
 
     /**
-     * Returns true if the given ORB could accurately be determined to be a
-     * Kestrel or earlier ORB.  Note: If passed the ORBSingleton, this will return
-     * false.
-     */
-    public static boolean isLegacyORB(ORB orb)
-    {
-        try {
-            ORBVersion currentORB = orb.getORBVersion();
-            return currentORB.equals( ORBVersionFactory.getOLD() ) ;
-        } catch (SecurityException se) {
-            return false;
-        }
-    }
-
-    /**
      * Returns true if it was accurately determined that the remote ORB is
      * a foreign (non-JavaSoft) ORB.  Note:  If passed the ORBSingleton, this
      * will return false.
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClass_1_3_1.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClass_1_3_1.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1119,8 +1119,8 @@
     private boolean hasExternalizableBlockData;
     Method writeObjectMethod;
     Method readObjectMethod;
-    private Method writeReplaceObjectMethod;
-    private Method readResolveObjectMethod;
+    private transient Method writeReplaceObjectMethod;
+    private transient Method readResolveObjectMethod;
 
     /*
      * ObjectStreamClass_1_3_1 that this one was built from.
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.corba.se.impl.orbutil;
-
-import org.omg.CORBA.ORB;
-import java.io.Serializable;
-import java.util.Hashtable;
-import java.net.MalformedURLException;
-import com.sun.corba.se.impl.io.TypeMismatchException;
-import com.sun.corba.se.impl.util.RepositoryId;
-
-/**
- * Delegates to the RepositoryId_1_3 implementation in
- * com.sun.corba.se.impl.orbutil.  This is necessary to
- * overcome the fact that many of RepositoryId's methods
- * are static.
- */
-public final class RepIdDelegator_1_3
-    implements RepositoryIdStrings,
-               RepositoryIdUtility,
-               RepositoryIdInterface
-{
-    // RepositoryIdFactory methods
-
-    public String createForAnyType(Class type) {
-        return RepositoryId_1_3.createForAnyType(type);
-    }
-
-    public String createForJavaType(Serializable ser)
-        throws TypeMismatchException
-    {
-        return RepositoryId_1_3.createForJavaType(ser);
-    }
-
-    public String createForJavaType(Class clz)
-        throws TypeMismatchException
-    {
-        return RepositoryId_1_3.createForJavaType(clz);
-    }
-
-    public String createSequenceRepID(java.lang.Object ser) {
-        return RepositoryId_1_3.createSequenceRepID(ser);
-    }
-
-    public String createSequenceRepID(Class clazz) {
-        return RepositoryId_1_3.createSequenceRepID(clazz);
-    }
-
-    public RepositoryIdInterface getFromString(String repIdString) {
-        return new RepIdDelegator_1_3(RepositoryId_1_3.cache.getId(repIdString));
-    }
-
-    // RepositoryIdUtility methods
-
-    public boolean isChunkedEncoding(int valueTag) {
-        return RepositoryId.isChunkedEncoding(valueTag);
-    }
-
-    public boolean isCodeBasePresent(int valueTag) {
-        return RepositoryId.isCodeBasePresent(valueTag);
-    }
-
-    public String getClassDescValueRepId() {
-        return RepositoryId_1_3.kClassDescValueRepID;
-    }
-
-    public String getWStringValueRepId() {
-        return RepositoryId_1_3.kWStringValueRepID;
-    }
-
-    public int getTypeInfo(int valueTag) {
-        return RepositoryId.getTypeInfo(valueTag);
-    }
-
-    public int getStandardRMIChunkedNoRepStrId() {
-        return RepositoryId.kPreComputed_StandardRMIChunked_NoRep;
-    }
-
-    public int getCodeBaseRMIChunkedNoRepStrId() {
-        return RepositoryId.kPreComputed_CodeBaseRMIChunked_NoRep;
-    }
-
-    public int getStandardRMIChunkedId() {
-        return RepositoryId.kPreComputed_StandardRMIChunked;
-    }
-
-    public int getCodeBaseRMIChunkedId() {
-        return RepositoryId.kPreComputed_CodeBaseRMIChunked;
-    }
-
-    public int getStandardRMIUnchunkedId() {
-        return RepositoryId.kPreComputed_StandardRMIUnchunked;
-    }
-
-    public int getCodeBaseRMIUnchunkedId() {
-        return RepositoryId.kPreComputed_CodeBaseRMIUnchunked;
-    }
-
-    public int getStandardRMIUnchunkedNoRepStrId() {
-        return RepositoryId.kPreComputed_StandardRMIUnchunked_NoRep;
-    }
-
-    public int getCodeBaseRMIUnchunkedNoRepStrId() {
-        return RepositoryId.kPreComputed_CodeBaseRMIUnchunked_NoRep;
-    }
-
-    // RepositoryIdInterface methods
-
-    public Class getClassFromType() throws ClassNotFoundException {
-        return delegate.getClassFromType();
-    }
-
-    public Class getClassFromType(String codebaseURL)
-        throws ClassNotFoundException, MalformedURLException
-    {
-        return delegate.getClassFromType(codebaseURL);
-    }
-
-    public Class getClassFromType(Class expectedType,
-                                  String codebaseURL)
-        throws ClassNotFoundException, MalformedURLException
-    {
-        return delegate.getClassFromType(expectedType, codebaseURL);
-    }
-
-    public String getClassName() {
-        return delegate.getClassName();
-    }
-
-    // Constructor used for factory/utility cases
-    public RepIdDelegator_1_3() {}
-
-    // Constructor used by getIdFromString.  All non-static
-    // RepositoryId methods will use the provided delegate.
-    private RepIdDelegator_1_3(RepositoryId_1_3 _delegate) {
-        this.delegate = _delegate;
-    }
-
-    private RepositoryId_1_3 delegate = null;
-
-    public String toString() {
-        if (delegate != null)
-            return delegate.toString();
-        else
-            return this.getClass().getName();
-    }
-
-    public boolean equals(Object obj) {
-        if (delegate != null)
-            return delegate.equals(obj);
-        else
-            return super.equals(obj);
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3_1.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.corba.se.impl.orbutil;
-
-import org.omg.CORBA.ORB;
-import java.io.Serializable;
-import java.util.Hashtable;
-import java.net.MalformedURLException;
-import com.sun.corba.se.impl.io.TypeMismatchException;
-import com.sun.corba.se.impl.util.RepositoryId;
-
-/**
- * Delegates to the RepositoryId_1_3_1 implementation in
- * com.sun.corba.se.impl.orbutil.  This is necessary to
- * overcome the fact that many of RepositoryId's methods
- * are static.
- */
-public final class RepIdDelegator_1_3_1
-    implements RepositoryIdStrings,
-               RepositoryIdUtility,
-               RepositoryIdInterface
-{
-    // RepositoryIdFactory methods
-
-    public String createForAnyType(Class type) {
-        return RepositoryId_1_3_1.createForAnyType(type);
-    }
-
-    public String createForJavaType(Serializable ser)
-        throws TypeMismatchException
-    {
-        return RepositoryId_1_3_1.createForJavaType(ser);
-    }
-
-    public String createForJavaType(Class clz)
-        throws TypeMismatchException
-    {
-        return RepositoryId_1_3_1.createForJavaType(clz);
-    }
-
-    public String createSequenceRepID(java.lang.Object ser) {
-        return RepositoryId_1_3_1.createSequenceRepID(ser);
-    }
-
-    public String createSequenceRepID(Class clazz) {
-        return RepositoryId_1_3_1.createSequenceRepID(clazz);
-    }
-
-    public RepositoryIdInterface getFromString(String repIdString) {
-        return new RepIdDelegator_1_3_1(RepositoryId_1_3_1.cache.getId(repIdString));
-    }
-
-    // RepositoryIdUtility methods
-
-    public boolean isChunkedEncoding(int valueTag) {
-        return RepositoryId.isChunkedEncoding(valueTag);
-    }
-
-    public boolean isCodeBasePresent(int valueTag) {
-        return RepositoryId.isCodeBasePresent(valueTag);
-    }
-
-    public String getClassDescValueRepId() {
-        return RepositoryId_1_3_1.kClassDescValueRepID;
-    }
-
-    public String getWStringValueRepId() {
-        return RepositoryId_1_3_1.kWStringValueRepID;
-    }
-
-    public int getTypeInfo(int valueTag) {
-        return RepositoryId.getTypeInfo(valueTag);
-    }
-
-    public int getStandardRMIChunkedNoRepStrId() {
-        return RepositoryId.kPreComputed_StandardRMIChunked_NoRep;
-    }
-
-    public int getCodeBaseRMIChunkedNoRepStrId() {
-        return RepositoryId.kPreComputed_CodeBaseRMIChunked_NoRep;
-    }
-
-    public int getStandardRMIChunkedId() {
-        return RepositoryId.kPreComputed_StandardRMIChunked;
-    }
-
-    public int getCodeBaseRMIChunkedId() {
-        return RepositoryId.kPreComputed_CodeBaseRMIChunked;
-    }
-
-    public int getStandardRMIUnchunkedId() {
-        return RepositoryId.kPreComputed_StandardRMIUnchunked;
-    }
-
-    public int getCodeBaseRMIUnchunkedId() {
-        return RepositoryId.kPreComputed_CodeBaseRMIUnchunked;
-    }
-
-    public int getStandardRMIUnchunkedNoRepStrId() {
-        return RepositoryId.kPreComputed_StandardRMIUnchunked_NoRep;
-    }
-
-    public int getCodeBaseRMIUnchunkedNoRepStrId() {
-        return RepositoryId.kPreComputed_CodeBaseRMIUnchunked_NoRep;
-    }
-
-    // RepositoryIdInterface methods
-
-    public Class getClassFromType() throws ClassNotFoundException {
-        return delegate.getClassFromType();
-    }
-
-    public Class getClassFromType(String codebaseURL)
-        throws ClassNotFoundException, MalformedURLException
-    {
-        return delegate.getClassFromType(codebaseURL);
-    }
-
-    public Class getClassFromType(Class expectedType,
-                                  String codebaseURL)
-        throws ClassNotFoundException, MalformedURLException
-    {
-        return delegate.getClassFromType(expectedType, codebaseURL);
-    }
-
-    public String getClassName() {
-        return delegate.getClassName();
-    }
-
-    // Constructor used for factory/utility cases
-    public RepIdDelegator_1_3_1() {}
-
-    // Constructor used by getIdFromString.  All non-static
-    // RepositoryId methods will use the provided delegate.
-    private RepIdDelegator_1_3_1(RepositoryId_1_3_1 _delegate) {
-        this.delegate = _delegate;
-    }
-
-    private RepositoryId_1_3_1 delegate = null;
-
-    public String toString() {
-        if (delegate != null)
-            return delegate.toString();
-        else
-            return this.getClass().getName();
-    }
-
-    public boolean equals(Object obj) {
-        if (delegate != null)
-            return delegate.equals(obj);
-        else
-            return super.equals(obj);
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-/*
- * Licensed Materials - Property of IBM
- * RMI-IIOP v1.0
- * Copyright IBM Corp. 1998 1999  All Rights Reserved
- *
- */
-
-package com.sun.corba.se.impl.orbutil;
-
-import java.util.Stack;
-import java.util.Hashtable;
-import java.util.EmptyStackException;
-import java.util.Enumeration;
-
-// Really limited pool - in this case just creating several at a time...
-class RepositoryIdPool_1_3 extends Stack {
-
-    private static int MAX_CACHE_SIZE = 4;
-    private RepositoryIdCache_1_3 cache;
-
-    public final synchronized RepositoryId_1_3 popId() {
-
-        try {
-            return (RepositoryId_1_3)super.pop();
-        }
-        catch(EmptyStackException e) {
-            increasePool(5);
-            return (RepositoryId_1_3)super.pop();
-        }
-
-    }
-
-    // Pool management
-    final void increasePool(int size) {
-        //if (cache.size() <= MAX_CACHE_SIZE)
-        for (int i = size; i > 0; i--)
-            push(new RepositoryId_1_3());
-        /*
-          // _REVISIT_ This will not work w/out either thread tracing or weak references.  I am
-          // betting that thread tracing almost completely negates benefit of reuse.  Until either
-          // 1.2 only inclusion or proof to the contrary, I'll leave it this way...
-          else {
-          int numToReclaim = cache.size() / 2;
-          Enumeration keys = cache.keys();
-          Enumeration elements = cache.elements();
-          for (int i = numToReclaim; i > 0; i--) {
-          Object key = keys.nextElement();
-          Object element = elements.nextElement();
-
-          push(element);
-          cache.remove(key);
-          }
-          }
-        */
-    }
-
-    final void setCaches(RepositoryIdCache_1_3 cache) {
-        this.cache = cache;
-    }
-
-}
-
-public class RepositoryIdCache_1_3 extends Hashtable {
-
-    private RepositoryIdPool_1_3 pool = new RepositoryIdPool_1_3();
-
-    public RepositoryIdCache_1_3() {
-        pool.setCaches(this);
-    }
-
-    public final synchronized RepositoryId_1_3 getId(String key) {
-        RepositoryId_1_3 repId = (RepositoryId_1_3)super.get(key);
-
-        if (repId != null)
-            return repId;
-        else {
-            //repId = pool.popId().init(key);
-            repId = new RepositoryId_1_3(key);
-            put(key, repId);
-            return repId;
-        }
-
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3_1.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.corba.se.impl.orbutil;
-
-import java.util.Stack;
-import java.util.Hashtable;
-import java.util.EmptyStackException;
-import java.util.Enumeration;
-
-// Really limited pool - in this case just creating several at a time...
-class RepositoryIdPool_1_3_1 extends Stack {
-
-    private static int MAX_CACHE_SIZE = 4;
-    private RepositoryIdCache_1_3_1 cache;
-
-    public final synchronized RepositoryId_1_3_1 popId() {
-
-        try {
-            return (RepositoryId_1_3_1)super.pop();
-        }
-        catch(EmptyStackException e) {
-            increasePool(5);
-            return (RepositoryId_1_3_1)super.pop();
-        }
-
-    }
-
-    // Pool management
-    final void increasePool(int size) {
-        //if (cache.size() <= MAX_CACHE_SIZE)
-        for (int i = size; i > 0; i--)
-            push(new RepositoryId_1_3_1());
-        /*
-          // _REVISIT_ This will not work w/out either thread tracing or weak references.  I am
-          // betting that thread tracing almost completely negates benefit of reuse.  Until either
-          // 1.2 only inclusion or proof to the contrary, I'll leave it this way...
-          else {
-          int numToReclaim = cache.size() / 2;
-          Enumeration keys = cache.keys();
-          Enumeration elements = cache.elements();
-          for (int i = numToReclaim; i > 0; i--) {
-          Object key = keys.nextElement();
-          Object element = elements.nextElement();
-
-          push(element);
-          cache.remove(key);
-          }
-          }
-        */
-    }
-
-    final void setCaches(RepositoryIdCache_1_3_1 cache) {
-        this.cache = cache;
-    }
-
-}
-
-public class RepositoryIdCache_1_3_1 extends Hashtable {
-
-    private RepositoryIdPool_1_3_1 pool = new RepositoryIdPool_1_3_1();
-
-    public RepositoryIdCache_1_3_1() {
-        pool.setCaches(this);
-    }
-
-    public final synchronized RepositoryId_1_3_1 getId(String key) {
-        RepositoryId_1_3_1 repId = (RepositoryId_1_3_1)super.get(key);
-
-        if (repId != null)
-            return repId;
-        else {
-            //repId = pool.popId().init(key);
-            repId = new RepositoryId_1_3_1(key);
-            put(key, repId);
-            return repId;
-        }
-
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryIdFactory.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryIdFactory.java	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,12 +30,6 @@
 
 public abstract class RepositoryIdFactory
 {
-    private static final RepIdDelegator_1_3 legacyDelegator
-        = new RepIdDelegator_1_3();
-
-    private static final RepIdDelegator_1_3_1 ladybirdDelegator
-        = new RepIdDelegator_1_3_1();
-
     private static final RepIdDelegator currentDelegator
         = new RepIdDelegator();
 
@@ -48,29 +42,6 @@
     }
 
     /**
-     * Checks the version of the ORB and returns the appropriate
-     * RepositoryIdStrings instance.
-     */
-    public static RepositoryIdStrings getRepIdStringsFactory(ORB orb)
-    {
-        if (orb != null) {
-            switch (orb.getORBVersion().getORBType()) {
-                case ORBVersion.NEWER:
-                case ORBVersion.FOREIGN:
-                case ORBVersion.JDK1_3_1_01:
-                    return currentDelegator;
-                case ORBVersion.OLD:
-                    return legacyDelegator;
-                case ORBVersion.NEW:
-                    return ladybirdDelegator;
-                default:
-                    return currentDelegator;
-            }
-        } else
-            return currentDelegator;
-    }
-
-    /**
      * Returns the latest version RepositoryIdUtility instance
      */
     public static RepositoryIdUtility getRepIdUtility()
@@ -78,26 +49,4 @@
         return currentDelegator;
     }
 
-    /**
-     * Checks the version of the ORB and returns the appropriate
-     * RepositoryIdUtility instance.
-     */
-    public static RepositoryIdUtility getRepIdUtility(ORB orb)
-    {
-        if (orb != null) {
-            switch (orb.getORBVersion().getORBType()) {
-                case ORBVersion.NEWER:
-                case ORBVersion.FOREIGN:
-                case ORBVersion.JDK1_3_1_01:
-                    return currentDelegator;
-                case ORBVersion.OLD:
-                    return legacyDelegator;
-                case ORBVersion.NEW:
-                    return ladybirdDelegator;
-                default:
-                    return currentDelegator;
-            }
-        } else
-            return currentDelegator;
-    }
 }
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryId_1_3.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,990 +0,0 @@
-/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-/*
- * Licensed Materials - Property of IBM
- * RMI-IIOP v1.0
- * Copyright IBM Corp. 1998 1999  All Rights Reserved
- *
- */
-
-package com.sun.corba.se.impl.orbutil;
-
-import java.util.StringTokenizer;
-import java.util.Hashtable;
-import java.io.IOException;
-import java.lang.reflect.Method;
-
-// Imports for using codebase URL to load class
-import java.net.MalformedURLException;
-import org.omg.CORBA.portable.ValueBase;
-import org.omg.CORBA.portable.IDLEntity;
-
-import com.sun.corba.se.impl.util.JDKBridge;
-import com.sun.corba.se.impl.util.Utility;
-import com.sun.corba.se.impl.util.PackagePrefixChecker;
-import com.sun.corba.se.impl.util.IdentityHashtable;
-import com.sun.corba.se.impl.io.ObjectStreamClass;
-
-import javax.rmi.CORBA.Util;
-
-// keeping the original RepositoryId class that was shipped in
-// JDK 1.3.  It has interoperability bugs
-
-public class RepositoryId_1_3 {
-
-    // Legal IDL Identifier characters (1 = legal). Note
-    // that '.' (2E) is marked as legal even though it is
-    // not legal in IDL. This allows us to treat a fully
-    // qualified Java name with '.' package separators
-    // uniformly, and is safe because that is the only
-    // legal use of '.' in a Java name.
-
-    public static final RepositoryIdCache_1_3 cache = new RepositoryIdCache_1_3();
-    private static final byte[] IDL_IDENTIFIER_CHARS = {
-
-        // 0 1 2 3  4 5 6 7  8 9 a b  c d e f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 00-0f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 10-1f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,0, // 20-2f
-        1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0, // 30-3f
-        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 40-4f
-        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,1, // 50-5f
-        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 60-6f
-        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0, // 70-7f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 80-8f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 90-9f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // a0-af
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // b0-bf
-        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // c0-cf
-        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // d0-df
-        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // e0-ef
-        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // f0-ff
-    };
-
-    private static String defaultServerURL = null;
-    private static boolean useCodebaseOnly = false;
-
-    static {
-        if (defaultServerURL == null)
-            defaultServerURL = (String)JDKBridge.getLocalCodebase();
-        useCodebaseOnly = JDKBridge.useCodebaseOnly();
-
-    }
-
-    private static IdentityHashtable classToRepStr = new IdentityHashtable();
-    private static IdentityHashtable classIDLToRepStr = new IdentityHashtable();
-    private static IdentityHashtable classSeqToRepStr = new IdentityHashtable();
-
-    private static IdentityHashtable repStrToByteArray = new IdentityHashtable();
-    private static Hashtable repStrToClass = new Hashtable();
-
-    private String repId = null;
-    private boolean isSupportedFormat = true;
-    private String typeString = null;
-    private String versionString = null;
-    private boolean isSequence = false;
-    private boolean isRMIValueType = false;
-    private boolean isIDLType = false;
-    private String completeClassName = null;
-    private String unqualifiedName = null;
-    private String definedInId = null;
-    private Class clazz = null;
-    private String suid = null, actualSuid = null;
-    private long suidLong = ObjectStreamClass.kDefaultUID, actualSuidLong = ObjectStreamClass.kDefaultUID;
-
-    // Repository ID fragments
-    private static final String kValuePrefix = "RMI:";
-    private static final String kIDLPrefix = "IDL:";
-    private static final String kIDLNamePrefix = "omg.org/";
-    private static final String kIDLClassnamePrefix = "org.omg.";
-    private static final String kSequencePrefix = "[";
-    private static final String kCORBAPrefix = "CORBA/";
-    private static final String kArrayPrefix = kValuePrefix + kSequencePrefix + kCORBAPrefix;
-    private static final int kValuePrefixLength = kValuePrefix.length();
-    private static final int kIDLPrefixLength = kIDLPrefix.length();
-    private static final int kSequencePrefixLength = kSequencePrefix.length();
-    private static final String kInterfaceHashCode = ":0000000000000000";
-    private static final String kInterfaceOnlyHashStr = "0000000000000000";
-    private static final String kExternalizableHashStr = "0000000000000001";
-
-    // Value tag utility methods and constants
-    public static final int kInitialValueTag= 0x7fffff00;
-    public static final int kNoTypeInfo = 0;
-    public static final int kSingleRepTypeInfo = 0x02;
-    public static final int  kPartialListTypeInfo = 0x06;
-    public static final int  kChunkedMask = 0x08;
-
-    // Public, well known repository IDs
-
-    // _REVISIT_ : A table structure with a good search routine for all of this
-    // would be more efficient and easier to maintain...
-
-    // String
-    public static final String kWStringValueVersion = "1.0";
-    public static final String kWStringValueHash = ":"+kWStringValueVersion;
-    public static final String kWStringStubValue = "WStringValue";
-    public static final String kWStringTypeStr = "omg.org/CORBA/"+kWStringStubValue;
-    public static final String kWStringValueRepID = kIDLPrefix + kWStringTypeStr + kWStringValueHash;
-
-    // Any
-    public static final String kAnyRepID = kIDLPrefix + "omg.org/CORBA/Any";
-
-    // Class
-    public static final String kClassDescValueHash = ":" + Long.toHexString(
-       ObjectStreamClass.getSerialVersionUID(javax.rmi.CORBA.ClassDesc.class));
-    public static final String kClassDescStubValue = "ClassDesc";
-    public static final String kClassDescTypeStr = "javax.rmi.CORBA."+kClassDescStubValue;
-    public static final String kClassDescValueRepID = kValuePrefix + kClassDescTypeStr + kClassDescValueHash;
-
-    // Object
-    public static final String kObjectValueHash = ":1.0";
-    public static final String kObjectStubValue = "Object";
-
-    // Sequence
-    public static final String kSequenceValueHash = ":1.0";
-    public static final String kPrimitiveSequenceValueHash = ":0000000000000000";
-
-    // Serializable
-    public static final String kSerializableValueHash = ":1.0";
-    public static final String kSerializableStubValue = "Serializable";
-
-    // Externalizable
-    public static final String kExternalizableValueHash = ":1.0";
-    public static final String kExternalizableStubValue = "Externalizable";
-
-    // Remote (The empty string is used for java.rmi.Remote)
-    public static final String kRemoteValueHash = "";
-    public static final String kRemoteStubValue = "";
-    public static final String kRemoteTypeStr = "";
-    public static final String kRemoteValueRepID = "";
-
-    private static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
-
-    static {
-        kSpecialArrayTypeStrings.put("CORBA.WStringValue", new StringBuffer(java.lang.String.class.getName()));
-        kSpecialArrayTypeStrings.put("javax.rmi.CORBA.ClassDesc", new StringBuffer(java.lang.Class.class.getName()));
-        kSpecialArrayTypeStrings.put("CORBA.Object", new StringBuffer(java.rmi.Remote.class.getName()));
-
-    }
-
-    private static final Hashtable kSpecialCasesRepIDs = new Hashtable();
-
-    static {
-        kSpecialCasesRepIDs.put(java.lang.String.class, kWStringValueRepID);
-        kSpecialCasesRepIDs.put(java.lang.Class.class, kClassDescValueRepID);
-        kSpecialCasesRepIDs.put(java.rmi.Remote.class, kRemoteValueRepID);
-    }
-
-    private static final Hashtable kSpecialCasesStubValues = new Hashtable();
-
-    static {
-        kSpecialCasesStubValues.put(java.lang.String.class, kWStringStubValue);
-        kSpecialCasesStubValues.put(java.lang.Class.class, kClassDescStubValue);
-        kSpecialCasesStubValues.put(java.lang.Object.class, kObjectStubValue);
-        kSpecialCasesStubValues.put(java.io.Serializable.class, kSerializableStubValue);
-        kSpecialCasesStubValues.put(java.io.Externalizable.class, kExternalizableStubValue);
-        kSpecialCasesStubValues.put(java.rmi.Remote.class, kRemoteStubValue);
-    }
-
-
-    private static final Hashtable kSpecialCasesVersions = new Hashtable();
-
-    static {
-        kSpecialCasesVersions.put(java.lang.String.class, kWStringValueHash);
-        kSpecialCasesVersions.put(java.lang.Class.class, kClassDescValueHash);
-        kSpecialCasesVersions.put(java.lang.Object.class, kObjectValueHash);
-        kSpecialCasesVersions.put(java.io.Serializable.class, kSerializableValueHash);
-        kSpecialCasesVersions.put(java.io.Externalizable.class, kExternalizableValueHash);
-        kSpecialCasesVersions.put(java.rmi.Remote.class, kRemoteValueHash);
-    }
-
-    private static final Hashtable kSpecialCasesClasses = new Hashtable();
-
-    static {
-        kSpecialCasesClasses.put(kWStringTypeStr, java.lang.String.class);
-        kSpecialCasesClasses.put(kClassDescTypeStr, java.lang.Class.class);
-        kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
-
-        kSpecialCasesClasses.put("org.omg.CORBA.WStringValue", java.lang.String.class);
-        kSpecialCasesClasses.put("javax.rmi.CORBA.ClassDesc", java.lang.Class.class);
-        //kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
-    }
-
-    private static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
-
-    static {
-        kSpecialCasesArrayPrefix.put(java.lang.String.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
-        kSpecialCasesArrayPrefix.put(java.lang.Class.class, kValuePrefix + kSequencePrefix + "javax/rmi/CORBA/");
-        kSpecialCasesArrayPrefix.put(java.lang.Object.class, kValuePrefix + kSequencePrefix + "java/lang/");
-        kSpecialCasesArrayPrefix.put(java.io.Serializable.class, kValuePrefix + kSequencePrefix + "java/io/");
-        kSpecialCasesArrayPrefix.put(java.io.Externalizable.class, kValuePrefix + kSequencePrefix + "java/io/");
-        kSpecialCasesArrayPrefix.put(java.rmi.Remote.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
-    }
-
-    private static final Hashtable kSpecialPrimitives = new Hashtable();
-
-    static {
-        kSpecialPrimitives.put("int","long");
-        kSpecialPrimitives.put("long","longlong");
-        kSpecialPrimitives.put("byte","octet");
-    }
-
-    /**
-     * Used to convert ascii to hex.
-     */
-    private static final byte ASCII_HEX[] =     {
-        (byte)'0',
-        (byte)'1',
-        (byte)'2',
-        (byte)'3',
-        (byte)'4',
-        (byte)'5',
-        (byte)'6',
-        (byte)'7',
-        (byte)'8',
-        (byte)'9',
-        (byte)'A',
-        (byte)'B',
-        (byte)'C',
-        (byte)'D',
-        (byte)'E',
-        (byte)'F',
-    };
-
-
-    // Interface Rep ID Strings
-    public static final String kjava_rmi_Remote = createForAnyType(java.rmi.Remote.class);
-    public static final String korg_omg_CORBA_Object = createForAnyType(org.omg.CORBA.Object.class);
-
-    // Dummy arguments for getIdFromHelper method
-    public static final Class kNoParamTypes[] ={};
-    public static final Object kNoArgs[] = {};
-
-
-    RepositoryId_1_3(){}
-
-    RepositoryId_1_3(String aRepId){
-        init(aRepId);
-    }
-
-    RepositoryId_1_3 init(String aRepId){
-
-        this.repId = aRepId;
-
-        // Special case for remote
-        if (aRepId.length() == 0) {
-            clazz = java.rmi.Remote.class;
-            typeString = "";
-            isRMIValueType = true;
-            suid = kInterfaceOnlyHashStr;
-            return this;
-        }
-        else if (aRepId.equals(kWStringValueRepID)) {
-            clazz = java.lang.String.class;
-            typeString = kWStringTypeStr;
-            isIDLType = true;
-            versionString = kWStringValueVersion;
-            return this;
-        }
-        else {
-
-        String repId = convertFromISOLatin1(aRepId);
-
-        versionString = repId.substring(repId.indexOf(':', repId.indexOf(':')+1));
-        if (repId.startsWith(kIDLPrefix)) {
-            typeString =
-                repId.substring(kIDLPrefixLength, repId.indexOf(':', kIDLPrefixLength));
-            isIDLType = true;
-            if (typeString.startsWith(kIDLNamePrefix))
-                completeClassName = kIDLClassnamePrefix +
-                    typeString.substring(kIDLNamePrefix.length()).replace('/','.');
-            else completeClassName = typeString.replace('/','.');
-
-        }
-        else if (repId.startsWith(kValuePrefix)) {
-            typeString =
-                repId.substring(kValuePrefixLength, repId.indexOf(':', kValuePrefixLength));
-            isRMIValueType = true;
-
-            if (versionString.indexOf('.') == -1) {
-                    actualSuid = versionString.substring(1);
-                    suid = actualSuid;  // default if not explicitly specified
-
-                    if (actualSuid.indexOf(':') != -1){
-                    // we have a declared hash also
-                        int pos = actualSuid.indexOf(':')+1;
-                        // actualSuid = suid.substring(pos);
-                        // suid = suid.substring(0, pos-1);
-                        suid = actualSuid.substring(pos);
-                        actualSuid = actualSuid.substring(0, pos-1);
-                }
-
-            }
-            else {
-                    // _REVISIT_ : Special case version failure ?
-            }
-        }
-        else isSupportedFormat = false;
-
-        if (typeString.startsWith(kSequencePrefix)) {
-            isSequence = true;
-        }
-
-
-        return this;
-    }
-    }
-
-    public final String getUnqualifiedName() {
-        if (unqualifiedName == null){
-            String className = getClassName();
-            int index = (className != null) ? className.lastIndexOf('.') : -1;
-            if (index == -1){
-                unqualifiedName = className;
-                definedInId = "IDL::1.0";
-            }
-            else {
-                unqualifiedName = className.substring(index);
-                definedInId = "IDL:" + className.substring(0, index).replace('.','/') + ":1.0";
-            }
-        }
-
-        return unqualifiedName;
-    }
-
-    public final String getDefinedInId() {
-        if (definedInId == null){
-            getUnqualifiedName();
-        }
-
-        return definedInId;
-    }
-
-    public final String getTypeString() {
-        return typeString;
-    }
-
-    public final String getVersionString() {
-        return versionString;
-    }
-
-    public final String getSerialVersionUID() {
-        return suid;
-    }
-
-    public final String getActualSerialVersionUID() {
-        return actualSuid;
-    }
-    public final long getSerialVersionUIDAsLong() {
-        return suidLong;
-    }
-
-    public final long getActualSerialVersionUIDAsLong() {
-        return actualSuidLong;
-    }
-
-    public final boolean isRMIValueType() {
-        return isRMIValueType;
-    }
-
-    public final boolean isIDLType() {
-        return isIDLType;
-    }
-
-    public final String getRepositoryId() {
-        return repId;
-    }
-
-    public static byte[] getByteArray(String repStr) {
-        synchronized (repStrToByteArray){
-            return (byte[]) repStrToByteArray.get(repStr);
-        }
-    }
-
-    public static void setByteArray(String repStr, byte[] repStrBytes) {
-        synchronized (repStrToByteArray){
-            repStrToByteArray.put(repStr, repStrBytes);
-        }
-    }
-
-    public final boolean isSequence() {
-        return isSequence;
-    }
-
-    public final boolean isSupportedFormat() {
-        return isSupportedFormat;
-    }
-
-
-    // This method will return the classname from the typestring OR if the classname turns out to be
-    // a special class "pseudo" name, then the matching real classname is returned.
-    public final String getClassName() {
-
-        if (isRMIValueType)
-            return typeString;
-        else if (isIDLType)
-            return completeClassName;
-        else return null;
-
-    }
-
-    // This method calls getClazzFromType() and falls back to the repStrToClass
-    // cache if no class was found.  It's used where any class matching the
-    // given repid is an acceptable result.
-    public final Class getAnyClassFromType() throws ClassNotFoundException {
-        try {
-            return getClassFromType();
-        } catch (ClassNotFoundException cnfe) {
-            Class clz = (Class)repStrToClass.get(repId);
-            if (clz != null)
-                return clz;
-            else
-                throw cnfe;
-        }
-    }
-
-    public final Class getClassFromType()
-        throws ClassNotFoundException {
-        if (clazz != null)
-            return clazz;
-
-        Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
-
-        if (specialCase != null){
-            clazz = specialCase;
-            return specialCase;
-        }
-        else
-            {
-                try{
-                    return Util.loadClass(getClassName(), null, null);
-                }
-                catch(ClassNotFoundException cnfe){
-                    if (defaultServerURL != null) {
-                        try{
-                            return getClassFromType(defaultServerURL);
-                        }
-                        catch(MalformedURLException mue){
-                            throw cnfe;
-                        }
-                    }
-                    else throw cnfe;
-                }
-            }
-
-    }
-
-    public final Class getClassFromType(Class expectedType, String codebase)
-        throws ClassNotFoundException {
-        if (clazz != null)
-            return clazz;
-
-        Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
-
-        if (specialCase != null){
-            clazz = specialCase;
-            return specialCase;
-        } else {
-            ClassLoader expectedTypeClassLoader = (expectedType == null ? null : expectedType.getClassLoader());
-            return loadClassOfType(getClassName(),
-                                            codebase,
-                                            expectedTypeClassLoader,
-                                            expectedType,
-                                            expectedTypeClassLoader);
-        }
-
-    }
-
-    public final Class getClassFromType(String url)
-        throws ClassNotFoundException, MalformedURLException {
-        return Util.loadClass(getClassName(), url, null);
-    }
-
-    public final String toString() {
-        return repId;
-    }
-
-    private static String createHashString(java.io.Serializable ser) {
-
-        return createHashString(ser.getClass());
-    }
-
-    private static String createHashString(java.lang.Class clazz) {
-
-        if (clazz.isInterface() || !java.io.Serializable.class.isAssignableFrom(clazz))
-            return kInterfaceHashCode;
-
-
-        long actualLong = ObjectStreamClassUtil_1_3.computeStructuralUID(false, clazz);
-        String hash = null;
-        if (actualLong == 0)
-            hash = kInterfaceOnlyHashStr;
-        else if (actualLong == 1)
-            hash = kExternalizableHashStr;
-        else
-            hash = Long.toHexString(actualLong).toUpperCase();
-        while(hash.length() < 16){
-            hash = "0" + hash;
-        }
-
-        long declaredLong = ObjectStreamClassUtil_1_3.computeSerialVersionUID(clazz);
-        String declared = null;
-        if (declaredLong == 0)
-            declared = kInterfaceOnlyHashStr;
-        else if (declaredLong == 1)
-            declared = kExternalizableHashStr;
-        else
-            declared = Long.toHexString(declaredLong).toUpperCase();
-        while (declared.length() < 16){
-            declared = "0" + declared;
-    }
-        hash = hash + ":" + declared;
-
-        return ":" + hash;
-    }
-
-    /**
-     * Creates a repository ID for a sequence.  This is for expert users only as
-     * this method assumes the object passed is an array.  If passed an object
-     * that is not an array, it will produce a rep id for a sequence of zero
-     * length.  This would be an error.
-     * @param ser The Java object to create a repository ID for
-     **/
-    public static String createSequenceRepID(java.lang.Object ser){
-        return createSequenceRepID(ser.getClass());
-    }
-
-    /**
-     * Creates a repository ID for a sequence.  This is for expert users only as
-     * this method assumes the object passed is an array.  If passed an object
-     * that is not an array, it will produce a malformed rep id.
-     * @param clazz The Java class to create a repository ID for
-     **/
-    public static String createSequenceRepID(java.lang.Class clazz){
-        synchronized (classSeqToRepStr){
-
-        String repid = (String)classSeqToRepStr.get(clazz);
-        if (repid != null)
-            return repid;
-
-        Class originalClazz = clazz;
-
-        Class type = null;
-        int numOfDims = 0;
-
-        while ((type = clazz.getComponentType()) != null) {
-            numOfDims++;
-            clazz = type;
-        }
-
-        if (clazz.isPrimitive())
-            repid = kValuePrefix + originalClazz.getName() + kPrimitiveSequenceValueHash;
-        else {
-            StringBuffer buf = new StringBuffer();
-            buf.append(kValuePrefix);
-            while(numOfDims-- > 0) {
-                buf.append("[");
-            }
-            buf.append("L");
-            buf.append(convertToISOLatin1(clazz.getName()));
-            buf.append(";");
-            buf.append(createHashString(clazz));
-            repid = buf.toString();
-        }
-        classSeqToRepStr.put(originalClazz,repid);
-        return repid;
-        }
-
-    }
-
-
-    public static String createForSpecialCase(java.lang.Class clazz){
-        if (clazz.isArray()){
-            return createSequenceRepID(clazz);
-        }
-        else {
-            return (String)kSpecialCasesRepIDs.get(clazz);
-        }
-    }
-
-    public static String createForSpecialCase(java.io.Serializable ser){
-        Class clazz = ser.getClass();
-        if (clazz.isArray()){
-            return createSequenceRepID(ser);
-        }
-        else
-            return createForSpecialCase(clazz);
-    }
-
-    /**
-     * Creates a repository ID for a normal Java Type.
-     * @param ser The Java object to create a repository ID for
-     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
-     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
-     **/
-    public static String createForJavaType(java.io.Serializable ser)
-        throws com.sun.corba.se.impl.io.TypeMismatchException
-    {
-        synchronized (classToRepStr) {
-        String repid = createForSpecialCase(ser);
-        if (repid != null)
-            return repid;
-        Class clazz = ser.getClass();
-        repid = (String)classToRepStr.get(clazz);
-
-        if (repid != null)
-            return repid;
-
-        repid = kValuePrefix + convertToISOLatin1(clazz.getName()) +
-            createHashString(clazz);
-
-        classToRepStr.put(clazz, repid);
-            repStrToClass.put(repid, clazz);
-        return repid;
-    }
-    }
-
-    /**
-     * Creates a repository ID for a normal Java Type.
-     * @param clz The Java class to create a repository ID for
-     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
-     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
-     **/
-    public static String createForJavaType(Class clz)
-        throws com.sun.corba.se.impl.io.TypeMismatchException
-    {
-        synchronized (classToRepStr){
-        String repid = createForSpecialCase(clz);
-        if (repid != null)
-            return repid;
-
-        repid = (String)classToRepStr.get(clz);
-        if (repid != null)
-            return repid;
-
-        repid = kValuePrefix + convertToISOLatin1(clz.getName()) +
-            createHashString(clz);
-
-        classToRepStr.put(clz, repid);
-            repStrToClass.put(repid, clz);
-        return repid;
-    }
-    }
-
-    /**
-     * Creates a repository ID for an IDL Java Type.
-     * @param ser The IDL Value object to create a repository ID for
-     * @param major The major version number
-     * @param minor The minor version number
-     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser does not implement the
-     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
-     **/
-    public static String createForIDLType(Class ser, int major, int minor)
-        throws com.sun.corba.se.impl.io.TypeMismatchException
-    {
-        synchronized (classIDLToRepStr){
-        String repid = (String)classIDLToRepStr.get(ser);
-        if (repid != null)
-            return repid;
-
-        repid = kIDLPrefix + convertToISOLatin1(ser.getName()).replace('.','/') +
-            ":" + major + "." + minor;
-        classIDLToRepStr.put(ser, repid);
-        return repid;
-    }
-    }
-
-    private static String getIdFromHelper(Class clazz){
-        try {
-            Class helperClazz = Utility.loadClassForClass(clazz.getName()+"Helper", null,
-                                    clazz.getClassLoader(), clazz, clazz.getClassLoader());
-            Method idMethod = helperClazz.getDeclaredMethod("id", kNoParamTypes);
-            return (String)idMethod.invoke(null, kNoArgs);
-        }
-        catch(java.lang.ClassNotFoundException cnfe)
-            {
-                throw new org.omg.CORBA.MARSHAL(cnfe.toString());
-            }
-        catch(java.lang.NoSuchMethodException nsme)
-            {
-                throw new org.omg.CORBA.MARSHAL(nsme.toString());
-            }
-        catch(java.lang.reflect.InvocationTargetException ite)
-            {
-                throw new org.omg.CORBA.MARSHAL(ite.toString());
-            }
-        catch(java.lang.IllegalAccessException iae)
-            {
-                throw new org.omg.CORBA.MARSHAL(iae.toString());
-    }
-    }
-
-    /**
-     * Createa a repository ID for the type if it is either a java type
-     * or an IDL type.
-     * @param type The type to create rep. id for
-     * @return The rep. id.
-     **/
-    public static String createForAnyType(Class type) {
-        try{
-            if (type.isArray())
-                return createSequenceRepID(type);
-            else if (IDLEntity.class.isAssignableFrom(type))
-                {
-                    try{
-                        return getIdFromHelper(type);
-                    }
-                    catch(Throwable t) {
-                        return createForIDLType(type, 1, 0);
-                    }
-                }
-            else return createForJavaType(type);
-        }
-        catch(com.sun.corba.se.impl.io.TypeMismatchException e){
-            return null;
-        }
-
-    }
-
-    public static boolean isAbstractBase(Class clazz) {
-        return (clazz.isInterface() &&
-                IDLEntity.class.isAssignableFrom(clazz) &&
-                (!ValueBase.class.isAssignableFrom(clazz)) &&
-                (!org.omg.CORBA.Object.class.isAssignableFrom(clazz)));
-
-    }
-
-    /**
-     * Convert strings with illegal IDL identifier characters.
-     * <p>
-     * Section 5.5.7 of OBV spec.
-     */
-    private static String convertToISOLatin1 (String name) {
-
-        int length = name.length();
-        if (length == 0) {
-            return name;
-        }
-        StringBuffer buffer = null;
-
-        for (int i = 0; i < length; i++) {
-
-            char c = name.charAt(i);
-
-            if (c > 255 || IDL_IDENTIFIER_CHARS[c] == 0) {
-
-                // We gotta convert. Have we already started?
-
-                if (buffer == null) {
-
-                    // No, so get set up...
-
-                    buffer = new StringBuffer(name.substring(0,i));
-                }
-
-                // Convert the character into the IDL escape syntax...
-                buffer.append(
-                              "\\U" +
-                              (char)ASCII_HEX[(c & 0xF000) >>> 12] +
-                              (char)ASCII_HEX[(c & 0x0F00) >>> 8] +
-                              (char)ASCII_HEX[(c & 0x00F0) >>> 4] +
-                              (char)ASCII_HEX[(c & 0x000F)]);
-
-            } else {
-                if (buffer != null) {
-                    buffer.append(c);
-                }
-            }
-        }
-
-        if (buffer != null) {
-            name = buffer.toString();
-        }
-
-        return name;
-    }
-
-    /**
-     * Convert strings with ISO Latin 1 escape sequences back to original strings.
-     * <p>
-     * Section 5.5.7 of OBV spec.
-     */
-    private static String convertFromISOLatin1 (String name) {
-
-        int index = -1;
-        StringBuffer buf = new StringBuffer(name);
-
-        while ((index = buf.toString().indexOf("\\U")) != -1){
-            String str = "0000" + buf.toString().substring(index+2, index+6);
-
-            // Convert Hexadecimal
-            byte[] buffer = new byte[(str.length() - 4) / 2];
-            for (int i=4, j=0; i < str.length(); i +=2, j++) {
-                buffer[j] = (byte)((ORBUtility.hexOf(str.charAt(i)) << 4) & 0xF0);
-                buffer[j] |= (byte)((ORBUtility.hexOf(str.charAt(i+1)) << 0) & 0x0F);
-            }
-            buf = new StringBuffer(delete(buf.toString(), index, index+6));
-            buf.insert(index, (char)buffer[1]);
-        }
-
-        return buf.toString();
-
-
-    }
-
-    private static String delete(String str, int from, int to)
-    {
-        return str.substring(0, from) + str.substring(to, str.length());
-    }
-
-    private static String replace(String target, String arg, String source)
-    {
-        int i = 0;
-        i = target.indexOf(arg);
-
-        while(i != -1)
-            {
-                String left = target.substring(0, i);
-                String right = target.substring(i+arg.length());
-                target = new String(left+source+right);
-                i = target.indexOf(arg);
-            }
-        return target;
-    }
-
-    /*
-     * Load a class and check that it is assignable to a given type.
-     * @param className the class name.
-     * @param remoteCodebase the codebase to use. May be null.
-     * @param loader the class loader of last resort. May be null.
-     * @param expectedType the expected type. May be null.
-     * @return the loaded class.
-     */
-    private Class loadClassOfType (String className,
-                                  String remoteCodebase,
-                                  ClassLoader loader,
-                                  Class expectedType,
-                                  ClassLoader expectedTypeClassLoader)
-        throws ClassNotFoundException {
-
-        Class loadedClass = null;
-
-        try {
-            //Sequence finding of the stubs according to spec
-            try{
-                //If-else is put here for speed up of J2EE.
-                //According to the OMG spec, the if clause is not dead code.
-                //It can occur if some compiler has allowed generation
-                //into org.omg.stub hierarchy for non-offending
-                //classes. This will encourage people to
-                //produce non-offending class stubs in their own hierarchy.
-                if(!PackagePrefixChecker
-                   .hasOffendingPrefix(PackagePrefixChecker
-                                       .withoutPackagePrefix(className))){
-                    loadedClass = Util.loadClass
-                        (PackagePrefixChecker.withoutPackagePrefix(className),
-                         remoteCodebase,
-                         loader);
-                } else {
-                    loadedClass = Util.loadClass
-                        (className,
-                         remoteCodebase,
-                         loader);
-                }
-            } catch (ClassNotFoundException cnfe) {
-                loadedClass = Util.loadClass
-                    (className,
-                     remoteCodebase,
-                     loader);
-            }
-            if (expectedType == null)
-                return loadedClass;
-        } catch (ClassNotFoundException cnfe) {
-            if (expectedType == null)
-                throw cnfe;
-        }
-
-        // If no class was not loaded, or if the loaded class is not of the
-        // correct type, make a further attempt to load the correct class
-        // using the classloader of the expected type.
-        // _REVISIT_ Is this step necessary, or should the Util,loadClass
-        // algorithm always produce a valid class if the setup is correct?
-        // Does the OMG standard algorithm need to be changed to include
-        // this step?
-        if (loadedClass == null || !expectedType.isAssignableFrom(loadedClass)) {
-            if (expectedType.getClassLoader() != expectedTypeClassLoader)
-                throw new IllegalArgumentException("expectedTypeClassLoader not class loader of expectedType.");
-
-            if (expectedTypeClassLoader != null)
-                loadedClass = expectedTypeClassLoader.loadClass(className);
-            else
-                loadedClass = ORBClassLoader.loadClass(className);
-        }
-
-        return loadedClass;
-    }
-
-    /**
-     * Checks to see if the FullValueDescription should be retrieved.
-     * @exception Throws IOException if suids do not match or if the repositoryID
-     * is not an RMIValueType
-     */
-    public static boolean useFullValueDescription(Class clazz, String repositoryID)
-        throws IOException{
-
-        String clazzRepIDStr = createForAnyType(clazz);
-
-        if (clazzRepIDStr.equals(repositoryID))
-            return false;
-
-        RepositoryId_1_3 targetRepid;
-        RepositoryId_1_3 clazzRepid;
-
-        synchronized(cache) {
-        // to avoid race condition where multiple threads could be
-        // accessing this method, and their access to the cache may
-        // be interleaved giving unexpected results
-
-            targetRepid = cache.getId(repositoryID);
-            clazzRepid = cache.getId(clazzRepIDStr);
-        }
-
-        if ((targetRepid.isRMIValueType()) && (clazzRepid.isRMIValueType())){
-            if (!targetRepid.getSerialVersionUID().equals(clazzRepid.getSerialVersionUID())) {
-
-                String mssg = "Mismatched serialization UIDs : Source (Rep. ID" +
-                    clazzRepid + ") = " +
-                    clazzRepid.getSerialVersionUID() + " whereas Target (Rep. ID " + repositoryID +
-                    ") = " + targetRepid.getSerialVersionUID();
-                throw new IOException(mssg);
-            } else {
-                return true;
-            }
-        } else {
-
-            throw new IOException("The repository ID is not of an RMI value type (Expected ID = " + clazzRepIDStr + "; Received ID = " + repositoryID +")");
-        }
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryId_1_3_1.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1065 +0,0 @@
-/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- */
-package com.sun.corba.se.impl.orbutil;
-
-import java.util.StringTokenizer;
-import java.util.Hashtable;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import org.omg.CORBA.portable.ValueBase;
-import org.omg.CORBA.portable.IDLEntity;
-
-//d11638 files in the same package, therefore remove their reference
-//import com.sun.corba.se.impl.util.JDKBridge;
-//import com.sun.corba.se.impl.util.IdentityHashtable;
-import com.sun.corba.se.impl.util.JDKBridge;
-import com.sun.corba.se.impl.util.Utility;
-import com.sun.corba.se.impl.util.PackagePrefixChecker;
-import com.sun.corba.se.impl.util.IdentityHashtable;
-
-import javax.rmi.CORBA.Util;
-
-/**
- * Because all methods in RepositoryId are static, we have
- * to duplicate all of this code, freezing it in its 1.3.1
- * form for backwards compatibility.
- *
- * For security reasons, we can't expose enough of
- * io/ObjectStreamClass, so it has to be duplicated in
- * orbutil.
- */
-public class RepositoryId_1_3_1 {
-
-    // Legal IDL Identifier characters (1 = legal). Note
-    // that '.' (2E) is marked as legal even though it is
-    // not legal in IDL. This allows us to treat a fully
-    // qualified Java name with '.' package separators
-    // uniformly, and is safe because that is the only
-    // legal use of '.' in a Java name.
-
-    private static final byte[] IDL_IDENTIFIER_CHARS = {
-
-        // 0 1 2 3  4 5 6 7  8 9 a b  c d e f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 00-0f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 10-1f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,0, // 20-2f
-        1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0, // 30-3f
-        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 40-4f
-        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,1, // 50-5f
-        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 60-6f
-        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0, // 70-7f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 80-8f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 90-9f
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // a0-af
-        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // b0-bf
-        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // c0-cf
-        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // d0-df
-        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // e0-ef
-        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // f0-ff
-    };
-
-
-    private static final long serialVersionUID = 123456789L;
-
-    private static String defaultServerURL = null;
-    private static boolean useCodebaseOnly = false;
-
-    static {
-        if (defaultServerURL == null)
-            defaultServerURL = (String)JDKBridge.getLocalCodebase();
-        useCodebaseOnly = JDKBridge.useCodebaseOnly();
-
-    }
-
-    private static IdentityHashtable classToRepStr = new IdentityHashtable();
-    private static IdentityHashtable classIDLToRepStr = new IdentityHashtable();
-    private static IdentityHashtable classSeqToRepStr = new IdentityHashtable();
-
-    private static IdentityHashtable repStrToByteArray = new IdentityHashtable();
-    private static Hashtable repStrToClass = new Hashtable();
-
-    private String repId = null;
-    private boolean isSupportedFormat = true;
-    private String typeString = null;
-    private String versionString = null;
-    private boolean isSequence = false;
-    private boolean isRMIValueType = false;
-    private boolean isIDLType = false;
-    private String completeClassName = null;
-    private String unqualifiedName = null;
-    private String definedInId = null;
-    private Class clazz = null;
-    private String suid = null, actualSuid = null;
-    private long suidLong = ObjectStreamClass_1_3_1.kDefaultUID, actualSuidLong = ObjectStreamClass_1_3_1.kDefaultUID;
-
-    // Repository ID fragments
-    private static final String kSequenceKeyword = "seq";
-    private static final String kValuePrefix = "RMI:";
-    private static final String kIDLPrefix = "IDL:";
-    private static final String kIDLNamePrefix = "omg.org/";
-    private static final String kIDLClassnamePrefix = "org.omg.";
-    private static final String kSequencePrefix = "[";
-    private static final String kCORBAPrefix = "CORBA/";
-    private static final String kArrayPrefix = kValuePrefix + kSequencePrefix + kCORBAPrefix;
-    private static final int kValuePrefixLength = kValuePrefix.length();
-    private static final int kIDLPrefixLength = kIDLPrefix.length();
-    private static final int kSequencePrefixLength = kSequencePrefix.length();
-    private static final String kInterfaceHashCode = ":0000000000000000";
-    private static final String kInterfaceOnlyHashStr = "0000000000000000";
-    private static final String kExternalizableHashStr = "0000000000000001";
-
-    // Value tag utility methods and constants
-    public static final int kInitialValueTag= 0x7fffff00;
-    public static final int kNoTypeInfo = 0;
-    public static final int kSingleRepTypeInfo = 0x02;
-    public static final int  kPartialListTypeInfo = 0x06;
-    public static final int  kChunkedMask = 0x08;
-    public static final int kPreComputed_StandardRMIUnchunked = RepositoryId_1_3_1.computeValueTag(false, RepositoryId_1_3_1.kSingleRepTypeInfo, false);
-    public static final int kPreComputed_CodeBaseRMIUnchunked = RepositoryId_1_3_1.computeValueTag(true, RepositoryId_1_3_1.kSingleRepTypeInfo, false);
-    public static final int kPreComputed_StandardRMIChunked = RepositoryId_1_3_1.computeValueTag(false, RepositoryId_1_3_1.kSingleRepTypeInfo, true);
-    public static final int kPreComputed_CodeBaseRMIChunked = RepositoryId_1_3_1.computeValueTag(true, RepositoryId_1_3_1.kSingleRepTypeInfo, true);
-
-    public static final int kPreComputed_StandardRMIUnchunked_NoRep = RepositoryId_1_3_1.computeValueTag(false, RepositoryId_1_3_1.kNoTypeInfo, false);
-    public static final int kPreComputed_CodeBaseRMIUnchunked_NoRep = RepositoryId_1_3_1.computeValueTag(true, RepositoryId_1_3_1.kNoTypeInfo, false);
-    public static final int kPreComputed_StandardRMIChunked_NoRep = RepositoryId_1_3_1.computeValueTag(false, RepositoryId_1_3_1.kNoTypeInfo, true);
-    public static final int kPreComputed_CodeBaseRMIChunked_NoRep = RepositoryId_1_3_1.computeValueTag(true, RepositoryId_1_3_1.kNoTypeInfo, true);
-
-    // Public, well known repository IDs
-
-    // _REVISIT_ : A table structure with a good search routine for all of this
-    // would be more efficient and easier to maintain...
-
-    // String
-    public static final String kWStringValueVersion = "1.0";
-    public static final String kWStringValueHash = ":"+kWStringValueVersion;
-    public static final String kWStringStubValue = "WStringValue";
-    public static final String kWStringTypeStr = "omg.org/CORBA/"+kWStringStubValue;
-    public static final String kWStringValueRepID = kIDLPrefix + kWStringTypeStr + kWStringValueHash;
-
-    // Any
-    public static final String kAnyRepID = kIDLPrefix + "omg.org/CORBA/Any";
-
-    // Class
-    // Anita4: convert to uppercase
-    public static final String kClassDescValueHash = ":" +
-       Long.toHexString(
-       ObjectStreamClass_1_3_1.getActualSerialVersionUID(javax.rmi.CORBA.ClassDesc.class)).toUpperCase() + ":" +
-      Long.toHexString(
-       ObjectStreamClass_1_3_1.getSerialVersionUID(javax.rmi.CORBA.ClassDesc.class)).toUpperCase();
-    public static final String kClassDescStubValue = "ClassDesc";
-    public static final String kClassDescTypeStr = "javax.rmi.CORBA."+kClassDescStubValue;
-    public static final String kClassDescValueRepID = kValuePrefix + kClassDescTypeStr + kClassDescValueHash;
-
-    // Object
-    public static final String kObjectValueHash = ":1.0";
-    public static final String kObjectStubValue = "Object";
-
-    // Sequence
-    public static final String kSequenceValueHash = ":1.0";
-    public static final String kPrimitiveSequenceValueHash = ":0000000000000000";
-
-    // Serializable
-    public static final String kSerializableValueHash = ":1.0";
-    public static final String kSerializableStubValue = "Serializable";
-
-    // Externalizable
-    public static final String kExternalizableValueHash = ":1.0";
-    public static final String kExternalizableStubValue = "Externalizable";
-
-    // Remote (The empty string is used for java.rmi.Remote)
-    public static final String kRemoteValueHash = "";
-    public static final String kRemoteStubValue = "";
-    public static final String kRemoteTypeStr = "";
-    public static final String kRemoteValueRepID = "";
-
-    private static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
-
-    static {
-        kSpecialArrayTypeStrings.put("CORBA.WStringValue", new StringBuffer(java.lang.String.class.getName()));
-        kSpecialArrayTypeStrings.put("javax.rmi.CORBA.ClassDesc", new StringBuffer(java.lang.Class.class.getName()));
-        kSpecialArrayTypeStrings.put("CORBA.Object", new StringBuffer(java.rmi.Remote.class.getName()));
-
-    }
-
-    private static final Hashtable kSpecialCasesRepIDs = new Hashtable();
-
-    static {
-        kSpecialCasesRepIDs.put(java.lang.String.class, kWStringValueRepID);
-        kSpecialCasesRepIDs.put(java.lang.Class.class, kClassDescValueRepID);
-        kSpecialCasesRepIDs.put(java.rmi.Remote.class, kRemoteValueRepID);
-    }
-
-    private static final Hashtable kSpecialCasesStubValues = new Hashtable();
-
-    static {
-        kSpecialCasesStubValues.put(java.lang.String.class, kWStringStubValue);
-        kSpecialCasesStubValues.put(java.lang.Class.class, kClassDescStubValue);
-        kSpecialCasesStubValues.put(java.lang.Object.class, kObjectStubValue);
-        kSpecialCasesStubValues.put(java.io.Serializable.class, kSerializableStubValue);
-        kSpecialCasesStubValues.put(java.io.Externalizable.class, kExternalizableStubValue);
-        kSpecialCasesStubValues.put(java.rmi.Remote.class, kRemoteStubValue);
-    }
-
-
-    private static final Hashtable kSpecialCasesVersions = new Hashtable();
-
-    static {
-        kSpecialCasesVersions.put(java.lang.String.class, kWStringValueHash);
-        kSpecialCasesVersions.put(java.lang.Class.class, kClassDescValueHash);
-        kSpecialCasesVersions.put(java.lang.Object.class, kObjectValueHash);
-        kSpecialCasesVersions.put(java.io.Serializable.class, kSerializableValueHash);
-        kSpecialCasesVersions.put(java.io.Externalizable.class, kExternalizableValueHash);
-        kSpecialCasesVersions.put(java.rmi.Remote.class, kRemoteValueHash);
-    }
-
-    private static final Hashtable kSpecialCasesClasses = new Hashtable();
-
-    static {
-        kSpecialCasesClasses.put(kWStringTypeStr, java.lang.String.class);
-        kSpecialCasesClasses.put(kClassDescTypeStr, java.lang.Class.class);
-        kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
-
-        kSpecialCasesClasses.put("org.omg.CORBA.WStringValue", java.lang.String.class);
-        kSpecialCasesClasses.put("javax.rmi.CORBA.ClassDesc", java.lang.Class.class);
-        //kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
-    }
-
-    private static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
-
-    static {
-        kSpecialCasesArrayPrefix.put(java.lang.String.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
-        kSpecialCasesArrayPrefix.put(java.lang.Class.class, kValuePrefix + kSequencePrefix + "javax/rmi/CORBA/");
-        kSpecialCasesArrayPrefix.put(java.lang.Object.class, kValuePrefix + kSequencePrefix + "java/lang/");
-        kSpecialCasesArrayPrefix.put(java.io.Serializable.class, kValuePrefix + kSequencePrefix + "java/io/");
-        kSpecialCasesArrayPrefix.put(java.io.Externalizable.class, kValuePrefix + kSequencePrefix + "java/io/");
-        kSpecialCasesArrayPrefix.put(java.rmi.Remote.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
-    }
-
-    private static final Hashtable kSpecialPrimitives = new Hashtable();
-
-    static {
-        kSpecialPrimitives.put("int","long");
-        kSpecialPrimitives.put("long","longlong");
-        kSpecialPrimitives.put("byte","octet");
-    }
-
-    /**
-     * Used to convert ascii to hex.
-     */
-    private static final byte ASCII_HEX[] =     {
-        (byte)'0',
-        (byte)'1',
-        (byte)'2',
-        (byte)'3',
-        (byte)'4',
-        (byte)'5',
-        (byte)'6',
-        (byte)'7',
-        (byte)'8',
-        (byte)'9',
-        (byte)'A',
-        (byte)'B',
-        (byte)'C',
-        (byte)'D',
-        (byte)'E',
-        (byte)'F',
-    };
-
-
-    // bug fix for 4328952; to eliminate possibility of overriding this
-    // in a subclass.
-    public static final RepositoryIdCache_1_3_1 cache = new RepositoryIdCache_1_3_1();
-
-    // Interface Rep ID Strings
-    public static final String kjava_rmi_Remote = createForAnyType(java.rmi.Remote.class);
-    public static final String korg_omg_CORBA_Object = createForAnyType(org.omg.CORBA.Object.class);
-
-    // Dummy arguments for getIdFromHelper method
-    public static final Class kNoParamTypes[] ={};
-    public static final Object kNoArgs[] = {};
-
-
-    // To create a RepositoryID, use code similar to the following:
-    // RepositoryId.cache.getId( id );
-
-    RepositoryId_1_3_1(){}
-
-    RepositoryId_1_3_1(String aRepId){
-        init(aRepId);
-    }
-
-    RepositoryId_1_3_1 init(String aRepId){
-
-        this.repId = aRepId;
-
-        // Special case for remote
-        if (aRepId.length() == 0) {
-            clazz = java.rmi.Remote.class;
-            typeString = "";
-            isRMIValueType = true;
-            suid = kInterfaceOnlyHashStr;
-            return this;
-        }
-        else if (aRepId.equals(kWStringValueRepID)) {
-            clazz = java.lang.String.class;
-            typeString = kWStringTypeStr;
-            isIDLType = true;
-            // fix where Attempting to obtain a FullValueDescription
-            // for an RMI value type with a String field causes an exception.
-            completeClassName = "java.lang.String";
-            versionString = kWStringValueVersion;
-            return this;
-        }
-        else {
-
-        String repId = convertFromISOLatin1(aRepId);
-
-        versionString = repId.substring(repId.indexOf(':', repId.indexOf(':')+1));
-        if (repId.startsWith(kIDLPrefix)) {
-            typeString =
-                repId.substring(kIDLPrefixLength, repId.indexOf(':', kIDLPrefixLength));
-            isIDLType = true;
-            if (typeString.startsWith(kIDLNamePrefix))
-                completeClassName = kIDLClassnamePrefix +
-                    typeString.substring(kIDLNamePrefix.length()).replace('/','.');
-            else completeClassName = typeString.replace('/','.');
-
-        }
-        else if (repId.startsWith(kValuePrefix)) {
-            typeString =
-                repId.substring(kValuePrefixLength, repId.indexOf(':', kValuePrefixLength));
-            isRMIValueType = true;
-
-            if (versionString.indexOf('.') == -1) {
-                    actualSuid = versionString.substring(1);
-                    suid = actualSuid;  // default if not explicitly specified
-
-                    if (actualSuid.indexOf(':') != -1){
-                    // we have a declared hash also
-                        int pos = actualSuid.indexOf(':')+1;
-                        // actualSuid = suid.substring(pos);
-                        // suid = suid.substring(0, pos-1);
-                        suid = actualSuid.substring(pos);
-                        actualSuid = actualSuid.substring(0, pos-1);
-                }
-
-            }
-            else {
-                    // _REVISIT_ : Special case version failure ?
-            }
-        }
-        else isSupportedFormat = false;
-
-        if (typeString.startsWith(kSequencePrefix)) {
-            isSequence = true;
-        }
-
-
-        return this;
-    }
-    }
-
-    public final String getUnqualifiedName() {
-        if (unqualifiedName == null){
-            String className = getClassName();
-            int index = className.lastIndexOf('.');
-            if (index == -1){
-                unqualifiedName = className;
-                definedInId = "IDL::1.0";
-            }
-            else {
-                unqualifiedName = className.substring(index);
-                definedInId = "IDL:" + className.substring(0, index).replace('.','/') + ":1.0";
-            }
-        }
-
-        return unqualifiedName;
-    }
-
-    public final String getDefinedInId() {
-        if (definedInId == null){
-            getUnqualifiedName();
-        }
-
-        return definedInId;
-    }
-
-    public final String getTypeString() {
-        return typeString;
-    }
-
-    public final String getVersionString() {
-        return versionString;
-    }
-
-    public final String getSerialVersionUID() {
-        return suid;
-    }
-
-    public final String getActualSerialVersionUID() {
-        return actualSuid;
-    }
-    public final long getSerialVersionUIDAsLong() {
-        return suidLong;
-    }
-
-    public final long getActualSerialVersionUIDAsLong() {
-        return actualSuidLong;
-    }
-
-    public final boolean isRMIValueType() {
-        return isRMIValueType;
-    }
-
-    public final boolean isIDLType() {
-        return isIDLType;
-    }
-
-    public final String getRepositoryId() {
-        return repId;
-    }
-
-    public static byte[] getByteArray(String repStr) {
-        synchronized (repStrToByteArray){
-            return (byte[]) repStrToByteArray.get(repStr);
-        }
-    }
-
-    public static void setByteArray(String repStr, byte[] repStrBytes) {
-        synchronized (repStrToByteArray){
-            repStrToByteArray.put(repStr, repStrBytes);
-        }
-    }
-
-    public final boolean isSequence() {
-        return isSequence;
-    }
-
-    public final boolean isSupportedFormat() {
-        return isSupportedFormat;
-    }
-
-
-    // This method will return the classname from the typestring OR if the classname turns out to be
-    // a special class "pseudo" name, then the matching real classname is returned.
-    public final String getClassName() {
-
-        if (isRMIValueType)
-            return typeString;
-        else if (isIDLType)
-            return completeClassName;
-        else return null;
-
-    }
-
-    // This method calls getClazzFromType() and falls back to the repStrToClass
-    // cache if no class was found.  It's used where any class matching the
-    // given repid is an acceptable result.
-    public final Class getAnyClassFromType() throws ClassNotFoundException {
-        try {
-            return getClassFromType();
-        } catch (ClassNotFoundException cnfe) {
-            Class clz = (Class)repStrToClass.get(repId);
-            if (clz != null)
-                return clz;
-            else
-                throw cnfe;
-        }
-    }
-
-    public final Class getClassFromType()
-        throws ClassNotFoundException {
-        if (clazz != null)
-            return clazz;
-
-        Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
-
-        if (specialCase != null){
-            clazz = specialCase;
-            return specialCase;
-        }
-        else
-            {
-                try{
-                    return Util.loadClass(getClassName(), null, null);
-                }
-                catch(ClassNotFoundException cnfe){
-                    if (defaultServerURL != null) {
-                        try{
-                            return getClassFromType(defaultServerURL);
-                        }
-                        catch(MalformedURLException mue){
-                            throw cnfe;
-                        }
-                    }
-                    else throw cnfe;
-                }
-            }
-
-    }
-
-    public final Class getClassFromType(Class expectedType, String codebase)
-        throws ClassNotFoundException {
-        if (clazz != null)
-            return clazz;
-
-        Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
-
-        if (specialCase != null){
-            clazz = specialCase;
-            return specialCase;
-        } else {
-            ClassLoader expectedTypeClassLoader = (expectedType == null ? null : expectedType.getClassLoader());
-            return loadClassOfType(getClassName(),
-                                   codebase,
-                                   expectedTypeClassLoader,
-                                   expectedType,
-                                   expectedTypeClassLoader);
-        }
-
-    }
-
-    public final Class getClassFromType(String url)
-        throws ClassNotFoundException, MalformedURLException {
-        return Util.loadClass(getClassName(), url, null);
-    }
-
-    public final String toString() {
-        return repId;
-    }
-
-    /**
-     * Checks to see if the FullValueDescription should be retrieved.
-     * @exception Throws IOException if suids do not match or if the repositoryID
-     * is not an RMIValueType
-     */
-    public static boolean useFullValueDescription(Class clazz, String repositoryID)
-        throws IOException{
-
-        String clazzRepIDStr = createForAnyType(clazz);
-
-        if (clazzRepIDStr.equals(repositoryID))
-            return false;
-
-        RepositoryId_1_3_1 targetRepid;
-        RepositoryId_1_3_1 clazzRepid;
-
-        synchronized(cache) {
-        // to avoid race condition where multiple threads could be
-        // accessing this method, and their access to the cache may
-        // be interleaved giving unexpected results
-
-            targetRepid = cache.getId(repositoryID);
-            clazzRepid = cache.getId(clazzRepIDStr);
-        }
-        //ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
-
-        if ((targetRepid.isRMIValueType()) && (clazzRepid.isRMIValueType())){
-            if (!targetRepid.getSerialVersionUID().equals(clazzRepid.getSerialVersionUID())) {
-
-                String mssg = "Mismatched serialization UIDs : Source (Rep. ID" +
-                    clazzRepid + ") = " +
-                    clazzRepid.getSerialVersionUID() + " whereas Target (Rep. ID " + repositoryID +
-                    ") = " + targetRepid.getSerialVersionUID();
-                                //com.sun.corba.se.impl.io.ValueUtility.log("RepositoryId",mssg);
-                throw new IOException(mssg);
-        }
-            else {
-                return true;
-            }
-        }
-        else {
-
-            throw new IOException("The repository ID is not of an RMI value type (Expected ID = " + clazzRepIDStr + "; Received ID = " + repositoryID +")");
-    }
-    }
-
-    private static String createHashString(java.io.Serializable ser) {
-
-        return createHashString(ser.getClass());
-    }
-
-    private static String createHashString(java.lang.Class clazz) {
-
-        if (clazz.isInterface() || !java.io.Serializable.class.isAssignableFrom(clazz))
-            return kInterfaceHashCode;
-
-        //ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
-
-        long actualLong = ObjectStreamClass_1_3_1.getActualSerialVersionUID(clazz);
-        String hash = null;
-        if (actualLong == 0)
-            hash = kInterfaceOnlyHashStr;
-        else if (actualLong == 1)
-            hash = kExternalizableHashStr;
-        else
-            hash = Long.toHexString(actualLong).toUpperCase();
-        while(hash.length() < 16){
-            hash = "0" + hash;
-        }
-
-        long declaredLong = ObjectStreamClass_1_3_1.getSerialVersionUID(clazz);
-        String declared = null;
-        if (declaredLong == 0)
-            declared = kInterfaceOnlyHashStr;
-        else if (declaredLong == 1)
-            declared = kExternalizableHashStr;
-        else
-            declared = Long.toHexString(declaredLong).toUpperCase();
-        while (declared.length() < 16){
-            declared = "0" + declared;
-    }
-        hash = hash + ":" + declared;
-
-        return ":" + hash;
-    }
-
-    /**
-     * Creates a repository ID for a sequence.  This is for expert users only as
-     * this method assumes the object passed is an array.  If passed an object
-     * that is not an array, it will produce a rep id for a sequence of zero
-     * length.  This would be an error.
-     * @param ser The Java object to create a repository ID for
-     **/
-    public static String createSequenceRepID(java.lang.Object ser){
-        return createSequenceRepID(ser.getClass());
-    }
-
-    /**
-     * Creates a repository ID for a sequence.  This is for expert users only as
-     * this method assumes the object passed is an array.  If passed an object
-     * that is not an array, it will produce a malformed rep id.
-     * @param clazz The Java class to create a repository ID for
-     **/
-    public static String createSequenceRepID(java.lang.Class clazz){
-        synchronized (classSeqToRepStr){
-
-        String repid = (String)classSeqToRepStr.get(clazz);
-        if (repid != null)
-            return repid;
-
-        Class originalClazz = clazz;
-
-        Class type = null;
-        int numOfDims = 0;
-
-        while ((type = clazz.getComponentType()) != null) {
-            numOfDims++;
-            clazz = type;
-        }
-
-        if (clazz.isPrimitive())
-            repid = kValuePrefix + originalClazz.getName() + kPrimitiveSequenceValueHash;
-        else {
-            StringBuffer buf = new StringBuffer();
-            buf.append(kValuePrefix);
-            while(numOfDims-- > 0) {
-                buf.append("[");
-            }
-            buf.append("L");
-            buf.append(convertToISOLatin1(clazz.getName()));
-            buf.append(";");
-            buf.append(createHashString(clazz));
-            repid = buf.toString();
-        }
-        classSeqToRepStr.put(originalClazz,repid);
-        return repid;
-        }
-
-    }
-
-
-    public static String createForSpecialCase(java.lang.Class clazz){
-        if (clazz.isArray()){
-            return createSequenceRepID(clazz);
-        }
-        else {
-            return (String)kSpecialCasesRepIDs.get(clazz);
-        }
-    }
-
-    public static String createForSpecialCase(java.io.Serializable ser){
-        Class clazz = ser.getClass();
-        if (clazz.isArray()){
-            return createSequenceRepID(ser);
-        }
-        else
-            return createForSpecialCase(clazz);
-    }
-
-    /**
-     * Creates a repository ID for a normal Java Type.
-     * @param ser The Java object to create a repository ID for
-     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
-     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
-     **/
-    public static String createForJavaType(java.io.Serializable ser)
-        throws com.sun.corba.se.impl.io.TypeMismatchException
-    {
-        synchronized (classToRepStr) {
-        String repid = createForSpecialCase(ser);
-        if (repid != null)
-            return repid;
-        Class clazz = ser.getClass();
-        repid = (String)classToRepStr.get(clazz);
-
-        if (repid != null)
-            return repid;
-
-        repid = kValuePrefix + convertToISOLatin1(clazz.getName()) +
-            createHashString(clazz);
-
-        classToRepStr.put(clazz, repid);
-            repStrToClass.put(repid, clazz);
-        return repid;
-    }
-    }
-
-    /**
-     * Creates a repository ID for a normal Java Type.
-     * @param clz The Java class to create a repository ID for
-     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
-     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
-     **/
-    public static String createForJavaType(Class clz)
-        throws com.sun.corba.se.impl.io.TypeMismatchException
-    {
-        synchronized (classToRepStr){
-        String repid = createForSpecialCase(clz);
-        if (repid != null)
-            return repid;
-
-        repid = (String)classToRepStr.get(clz);
-        if (repid != null)
-            return repid;
-
-        repid = kValuePrefix + convertToISOLatin1(clz.getName()) +
-            createHashString(clz);
-
-        classToRepStr.put(clz, repid);
-            repStrToClass.put(repid, clz);
-        return repid;
-    }
-    }
-
-    /**
-     * Creates a repository ID for an IDL Java Type.
-     * @param ser The IDL Value object to create a repository ID for
-     * @param major The major version number
-     * @param minor The minor version number
-     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser does not implement the
-     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
-     **/
-    public static String createForIDLType(Class ser, int major, int minor)
-        throws com.sun.corba.se.impl.io.TypeMismatchException
-    {
-        synchronized (classIDLToRepStr){
-        String repid = (String)classIDLToRepStr.get(ser);
-        if (repid != null)
-            return repid;
-
-        repid = kIDLPrefix + convertToISOLatin1(ser.getName()).replace('.','/') +
-            ":" + major + "." + minor;
-        classIDLToRepStr.put(ser, repid);
-        return repid;
-    }
-    }
-
-    private static String getIdFromHelper(Class clazz){
-        try {
-            Class helperClazz = Utility.loadClassForClass(clazz.getName()+"Helper", null,
-                                    clazz.getClassLoader(), clazz, clazz.getClassLoader());
-            Method idMethod = helperClazz.getDeclaredMethod("id", kNoParamTypes);
-            return (String)idMethod.invoke(null, kNoArgs);
-        }
-        catch(java.lang.ClassNotFoundException cnfe)
-            {
-                throw new org.omg.CORBA.MARSHAL(cnfe.toString());
-            }
-        catch(java.lang.NoSuchMethodException nsme)
-            {
-                throw new org.omg.CORBA.MARSHAL(nsme.toString());
-            }
-        catch(java.lang.reflect.InvocationTargetException ite)
-            {
-                throw new org.omg.CORBA.MARSHAL(ite.toString());
-            }
-        catch(java.lang.IllegalAccessException iae)
-            {
-                throw new org.omg.CORBA.MARSHAL(iae.toString());
-    }
-    }
-
-    /**
-     * Createa a repository ID for the type if it is either a java type
-     * or an IDL type.
-     * @param type The type to create rep. id for
-     * @return The rep. id.
-     **/
-    public static String createForAnyType(Class type) {
-        try{
-            if (type.isArray())
-                return createSequenceRepID(type);
-            else if (IDLEntity.class.isAssignableFrom(type))
-                {
-                    try{
-                        return getIdFromHelper(type);
-                    }
-                    catch(Throwable t) {
-                        return createForIDLType(type, 1, 0);
-                    }
-                }
-            else return createForJavaType(type);
-        }
-        catch(com.sun.corba.se.impl.io.TypeMismatchException e){
-            return null;
-        }
-
-    }
-
-    public static boolean isAbstractBase(Class clazz) {
-        return (clazz.isInterface() &&
-                IDLEntity.class.isAssignableFrom(clazz) &&
-                (!ValueBase.class.isAssignableFrom(clazz)) &&
-                (!org.omg.CORBA.Object.class.isAssignableFrom(clazz)));
-
-    }
-
-    public static boolean isAnyRequired(Class clazz) {
-        return ((clazz == java.lang.Object.class) ||
-                (clazz == java.io.Serializable.class) ||
-                (clazz == java.io.Externalizable.class));
-    }
-
-    public static long fromHex(String hexNumber) {
-        if (hexNumber.startsWith("0x"))
-            return Long.valueOf(hexNumber.substring(2), 16).longValue();
-        else return Long.valueOf(hexNumber, 16).longValue();
-    }
-
-    /**
-     * Convert strings with illegal IDL identifier characters.
-     * <p>
-     * Section 5.5.7 of OBV spec.
-     */
-    private static String convertToISOLatin1 (String name) {
-
-        int length = name.length();
-        if (length == 0) {
-            return name;
-        }
-        StringBuffer buffer = null;
-
-        for (int i = 0; i < length; i++) {
-
-            char c = name.charAt(i);
-
-            if (c > 255 || IDL_IDENTIFIER_CHARS[c] == 0) {
-
-                // We gotta convert. Have we already started?
-
-                if (buffer == null) {
-
-                    // No, so get set up...
-
-                    buffer = new StringBuffer(name.substring(0,i));
-                }
-
-                // Convert the character into the IDL escape syntax...
-                buffer.append(
-                              "\\U" +
-                              (char)ASCII_HEX[(c & 0xF000) >>> 12] +
-                              (char)ASCII_HEX[(c & 0x0F00) >>> 8] +
-                              (char)ASCII_HEX[(c & 0x00F0) >>> 4] +
-                              (char)ASCII_HEX[(c & 0x000F)]);
-
-            } else {
-                if (buffer != null) {
-                    buffer.append(c);
-                }
-            }
-        }
-
-        if (buffer != null) {
-            name = buffer.toString();
-        }
-
-        return name;
-    }
-
-    /**
-     * Convert strings with ISO Latin 1 escape sequences back to original strings.
-     * <p>
-     * Section 5.5.7 of OBV spec.
-     */
-    private static String convertFromISOLatin1 (String name) {
-
-        int index = -1;
-        StringBuffer buf = new StringBuffer(name);
-
-        while ((index = buf.toString().indexOf("\\U")) != -1){
-            String str = "0000" + buf.toString().substring(index+2, index+6);
-
-            // Convert Hexadecimal
-            byte[] buffer = new byte[(str.length() - 4) / 2];
-            for (int i=4, j=0; i < str.length(); i +=2, j++) {
-                buffer[j] = (byte)((ORBUtility.hexOf(str.charAt(i)) << 4) & 0xF0);
-                buffer[j] |= (byte)((ORBUtility.hexOf(str.charAt(i+1)) << 0) & 0x0F);
-            }
-            buf = new StringBuffer(delete(buf.toString(), index, index+6));
-            buf.insert(index, (char)buffer[1]);
-        }
-
-        return buf.toString();
-
-
-    }
-
-    private static String delete(String str, int from, int to)
-    {
-        return str.substring(0, from) + str.substring(to, str.length());
-    }
-
-    private static String replace(String target, String arg, String source)
-    {
-        int i = 0;
-        i = target.indexOf(arg);
-
-        while(i != -1)
-            {
-                String left = target.substring(0, i);
-                String right = target.substring(i+arg.length());
-                target = new String(left+source+right);
-                i = target.indexOf(arg);
-            }
-        return target;
-    }
-
-    public static int computeValueTag(boolean codeBasePresent, int typeInfo, boolean chunkedEncoding){
-        int value_tag = kInitialValueTag;
-
-        if (codeBasePresent)
-            value_tag = value_tag | 0x00000001;
-
-        value_tag = value_tag | typeInfo;
-
-        if (chunkedEncoding)
-            value_tag = value_tag | kChunkedMask;
-
-        return value_tag;
-    }
-
-    public static boolean isCodeBasePresent(int value_tag){
-        return ((value_tag & 0x00000001) == 1);
-    }
-
-    public static int getTypeInfo(int value_tag){
-        return (value_tag & 0x00000006);
-    }
-
-    public static boolean isChunkedEncoding(int value_tag){
-        return ((value_tag & kChunkedMask) != 0);
-    }
-
-    public static String getServerURL(){
-        return defaultServerURL;
-    }
-
-    /*
-     * Load a class and check that it is assignable to a given type.
-     * @param className the class name.
-     * @param remoteCodebase the codebase to use. May be null.
-     * @param loader the class loader of last resort. May be null.
-     * @param expectedType the expected type. May be null.
-     * @return the loaded class.
-     */
-    private Class loadClassOfType (String className,
-                                  String remoteCodebase,
-                                  ClassLoader loader,
-                                  Class expectedType,
-                                  ClassLoader expectedTypeClassLoader)
-        throws ClassNotFoundException {
-
-        Class loadedClass = null;
-
-        try {
-            //Sequence finding of the stubs according to spec
-            try{
-                //If-else is put here for speed up of J2EE.
-                //According to the OMG spec, the if clause is not dead code.
-                //It can occur if some compiler has allowed generation
-                //into org.omg.stub hierarchy for non-offending
-                //classes. This will encourage people to
-                //produce non-offending class stubs in their own hierarchy.
-                if(!PackagePrefixChecker
-                   .hasOffendingPrefix(PackagePrefixChecker
-                                       .withoutPackagePrefix(className))){
-                    loadedClass = Util.loadClass
-                        (PackagePrefixChecker.withoutPackagePrefix(className),
-                         remoteCodebase,
-                         loader);
-                } else {
-                    loadedClass = Util.loadClass
-                        (className,
-                         remoteCodebase,
-                         loader);
-                }
-            } catch (ClassNotFoundException cnfe) {
-                loadedClass = Util.loadClass
-                    (className,
-                     remoteCodebase,
-                     loader);
-            }
-            if (expectedType == null)
-                return loadedClass;
-        } catch (ClassNotFoundException cnfe) {
-            if (expectedType == null)
-                throw cnfe;
-        }
-
-        // If no class was not loaded, or if the loaded class is not of the
-        // correct type, make a further attempt to load the correct class
-        // using the classloader of the expected type.
-        // _REVISIT_ Is this step necessary, or should the Util,loadClass
-        // algorithm always produce a valid class if the setup is correct?
-        // Does the OMG standard algorithm need to be changed to include
-        // this step?
-        if (loadedClass == null || !expectedType.isAssignableFrom(loadedClass)) {
-            if (expectedType.getClassLoader() != expectedTypeClassLoader)
-                throw new IllegalArgumentException("expectedTypeClassLoader not class loader of expectedType.");
-
-            if (expectedTypeClassLoader != null)
-                loadedClass = expectedTypeClassLoader.loadClass(className);
-            else
-                loadedClass = Class.forName(className);
-        }
-
-        return loadedClass;
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-/*
- * Licensed Materials - Property of IBM
- * RMI-IIOP v1.0
- * Copyright IBM Corp. 1998 1999  All Rights Reserved
- *
- */
-
-package com.sun.corba.se.impl.orbutil;
-
-import javax.rmi.CORBA.Util;
-import javax.rmi.PortableRemoteObject;
-
-import java.util.Hashtable;
-import java.util.Stack;
-import java.io.IOException;
-import java.util.EmptyStackException;
-
-import com.sun.corba.se.impl.util.Utility;
-import com.sun.corba.se.impl.io.IIOPInputStream;
-import com.sun.corba.se.impl.io.IIOPOutputStream;
-import com.sun.corba.se.impl.util.RepositoryId;
-import com.sun.corba.se.impl.util.Utility;
-
-import org.omg.CORBA.TCKind;
-import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.CompletionStatus;
-import org.omg.CORBA.portable.IndirectionException;
-import com.sun.org.omg.SendingContext.CodeBase;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * This class overrides behavior of our current ValueHandlerImpl to
- * provide backwards compatibility with JDK 1.3.0.
- */
-public class ValueHandlerImpl_1_3 extends com.sun.corba.se.impl.io.ValueHandlerImpl {
-
-    public ValueHandlerImpl_1_3(){
-        super();
-    }
-
-    public ValueHandlerImpl_1_3(boolean isInputStream) {
-        super(isInputStream);
-    }
-
-    /**
-     * Writes the value to the stream using java semantics.
-     * @param out The stream to write the value to
-     * @param value The value to be written to the stream
-     **/
-    public void writeValue(org.omg.CORBA.portable.OutputStream _out, java.io.Serializable value) {
-        super.writeValue(_out, value);
-    }
-
-    /**
-     * Reads a value from the stream using java semantics.
-     * @param in The stream to read the value from
-     * @param clazz The type of the value to be read in
-     * @param sender The sending context runtime
-     **/
-    public java.io.Serializable readValue(org.omg.CORBA.portable.InputStream _in,
-                                          int offset,
-                                          java.lang.Class clazz,
-                                          String repositoryID,
-                                          org.omg.SendingContext.RunTime _sender)
-    {
-        return super.readValue(_in, offset, clazz, repositoryID, _sender);
-    }
-
-    /**
-     * Returns the repository ID for the given RMI value Class.
-     * @param clz The class to return a repository ID for.
-     * @return the repository ID of the Class.
-     **/
-    public java.lang.String getRMIRepositoryID(java.lang.Class clz) {
-        return RepositoryId_1_3.createForJavaType(clz);
-    }
-
-    /**
-     * Indicates whether the given Class performs custom or
-     * default marshaling.
-     * @param clz The class to test for custom marshaling.
-     * @return True if the class performs custom marshaling, false
-     * if it does not.
-     **/
-    public boolean isCustomMarshaled(java.lang.Class clz) {
-        return super.isCustomMarshaled(clz);
-    }
-
-    /**
-     * Returns the CodeBase for this ValueHandler.  This is used by
-     * the ORB runtime.  The server sends the service context containing
-     * the IOR for this CodeBase on the first GIOP reply.  The clients
-     * do the same on the first GIOP request.
-     * @return the SendingContext.CodeBase of this ValueHandler.
-     **/
-    public org.omg.SendingContext.RunTime getRunTimeCodeBase() {
-        return super.getRunTimeCodeBase();
-    }
-
-    /**
-     * If the value contains a writeReplace method then the result
-     * is returned.  Otherwise, the value itself is returned.
-     * @return the true value to marshal on the wire.
-     **/
-    public java.io.Serializable writeReplace(java.io.Serializable value) {
-        return super.writeReplace(value);
-    }
-
-    // methods supported for backward compatability so that the appropriate
-    // Rep-id calculations take place based on the ORB version
-
-    /**
-     *  Returns a boolean of whether or not RepositoryId indicates
-     *  FullValueDescriptor.
-     *  used for backward compatability
-     */
-
-     public boolean useFullValueDescription(Class clazz, String repositoryID)
-        throws IOException
-
-     {
-        return RepositoryId_1_3.useFullValueDescription(clazz, repositoryID);
-     }
-
-     public String getClassName(String id)
-     {
-        RepositoryId_1_3 repID = RepositoryId_1_3.cache.getId(id);
-        return repID.getClassName();
-     }
-
-     public Class getClassFromType(String id)
-        throws ClassNotFoundException
-     {
-        RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
-        return repId.getClassFromType();
-     }
-
-     public Class getAnyClassFromType(String id)
-        throws ClassNotFoundException
-     {
-        RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
-        return repId.getAnyClassFromType();
-     }
-
-     public String createForAnyType(Class cl)
-     {
-        return RepositoryId_1_3.createForAnyType(cl);
-     }
-
-     public String getDefinedInId(String id)
-     {
-        RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
-        return repId.getDefinedInId();
-     }
-
-     public String getUnqualifiedName(String id)
-     {
-        RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
-        return repId.getUnqualifiedName();
-     }
-
-     public String getSerialVersionUID(String id)
-     {
-        RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
-        return repId.getSerialVersionUID();
-     }
-
-     public boolean isAbstractBase(Class clazz)
-     {
-        return RepositoryId_1_3.isAbstractBase(clazz);
-     }
-
-     public boolean isSequence(String id)
-     {
-        RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
-        return repId.isSequence();
-     }
-
-    /**
-     * Preserves the incorrect 1.3 behavior which truncates Java chars in
-     * arrays to 8-bit CORBA chars.  Bug 4367783.  This enables us to
-     * continue interoperating with our legacy ORBs.  If this goes into
-     * Ladybird, then Ladybird and Kestrel will interoperate as long as
-     * people don't use chars greater than 8-bits.
-     */
-    protected void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out,
-                                char[] array,
-                                int offset,
-                                int length)
-    {
-        out.write_char_array(array, offset, length);
-    }
-
-    /**
-     * Preserves the incorrect 1.3 behavior which truncates Java chars in
-     * arrays to 8-bit CORBA chars.  Bug 4367783.  This enables us to
-     * continue interoperating with our legacy ORBs.  If this goes into
-     * Ladybird, then Ladybird and Kestrel will interoperate as long as
-     * people don't use chars greater than 8-bits.
-     */
-    protected void readCharArray(org.omg.CORBA_2_3.portable.InputStream in,
-                                 char[] array,
-                                 int offset,
-                                 int length)
-    {
-        in.read_char_array(array, offset, length);
-    }
-
-    protected final String getOutputStreamClassName() {
-        return "com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3";
-    }
-
-    protected final String getInputStreamClassName() {
-        return "com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3";
-    }
-
-    /**
-     * Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.
-     * The correct behavior is for a Java char to map to a CORBA wchar,
-     * but our older code mapped it to a CORBA char.
-     */
-    protected TCKind getJavaCharTCKind() {
-        return TCKind.tk_char;
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3_1.java	Sat Mar 09 21:49:32 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.corba.se.impl.orbutil;
-
-import org.omg.CORBA.TCKind;
-
-/**
- * This class overrides behavior of our current ValueHandlerImpl to
- * provide backwards compatibility with JDK 1.3.1.
- */
-public class ValueHandlerImpl_1_3_1
-    extends com.sun.corba.se.impl.io.ValueHandlerImpl
-{
-    public ValueHandlerImpl_1_3_1() {}
-
-    public ValueHandlerImpl_1_3_1(boolean isInputStream) {
-        super(isInputStream);
-    }
-
-    /**
-     * Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.
-     * The correct behavior is for a Java char to map to a CORBA wchar,
-     * but our older code mapped it to a CORBA char.
-     */
-    protected TCKind getJavaCharTCKind() {
-        return TCKind.tk_char;
-    }
-
-    /**
-     * RepositoryId_1_3_1 performs an incorrect repId calculation
-     * when using serialPersistentFields and one of the fields no longer
-     * exists on the class itself.
-     */
-    public boolean useFullValueDescription(Class clazz, String repositoryID)
-        throws java.io.IOException
-    {
-        return RepositoryId_1_3_1.useFullValueDescription(clazz, repositoryID);
-    }
-
-    /**
-     * Installs the legacy IIOPOutputStream_1_3_1 which does
-     * PutFields/GetFields incorrectly.  Bug 4407244.
-     */
-    protected final String getOutputStreamClassName() {
-        return "com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1";
-    }
-
-    /**
-     * Installs the legacy IIOPInputStream_1_3_1 which does
-     * PutFields/GetFields incorrectly.  Bug 4407244.
-     */
-    protected final String getInputStreamClassName() {
-        return "com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1";
-    }
-}
--- a/corba/src/share/classes/com/sun/corba/se/spi/orb/ORB.java	Sat Mar 09 21:49:32 2013 +0530
+++ b/corba/src/share/classes/com/sun/corba/se/spi/orb/ORB.java	Wed Jul 05 18:45:29 2017 +0200
@@ -98,6 +98,7 @@
 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ;
 
 import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
+import sun.awt.AppContext;
 
 public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
     implements Broker, TypeCodeFactory
@@ -173,14 +174,7 @@
 
     protected MonitoringManager monitoringManager;
 
-    // There is only one instance of the PresentationManager
-    // that is shared between all ORBs.  This is necessary
-    // because RMI-IIOP requires the PresentationManager in
-    // places where no ORB is available, so the PresentationManager
-    // must be global.  It is initialized here as well.
-    protected static PresentationManager globalPM = null ;
-
-    static {
+    private static PresentationManager setupPresentationManager() {
         staticWrapper = ORBUtilSystemException.get(
             CORBALogDomains.RPC_PRESENTATION ) ;
 
@@ -220,10 +214,11 @@
                 }
             ) ;
 
-        globalPM = new PresentationManagerImpl( useDynamicStub ) ;
-        globalPM.setStubFactoryFactory( false,
+        PresentationManager pm = new PresentationManagerImpl( useDynamicStub ) ;
+        pm.setStubFactoryFactory( false,
             PresentationDefaults.getStaticStubFactoryFactory() ) ;
-        globalPM.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
+        pm.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
+        return pm;
     }
 
     public void destroy() {
@@ -234,11 +229,19 @@
         byteBufferPool = null;
     }
 
-    /** Get the single instance of the PresentationManager
+    /**
+     * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific
+     * AppContext to hold it. Creates and records one if needed.
      */
     public static PresentationManager getPresentationManager()
     {
-        return globalPM ;
+        AppContext ac = AppContext.getAppContext();
+        PresentationManager pm = (PresentationManager) ac.get(PresentationManager.class);
+        if (pm == null) {
+            pm = setupPresentationManager();
+            ac.put(PresentationManager.class, pm);
+        }
+        return pm;
     }
 
     /** Get the appropriate StubFactoryFactory.  This
@@ -248,8 +251,9 @@
     public static PresentationManager.StubFactoryFactory
         getStubFactoryFactory()
     {
-        boolean useDynamicStubs = globalPM.useDynamicStubs() ;
-        return globalPM.getStubFactoryFactory( useDynamicStubs ) ;
+        PresentationManager gPM = getPresentationManager();
+        boolean useDynamicStubs = gPM.useDynamicStubs() ;
+        return gPM.getStubFactoryFactory( useDynamicStubs ) ;
     }
 
     protected ORB()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/src/share/classes/sun/corba/JavaCorbaAccess.java	Wed Jul 05 18:45:29 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.corba;
+
+import com.sun.corba.se.impl.io.ValueHandlerImpl;
+
+public interface JavaCorbaAccess {
+    public ValueHandlerImpl newValueHandlerImpl();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/src/share/classes/sun/corba/SharedSecrets.java	Wed Jul 05 18:45:29 2017 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.corba;
+
+import com.sun.corba.se.impl.io.ValueUtility;
+import sun.misc.Unsafe;
+
+import java.security.AccessController;
+
+/** A repository of "shared secrets", which are a mechanism for
+    calling implementation-private methods in another package without
+    using reflection. A package-private class implements a public
+    interface and provides the ability to call package-private methods
+    within that package; the object implementing that interface is
+    provided through a third package to which access is restricted.
+    This framework avoids the primary disadvantage of using reflection
+    for this purpose, namely the loss of compile-time checking. */
+
+// SharedSecrets cloned in corba repo to avoid build issues
+public class SharedSecrets {
+    private static final Unsafe unsafe = Unsafe.getUnsafe();
+    private static JavaCorbaAccess javaCorbaAccess;
+
+    public static JavaCorbaAccess getJavaCorbaAccess() {
+        if (javaCorbaAccess == null) {
+            // Ensure ValueUtility is initialized; we know that that class
+            // provides the shared secret
+            unsafe.ensureClassInitialized(ValueUtility.class);
+        }
+        return javaCorbaAccess;
+    }
+
+    public static void setJavaCorbaAccess(JavaCorbaAccess access) {
+        javaCorbaAccess = access;
+    }
+
+}
--- a/hotspot/.hgtags	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/.hgtags	Wed Jul 05 18:45:29 2017 +0200
@@ -322,3 +322,5 @@
 df5396524152118535c36da5801d828b560d19a2 hs25-b21
 4a198b201f3ce84433fa94a3ca65d061473e7c4c jdk8-b80
 dd6350b4abc4a6c19c89dd982cc0e4f3d119885c hs25-b22
+65b797426a3bec6e91b64085a0cfb94adadb634a jdk8-b81
+0631ebcc45f05c73b09a56c2586685af1f781c1d hs25-b23
--- a/hotspot/agent/src/os/linux/ps_core.c	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/agent/src/os/linux/ps_core.c	Wed Jul 05 18:45:29 2017 +0200
@@ -132,12 +132,12 @@
 }
 
 // Part of the class sharing workaround
-static map_info* add_class_share_map_info(struct ps_prochandle* ph, off_t offset,
+static void add_class_share_map_info(struct ps_prochandle* ph, off_t offset,
                              uintptr_t vaddr, size_t memsz) {
    map_info* map;
    if ((map = allocate_init_map(ph->core->classes_jsa_fd,
                                 offset, vaddr, memsz)) == NULL) {
-      return NULL;
+      return;
    }
 
    map->next = ph->core->class_share_maps;
--- a/hotspot/make/bsd/makefiles/gcc.make	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/make/bsd/makefiles/gcc.make	Wed Jul 05 18:45:29 2017 +0200
@@ -168,12 +168,12 @@
 # conversions which might affect the values. To avoid that, we need to turn
 # it off explicitly. 
 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
-ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef
 else
-ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
+WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
 endif
 
-CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
+CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
 # Special cases
 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
 # XXXDARWIN: for _dyld_bind_fully_image_containing_address
--- a/hotspot/make/excludeSrc.make	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/make/excludeSrc.make	Wed Jul 05 18:45:29 2017 +0200
@@ -69,7 +69,7 @@
       CXXFLAGS += -DINCLUDE_CDS=0
       CFLAGS += -DINCLUDE_CDS=0
 
-      Src_Files_EXCLUDE += metaspaceShared.cpp
+      Src_Files_EXCLUDE += filemap.cpp metaspaceShared.cpp
 endif
 
 ifeq ($(INCLUDE_ALL_GCS), false)
--- a/hotspot/make/hotspot_version	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/make/hotspot_version	Wed Jul 05 18:45:29 2017 +0200
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=25
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=22
+HS_BUILD_NUMBER=23
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=8
--- a/hotspot/make/linux/makefiles/gcc.make	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/make/linux/makefiles/gcc.make	Wed Jul 05 18:45:29 2017 +0200
@@ -131,12 +131,12 @@
 # conversions which might affect the values. To avoid that, we need to turn
 # it off explicitly. 
 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
-ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef
 else
-ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
+WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
 endif
 
-CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
+CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
 # Special cases
 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
 
--- a/hotspot/make/solaris/makefiles/gcc.make	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/make/solaris/makefiles/gcc.make	Wed Jul 05 18:45:29 2017 +0200
@@ -118,8 +118,8 @@
 # Compiler warnings are treated as errors 
 WARNINGS_ARE_ERRORS = -Werror 
 # Enable these warnings. See 'info gcc' about details on these options
-ADDITIONAL_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare 
-CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ADDITIONAL_WARNINGS) 
+WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
+CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
 # Special cases 
 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))  
 
--- a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -2194,7 +2194,8 @@
                                            int callee_locals_size,
                                            frame* caller,
                                            frame* interpreter_frame,
-                                           bool is_top_frame) {
+                                           bool is_top_frame,
+                                           bool is_bottom_frame) {
 
   assert(popframe_extra_args == 0, "NEED TO FIX");
   // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
--- a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -1581,7 +1581,8 @@
                                            int callee_local_count,
                                            frame* caller,
                                            frame* interpreter_frame,
-                                           bool is_top_frame) {
+                                           bool is_top_frame,
+                                           bool is_bottom_frame) {
   // Note: This calculation must exactly parallel the frame setup
   // in InterpreterGenerator::generate_fixed_frame.
   // If f!=NULL, set up the following variables:
@@ -1664,6 +1665,15 @@
       int delta = local_words - parm_words;
       int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
       *interpreter_frame->register_addr(I5_savedSP)    = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
+      if (!is_bottom_frame) {
+        // Llast_SP is set below for the current frame to SP (with the
+        // extra space for the callee's locals). Here we adjust
+        // Llast_SP for the caller's frame, removing the extra space
+        // for the current method's locals.
+        *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
+      } else {
+        assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
+      }
     } else {
       assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
       // Don't have Lesp available; lay out locals block in the caller
--- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -2361,7 +2361,8 @@
                                            int callee_locals,
                                            frame* caller,
                                            frame* interpreter_frame,
-                                           bool is_top_frame) {
+                                           bool is_top_frame,
+                                           bool is_bottom_frame) {
 
   assert(popframe_extra_args == 0, "FIX ME");
   // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
--- a/hotspot/src/cpu/x86/vm/frame_x86.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/cpu/x86/vm/frame_x86.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -356,7 +356,7 @@
 // Verifies the calculated original PC of a deoptimization PC for the
 // given unextended SP.  The unextended SP might also be the saved SP
 // for MethodHandle call sites.
-#if ASSERT
+#ifdef ASSERT
 void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return) {
   frame fr;
 
--- a/hotspot/src/cpu/x86/vm/frame_x86.hpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/cpu/x86/vm/frame_x86.hpp	Wed Jul 05 18:45:29 2017 +0200
@@ -170,7 +170,7 @@
     return (intptr_t*) addr_at(offset);
   }
 
-#if ASSERT
+#ifdef ASSERT
   // Used in frame::sender_for_{interpreter,compiled}_frame
   static void verify_deopt_original_pc(   nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return = false);
   static void verify_deopt_mh_original_pc(nmethod* nm, intptr_t* unextended_sp) {
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -1585,7 +1585,8 @@
                                            int callee_locals,
                                            frame* caller,
                                            frame* interpreter_frame,
-                                           bool is_top_frame) {
+                                           bool is_top_frame,
+                                           bool is_bottom_frame) {
   // Note: This calculation must exactly parallel the frame setup
   // in AbstractInterpreterGenerator::generate_method_entry.
   // If interpreter_frame!=NULL, set up the method, locals, and monitors.
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -1599,7 +1599,8 @@
                                            int callee_locals,
                                            frame* caller,
                                            frame* interpreter_frame,
-                                           bool is_top_frame) {
+                                           bool is_top_frame,
+                                           bool is_bottom_frame) {
   // Note: This calculation must exactly parallel the frame setup
   // in AbstractInterpreterGenerator::generate_method_entry.
   // If interpreter_frame!=NULL, set up the method, locals, and monitors.
--- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -919,7 +919,8 @@
                                            int       callee_locals,
                                            frame*    caller,
                                            frame*    interpreter_frame,
-                                           bool      is_top_frame) {
+                                           bool      is_top_frame,
+                                           bool      is_bottom_frame) {
   assert(popframe_extra_args == 0, "what to do?");
   assert(!is_top_frame || (!callee_locals && !callee_param_count),
          "top frame should have no caller");
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -57,6 +57,7 @@
 #include "runtime/threadCritical.hpp"
 #include "runtime/timer.hpp"
 #include "services/attachListener.hpp"
+#include "services/memTracker.hpp"
 #include "services/runtimeService.hpp"
 #include "utilities/decoder.hpp"
 #include "utilities/defaultStream.hpp"
@@ -2275,13 +2276,25 @@
      return NULL;
   }
 
+  // The memory is committed
+  address pc = CALLER_PC;
+  MemTracker::record_virtual_memory_reserve((address)addr, bytes, pc);
+  MemTracker::record_virtual_memory_commit((address)addr, bytes, pc);
+
   return addr;
 }
 
 bool os::release_memory_special(char* base, size_t bytes) {
   // detaching the SHM segment will also delete it, see reserve_memory_special()
   int rslt = shmdt(base);
-  return rslt == 0;
+  if (rslt == 0) {
+    MemTracker::record_virtual_memory_uncommit((address)base, bytes);
+    MemTracker::record_virtual_memory_release((address)base, bytes);
+    return true;
+  } else {
+    return false;
+  }
+
 }
 
 size_t os::large_page_size() {
--- a/hotspot/src/os/linux/vm/globals_linux.hpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/os/linux/vm/globals_linux.hpp	Wed Jul 05 18:45:29 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -40,6 +40,9 @@
   product(bool, UseHugeTLBFS, false,                                    \
           "Use MAP_HUGETLB for large pages")                            \
                                                                         \
+  product(bool, LoadExecStackDllInVMThread, true,                       \
+          "Load DLLs with executable-stack attribute in the VM Thread") \
+                                                                        \
   product(bool, UseSHM, false,                                          \
           "Use SYSV shared memory for large pages")
 
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -44,6 +44,7 @@
 #include "runtime/extendedPC.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/interfaceSupport.hpp"
+#include "runtime/init.hpp"
 #include "runtime/java.hpp"
 #include "runtime/javaCalls.hpp"
 #include "runtime/mutexLocker.hpp"
@@ -57,10 +58,12 @@
 #include "runtime/threadCritical.hpp"
 #include "runtime/timer.hpp"
 #include "services/attachListener.hpp"
+#include "services/memTracker.hpp"
 #include "services/runtimeService.hpp"
 #include "utilities/decoder.hpp"
 #include "utilities/defaultStream.hpp"
 #include "utilities/events.hpp"
+#include "utilities/elfFile.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/vmError.hpp"
 
@@ -1796,9 +1799,93 @@
   // in case of error it checks if .dll/.so was built for the
   // same architecture as Hotspot is running on
 
+
+// Remember the stack's state. The Linux dynamic linker will change
+// the stack to 'executable' at most once, so we must safepoint only once.
+bool os::Linux::_stack_is_executable = false;
+
+// VM operation that loads a library.  This is necessary if stack protection
+// of the Java stacks can be lost during loading the library.  If we
+// do not stop the Java threads, they can stack overflow before the stacks
+// are protected again.
+class VM_LinuxDllLoad: public VM_Operation {
+ private:
+  const char *_filename;
+  void *_lib;
+ public:
+  VM_LinuxDllLoad(const char *fn) :
+    _filename(fn), _lib(NULL) {}
+  VMOp_Type type() const { return VMOp_LinuxDllLoad; }
+  void doit() {
+    _lib = os::Linux::dll_load_inner(_filename);
+    os::Linux::_stack_is_executable = true;
+  }
+  void* loaded_library() { return _lib; }
+};
+
 void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
 {
-  void * result= ::dlopen(filename, RTLD_LAZY);
+  void * result = NULL;
+  bool load_attempted = false;
+
+  // Check whether the library to load might change execution rights
+  // of the stack. If they are changed, the protection of the stack
+  // guard pages will be lost. We need a safepoint to fix this.
+  //
+  // See Linux man page execstack(8) for more info.
+  if (os::uses_stack_guard_pages() && !os::Linux::_stack_is_executable) {
+    ElfFile ef(filename);
+    if (!ef.specifies_noexecstack()) {
+      if (!is_init_completed()) {
+        os::Linux::_stack_is_executable = true;
+        // This is OK - No Java threads have been created yet, and hence no
+        // stack guard pages to fix.
+        //
+        // This should happen only when you are building JDK7 using a very
+        // old version of JDK6 (e.g., with JPRT) and running test_gamma.
+        //
+        // Dynamic loader will make all stacks executable after
+        // this function returns, and will not do that again.
+        assert(Threads::first() == NULL, "no Java threads should exist yet.");
+      } else {
+        warning("You have loaded library %s which might have disabled stack guard. "
+                "The VM will try to fix the stack guard now.\n"
+                "It's highly recommended that you fix the library with "
+                "'execstack -c <libfile>', or link it with '-z noexecstack'.",
+                filename);
+
+        assert(Thread::current()->is_Java_thread(), "must be Java thread");
+        JavaThread *jt = JavaThread::current();
+        if (jt->thread_state() != _thread_in_native) {
+          // This happens when a compiler thread tries to load a hsdis-<arch>.so file
+          // that requires ExecStack. Cannot enter safe point. Let's give up.
+          warning("Unable to fix stack guard. Giving up.");
+        } else {
+          if (!LoadExecStackDllInVMThread) {
+            // This is for the case where the DLL has an static
+            // constructor function that executes JNI code. We cannot
+            // load such DLLs in the VMThread.
+            result = ::dlopen(filename, RTLD_LAZY);
+          }
+
+          ThreadInVMfromNative tiv(jt);
+          debug_only(VMNativeEntryWrapper vew;)
+
+          VM_LinuxDllLoad op(filename);
+          VMThread::execute(&op);
+          if (LoadExecStackDllInVMThread) {
+            result = op.loaded_library();
+          }
+          load_attempted = true;
+        }
+      }
+    }
+  }
+
+  if (!load_attempted) {
+    result = ::dlopen(filename, RTLD_LAZY);
+  }
+
   if (result != NULL) {
     // Successful loading
     return result;
@@ -1952,6 +2039,38 @@
   return NULL;
 }
 
+void * os::Linux::dll_load_inner(const char *filename) {
+  void * result = NULL;
+  if (LoadExecStackDllInVMThread) {
+    result = ::dlopen(filename, RTLD_LAZY);
+  }
+
+  // Since 7019808, libjvm.so is linked with -noexecstack. If the VM loads a
+  // library that requires an executable stack, or which does not have this
+  // stack attribute set, dlopen changes the stack attribute to executable. The
+  // read protection of the guard pages gets lost.
+  //
+  // Need to check _stack_is_executable again as multiple VM_LinuxDllLoad
+  // may have been queued at the same time.
+
+  if (!_stack_is_executable) {
+    JavaThread *jt = Threads::first();
+
+    while (jt) {
+      if (!jt->stack_guard_zone_unused() &&        // Stack not yet fully initialized
+          jt->stack_yellow_zone_enabled()) {       // No pending stack overflow exceptions
+        if (!os::guard_memory((char *) jt->stack_red_zone_base() - jt->stack_red_zone_size(),
+                              jt->stack_yellow_zone_size() + jt->stack_red_zone_size())) {
+          warning("Attempt to reguard stack yellow zone failed.");
+        }
+      }
+      jt = jt->next();
+    }
+  }
+
+  return result;
+}
+
 /*
  * glibc-2.0 libdl is not MT safe.  If you are building with any glibc,
  * chances are you might want to run the generated bits against glibc-2.0
@@ -3094,13 +3213,24 @@
     numa_make_global(addr, bytes);
   }
 
+  // The memory is committed
+  address pc = CALLER_PC;
+  MemTracker::record_virtual_memory_reserve((address)addr, bytes, pc);
+  MemTracker::record_virtual_memory_commit((address)addr, bytes, pc);
+
   return addr;
 }
 
 bool os::release_memory_special(char* base, size_t bytes) {
   // detaching the SHM segment will also delete it, see reserve_memory_special()
   int rslt = shmdt(base);
-  return rslt == 0;
+  if (rslt == 0) {
+    MemTracker::record_virtual_memory_uncommit((address)base, bytes);
+    MemTracker::record_virtual_memory_release((address)base, bytes);
+    return true;
+  } else {
+   return false;
+  }
 }
 
 size_t os::large_page_size() {
--- a/hotspot/src/os/linux/vm/os_linux.hpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/os/linux/vm/os_linux.hpp	Wed Jul 05 18:45:29 2017 +0200
@@ -94,6 +94,9 @@
   static void print_libversion_info(outputStream* st);
 
  public:
+  static bool _stack_is_executable;
+  static void *dll_load_inner(const char *name);
+
   static void init_thread_fpu_state();
   static int  get_fpu_control_word();
   static void set_fpu_control_word(int fpu_control);
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -2945,7 +2945,7 @@
   while (p < (uint64_t)end) {
     addrs[0] = p;
     size_t addrs_count = 1;
-    while (addrs_count < MAX_MEMINFO_CNT && addrs[addrs_count - 1] < (uint64_t)end) {
+    while (addrs_count < MAX_MEMINFO_CNT && addrs[addrs_count - 1] + page_size < (uint64_t)end) {
       addrs[addrs_count] = addrs[addrs_count - 1] + page_size;
       addrs_count++;
     }
@@ -3420,13 +3420,25 @@
   if ((retAddr != NULL) && UseNUMAInterleaving) {
     numa_make_global(retAddr, size);
   }
+
+  // The memory is committed
+  address pc = CALLER_PC;
+  MemTracker::record_virtual_memory_reserve((address)retAddr, size, pc);
+  MemTracker::record_virtual_memory_commit((address)retAddr, size, pc);
+
   return retAddr;
 }
 
 bool os::release_memory_special(char* base, size_t bytes) {
   // detaching the SHM segment will also delete it, see reserve_memory_special()
   int rslt = shmdt(base);
-  return rslt == 0;
+  if (rslt == 0) {
+    MemTracker::record_virtual_memory_uncommit((address)base, bytes);
+    MemTracker::record_virtual_memory_release((address)base, bytes);
+    return true;
+  } else {
+   return false;
+  }
 }
 
 size_t os::large_page_size() {
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -60,6 +60,7 @@
 #include "runtime/threadCritical.hpp"
 #include "runtime/timer.hpp"
 #include "services/attachListener.hpp"
+#include "services/memTracker.hpp"
 #include "services/runtimeService.hpp"
 #include "utilities/decoder.hpp"
 #include "utilities/defaultStream.hpp"
@@ -2836,7 +2837,7 @@
                                 PAGE_READWRITE);
   // If reservation failed, return NULL
   if (p_buf == NULL) return NULL;
-
+  MemTracker::record_virtual_memory_reserve((address)p_buf, size_of_reserve, CALLER_PC);
   os::release_memory(p_buf, bytes + chunk_size);
 
   // we still need to round up to a page boundary (in case we are using large pages)
@@ -2898,6 +2899,11 @@
       if (next_alloc_addr > p_buf) {
         // Some memory was committed so release it.
         size_t bytes_to_release = bytes - bytes_remaining;
+        // NMT has yet to record any individual blocks, so it
+        // need to create a dummy 'reserve' record to match
+        // the release.
+        MemTracker::record_virtual_memory_reserve((address)p_buf,
+          bytes_to_release, CALLER_PC);
         os::release_memory(p_buf, bytes_to_release);
       }
 #ifdef ASSERT
@@ -2909,10 +2915,19 @@
 #endif
       return NULL;
     }
+
     bytes_remaining -= bytes_to_rq;
     next_alloc_addr += bytes_to_rq;
     count++;
   }
+  // Although the memory is allocated individually, it is returned as one.
+  // NMT records it as one block.
+  address pc = CALLER_PC;
+  MemTracker::record_virtual_memory_reserve((address)p_buf, bytes, pc);
+  if ((flags & MEM_COMMIT) != 0) {
+    MemTracker::record_virtual_memory_commit((address)p_buf, bytes, pc);
+  }
+
   // made it this far, success
   return p_buf;
 }
@@ -3099,11 +3114,20 @@
     // normal policy just allocate it all at once
     DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
     char * res = (char *)VirtualAlloc(NULL, bytes, flag, prot);
+    if (res != NULL) {
+      address pc = CALLER_PC;
+      MemTracker::record_virtual_memory_reserve((address)res, bytes, pc);
+      MemTracker::record_virtual_memory_commit((address)res, bytes, pc);
+    }
+
     return res;
   }
 }
 
 bool os::release_memory_special(char* base, size_t bytes) {
+  assert(base != NULL, "Sanity check");
+  // Memory allocated via reserve_memory_special() is committed
+  MemTracker::record_virtual_memory_uncommit((address)base, bytes);
   return release_memory(base, bytes);
 }
 
--- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -516,7 +516,7 @@
         // here if the underlying file has been truncated.
         // Do not crash the VM in such a case.
         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-        nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
+        nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL;
         if (nm != NULL && nm->has_unsafe_access()) {
           stub = StubRoutines::handler_for_unsafe_access();
         }
--- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -410,6 +410,11 @@
       // to handle_unexpected_exception way down below.
       thread->disable_stack_red_zone();
       tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
+
+      // This is a likely cause, but hard to verify. Let's just print
+      // it as a hint.
+      tty->print_raw_cr("Please check if any of your loaded .so files has "
+                        "enabled executable stack (see man page execstack(8))");
     } else {
       // Accessing stack address below sp may cause SEGV if current
       // thread has MAP_GROWSDOWN stack. This should only happen when
--- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -305,6 +305,11 @@
           // to handle_unexpected_exception way down below.
           thread->disable_stack_red_zone();
           tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
+
+          // This is a likely cause, but hard to verify. Let's just print
+          // it as a hint.
+          tty->print_raw_cr("Please check if any of your loaded .so files has "
+                            "enabled executable stack (see man page execstack(8))");
         } else {
           // Accessing stack address below sp may cause SEGV if current
           // thread has MAP_GROWSDOWN stack. This should only happen when
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp	Wed Jul 05 18:45:29 2017 +0200
@@ -2375,7 +2375,7 @@
   // collects all register operands of the instruction
   void visit(LIR_Op* op);
 
-#if ASSERT
+#ifdef ASSERT
   // check that an operation has no operands
   bool no_operands(LIR_Op* op);
 #endif
--- a/hotspot/src/share/vm/ci/ciTypeFlow.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/share/vm/ci/ciTypeFlow.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -2540,7 +2540,7 @@
   } else if (innermost->head() == blk) {
     // If loop header, complete the tree pointers
     if (blk->loop() != innermost) {
-#if ASSERT
+#ifdef ASSERT
       assert(blk->loop()->head() == innermost->head(), "same head");
       Loop* dl;
       for (dl = innermost; dl != NULL && dl != blk->loop(); dl = dl->parent());
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Sat Mar 09 21:49:32 2013 +0530
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Jul 05 18:45:29 2017 +0200
@@ -90,8 +90,7 @@
 // Extension method support.
 #define JAVA_8_VERSION                    52
 
-
-void ClassFileParser::parse_constant_pool_entries(ClassLoaderData* loader_data, constantPoolHandle cp, int length, TRAPS) {
+void ClassFileParser::parse_constant_pool_entries(int length, TRAPS) {
   // Use a local copy of ClassFileStream. It helps the C++ compiler to optimize
   // this function (_current can be allocated in a register, with scalar
   // replacement of aggregates). The _current pointer is copied back to
@@ -104,7 +103,7 @@
   assert(cfs->allocated_on_stack(),"should be local");
   u1* old_current = cfs0->current();
 #endif
-  Handle class_loader(THREAD, loader_data->class_loader());
+  Handle class_loader(THREAD, _loader_data->class_loader());
 
   // Used for batching symbol allocations.
   const char* names[SymbolTable::symbol_alloc_batch_size];
@@ -124,7 +123,7 @@
         {
           cfs->guarantee_more(3, CHECK);  // name_index, tag/access_flags
           u2 name_index = cfs->get_u2_fast();
-          cp->klass_index_at_put(index, name_index);
+          _cp->klass_index_at_put(index, name_index);
         }
         break;
       case JVM_CONSTANT_Fieldref :
@@ -132,7 +131,7 @@
           cfs->guarantee_more(5, CHECK);  // class_index, name_and_type_index, tag/access_flags
           u2 class_index = cfs->get_u2_fast();
           u2 name_and_type_index = cfs->get_u2_fast();
-          cp->field_at_put(index, class_index, name_and_type_index);
+          _cp->field_at_put(index, class_index, name_and_type_index);
         }
         break;
       case JVM_CONSTANT_Methodref :
@@ -140,7 +139,7 @@
           cfs->guarantee_more(5, CHECK);  // class_index, name_and_type_index, tag/access_flags
           u2 class_index = cfs->get_u2_fast();
           u2 name_and_type_index = cfs->get_u2_fast();
-          cp->method_at_put(index, class_index, name_and_type_index);
+          _cp->method_at_put(index, class_index, name_and_type_index);
         }
         break;
       case JVM_CONSTANT_InterfaceMethodref :
@@ -148,14 +147,14 @@
           cfs->guarantee_more(5, CHECK);  // class_index, name_and_type_index, tag/access_flags
           u2 class_index = cfs->get_u2_fast();
           u2 name_and_type_index = cfs->get_u2_fast();
-          cp->interface_method_at_put(index, class_index, name_and_type_index);
+          _cp->interface_method_at_put(index, class_index, name_and_type_index);
         }
         break;
       case JVM_CONSTANT_String :
         {
           cfs->guarantee_more(3, CHECK);  // string_index, tag/access_flags
           u2 string_index = cfs->get_u2_fast();
-          cp->string_index_at_put(index, string_index);
+          _cp->string_index_at_put(index, string_index);
         }
         break;
       case JVM_CONSTANT_MethodHandle :
@@ -174,11 +173,11 @@
           cfs->guarantee_more(4, CHECK);  // ref_kind, method_index, tag/access_flags
           u1 ref_kind = cfs->get_u1_fast();
           u2 method_index = cfs->get_u2_fast();
-          cp->method_handle_index_at_put(index, ref_kind, method_index);
+          _cp->method_handle_index_at_put(index, ref_kind, method_index);
         } else if (tag == JVM_CONSTANT_MethodType) {
           cfs->guarantee_more(3, CHECK);  // signature_index, tag/access_flags
           u2 signature_index = cfs->get_u2_fast();
-          cp->method_type_index_at_put(index, signature_index);
+          _cp->method_type_index_at_put(index, signature_index);
         } else {
           ShouldNotReachHere();
         }
@@ -200,21 +199,21 @@
           u2 name_and_type_index = cfs->get_u2_fast();
           if (_max_bootstrap_specifier_index < (int) bootstrap_specifier_index)
             _max_bootstrap_specifier_index = (int) bootstrap_specifier_index;  // collect for later
-          cp->invoke_dynamic_at_put(index, bootstrap_specifier_index, name_and_type_index);
+          _cp->invoke_dynamic_at_put(index, bootstrap_specifier_index, name_and_type_index);
         }
         break;
       case JVM_CONSTANT_Integer :
         {
           cfs->guarantee_more(5, CHECK);  // bytes, tag/access_flags
           u4 bytes = cfs->get_u4_fast();
-          cp->int_at_put(index, (jint) bytes);
+          _cp->int_at_put(index, (jint) bytes);
         }
         break;
       case JVM_CONSTANT_Float :
         {
           cfs->guarantee_more(5, CHECK);  // bytes, tag/access_flags
           u4 bytes = cfs->get_u4_fast();
-          cp->float_at_put(index, *(jfloat*)&bytes);
+          _cp->float_at_put(index, *(jfloat*)&bytes);
         }
         break;
       case JVM_CONSTANT_Long :
@@ -225,7 +224,7 @@
         {
           cfs->guarantee_more(9, CHECK);  // bytes, tag/access_flags
           u8 bytes = cfs->get_u8_fast();
-          cp->long_at_put(index, bytes);
+          _cp->long_at_put(index, bytes);
         }
         index++;   // Skip entry following eigth-byte constant, see JVM book p. 98
         break;
@@ -237,7 +236,7 @@
         {
           cfs->guarantee_more(9, CHECK);  // bytes, tag/access_flags
           u8 bytes = cfs->get_u8_fast();
-          cp->double_at_put(index, *(jdouble*)&bytes);
+          _cp->double_at_put(index, *(jdouble*)&bytes);
         }
         index++;   // Skip entry following eigth-byte constant, see JVM book p. 98
         break;
@@ -246,7 +245,7 @@
           cfs->guarantee_more(5, CHECK);  // name_index, signature_index, tag/access_flags
           u2 name_index = cfs->get_u2_fast();
           u2 signature_index = cfs->get_u2_fast();
-          cp->name_and_type_at_put(index, name_index, signature_index);
+          _cp->name_and_type_at_put(index, name_index, signature_index);
         }
         break;
       case JVM_CONSTANT_Utf8 :
@@ -283,11 +282,11 @@
             indices[names_count] = index;
             hashValues[names_count++] = hash;
             if (names_count == SymbolTable::symbol_alloc_batch_size) {
-              SymbolTable::new_symbols(loader_data, cp, names_count, names, lengths, indices, hashValues, CHECK);
+              SymbolTable::new_symbols(_loader_data, _cp, names_count, names, lengths, indices, hashValues, CHECK);
               names_count = 0;
             }
           } else {
-            cp->symbol_at_put(index, result);
+            _cp->symbol_at_put(index, result);
           }
         }
         break;
@@ -300,7 +299,7 @@
 
   // Allocate the remaining symbols
   if (names_count > 0) {
-    SymbolTable::new_symbols(loader_data, cp, names_count, names, lengths, indices, hashValues, CHECK);
+    SymbolTable::new_symbols(_loader_data, _cp, names_count, names, lengths, indices, hashValues, CHECK);
   }
 
   // Copy _current pointer of local copy back to stream().
@@ -310,23 +309,6 @@
   cfs0->set_current(cfs1.current());
 }
 
-// This class unreferences constant pool symbols if an error has occurred
-// while parsing the class before it is assigned into the class.
-// If it gets an error after that it is unloaded and the constant pool will
-// be cleaned up then.
-class ConstantPoolCleaner : public StackObj {
-  constantPoolHandle _cphandle;
-  bool               _in_error;
- public:
-  ConstantPoolCleaner(constantPoolHandle cp) : _cphandle(cp), _in_error(true) {}
-  ~ConstantPoolCleaner() {
-    if (_in_error && _cphandle.not_null()) {
-      _cphandle->unreference_symbols();
-    }
-  }
-  void set_in_error(bool clean) { _in_error = clean; }
-};
-
 bool inline valid_cp_range(int index, int length) { return (index > 0 && index < length); }
 
 inline Symbol* check_symbol_at(constantPoolHandle cp, int index) {
@@ -336,7 +318,7 @@
     return NULL;
 }
 
-constantPoolHandle ClassFileParser::parse_constant_pool(ClassLoaderData* loader_data, TRAPS) {
+constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) {
   ClassFileStream* cfs = stream();
   constantPoolHandle nullHandle;
 
@@ -345,16 +327,13 @@
   guarantee_property(
     length >= 1, "Illegal constant pool size %u in class file %s",
     length, CHECK_(nullHandle));
-  ConstantPool* constant_pool =
-                      ConstantPool::allocate(loader_data,
-                                                    length,
-                                                   CHECK_(nullHandle));
+  ConstantPool* constant_pool = ConstantPool::allocate(_loader_data, length,
+                                                        CHECK_(nullHandle));
+  _cp = constant_pool; // save in case of errors
   constantPoolHandle cp (THREAD, constant_pool);
 
-  ConstantPoolCleaner cp_in_error(cp); // set constant pool to be cleaned up.
-
   // parsing constant pool entries
-  parse_constant_pool_entries(loader_data, cp, length, CHECK_(nullHandle));
+  parse_constant_pool_entries(length, CHECK_(nullHandle));
 
   int index = 1;  // declared outside of loops for portability
 
@@ -373,8 +352,7 @@
         if (!_need_verify) break;
         int klass_ref_index = cp->klass_ref_index_at(index);
         int name_and_type_ref_index = cp->name_and_type_ref_index_at(index);
-        check_property(valid_cp_range(klass_ref_index, length) &&
-                       is_klass_reference(cp, klass_ref_index),
+        check_property(valid_klass_reference_at(klass_ref_index),
                        "Invalid constant pool index %u in class file %s",
                        klass_ref_index,
                        CHECK_(nullHandle));
@@ -404,16 +382,12 @@
         if (!_need_verify) break;
         int name_ref_index = cp->name_ref_index_at(index);
         int signature_ref_index = cp->signature_ref_index_at(index);
-        check_property(
-          valid_cp_range(name_ref_index, length) &&
-            cp->tag_at(name_ref_index).is_utf8(),
-          "Invalid constant pool index %u in class file %s",
-          name_ref_index, CHECK_(nullHandle));
-        check_property(
-          valid_cp_range(signature_ref_index, length) &&
-            cp->tag_at(signature_ref_index).is_utf8(),
-          "Invalid constant pool index %u in class file %s",
-          signature_ref_index, CHECK_(nullHandle));
+        check_property(valid_symbol_at(name_ref_index),
+                 "Invalid constant pool index %u in class file %s",
+                 name_ref_index, CHECK_(nullHandle));
+        check_property(valid_symbol_at(signature_ref_index),
+                 "Invalid constant pool index %u in class file %s",
+                 signature_ref_index, CHECK_(nullHandle));
         break;
       }
       case JVM_CONSTANT_Utf8 :
@@ -425,22 +399,18 @@
       case JVM_CONSTANT_ClassIndex :
         {
           int class_index = cp->klass_index_at(index);
-          check_property(
-            valid_cp_range(class_index, length) &&
-              cp->tag_at(class_index).is_utf8(),
-            "Invalid constant pool index %u in class file %s",
-            class_index, CHECK_(nullHandle));
+          check_property(valid_symbol_at(class_index),
+                 "Invalid constant pool index %u in class file %s",
+                 class_index, CHECK_(nullHandle));
           cp->unresolved_klass_at_put(index, cp->symbol_at(class_index));
         }
         break;
       case JVM_CONSTANT_StringIndex :
         {
           int string_index = cp->string_index_at(index);
-          check_property(
-            valid_cp_range(string_index, length) &&
-              cp->tag_at(string_index).is_utf8(),
-            "Invalid constant pool index %u in class file %s",
-            string_index, CHECK_(nullHandle));
+          check_property(valid_symbol_at(string_index),
+                 "Invalid constant pool index %u in class file %s",
+                 string_index, CHECK_(nullHandle));
           Symbol* sym = cp->symbol_at(string_index);
           cp->unresolved_string_at_put(index, sym);
         }
@@ -491,12 +461,9 @@
       case JVM_CONSTANT_MethodType :
         {
           int ref_index = cp->method_type_index_at(index);
-          check_property(
-            valid_cp_range(ref_index, length) &&
-                cp->tag_at(ref_index).is_utf8() &&
-                EnableInvokeDynamic,
-              "Invalid constant pool index %u in class file %s",
-              ref_index, CHECK_(nullHandle));
+          check_property(valid_symbol_at(ref_index) && EnableInvokeDynamic,
+                 "Invalid constant pool index %u in class file %s",
+                 ref_index, CHECK_(nullHandle));
         }
         break;
       case JVM_CONSTANT_InvokeDynamic :
@@ -541,7 +508,6 @@
   }
 
   if (!_need_verify) {
-    cp_in_error.set_in_error(false);
     return cp;
   }
 
@@ -664,7 +630,6 @@
     }  // end of switch
   }  // end of for
 
-  cp_in_error.set_in_error(false);
   return cp;
 }
 
@@ -786,93 +751,92 @@
 }
 
 
-Array<Klass*>* ClassFileParser::parse_interfaces(constantPoolHandle cp,
-                                                 int length,
-                                                 ClassLoaderData* loader_data,
+Array<Klass*>* ClassFileParser::parse_interfaces(int length,
                                                  Handle protection_domain,
                                                  Symbol* class_name,
                                                  bool* has_default_methods,
                                                  TRAPS) {
-  ClassFileStream* cfs = stream();
-  assert(length > 0, "only called for length>0");
-  // FIXME: Leak at later OOM.
-  Array<Klass*>* interfaces = MetadataFactory::new_array<Klass*>(loader_data, length, NULL, CHECK_NULL);
-
-  int index;
-  for (index = 0; index < length; index++) {
-    u2 interface_index = cfs->get_u2(CHECK_NULL);
-    KlassHandle interf;
-    check_property(
-      valid_cp_range(interface_index, cp->length()) &&
-      is_klass_reference(cp, interface_index),
-      "Interface name has bad constant pool index %u in class file %s",
-      interface_index, CHECK_NULL);
-    if (cp->tag_at(interface_index).is_klass()) {
-      interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index));
-    } else {
-      Symbol*  unresolved_klass  = cp->klass_name_at(interface_index);
-
-      // Don't need to check legal name because it's checked when parsing constant pool.
-      // But need to make sure it's not an array type.
-      guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
-                         "Bad interface name in class file %s", CHECK_NULL);
-      Handle class_loader(THREAD, loader_data->class_loader());
-
-      // Call resolve_super so classcircularity is checked
-      Klass* k = SystemDictionary::resolve_super_or_fail(class_name,
-                    unresolved_klass, class_loader, protection_domain,
-                    false, CHECK_NULL);
-      interf = KlassHandle(THREAD, k);
+  if (length == 0) {
+    _local_interfaces = Universe::the_empty_klass_array();
+  } else {
+    ClassFileStream* cfs = stream();
+    assert(length > 0, "only called for length>0");
+    _local_interfaces = MetadataFactory::new_array<Klass*>(_loader_data, length, NULL, CHECK_NULL);
+
+    int index;
+    for (index = 0; index < length; index++) {
+      u2 interface_index = cfs->get_u2(CHECK_NULL);
+      KlassHandle interf;
+      check_property(
+        valid_klass_reference_at(interface_index),
+        "Interface name has bad constant pool index %u in class file %s",
+        interface_index, CHECK_NULL);
+      if (_cp->tag_at(interface_index).is_klass()) {
+        interf = KlassHandle(THREAD, _cp->resolved_klass_at(interface_index));
+      } else {
+        Symbol*  unresolved_klass  = _cp->klass_name_at(interface_index);
+
+        // Don't need to check legal name because it's checked when parsing constant pool.
+        // But need to make sure it's not an array type.
+        guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
+                           "Bad interface name in class file %s", CHECK_NULL);
+        Handle class_loader(THREAD, _loader_data->class_loader());
+
+        // Call resolve_super so classcircularity is checked
+        Klass* k = SystemDictionary::resolve_super_or_fail(class_name,
+                      unresolved_klass, class_loader, protection_domain,
+                      false, CHECK_NULL);
+        interf = KlassHandle(THREAD, k);
+      }
+
+      if (!interf()->is_interface()) {
+        THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", NULL);
+      }
+      if (InstanceKlass::cast(interf())->has_default_methods()) {
+        *has_default_methods = true;
+      }
+      _local_interfaces->at_put(index, interf());
     }
 
-    if (!interf()->is_interface()) {
-      THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", NULL);
+    if (!_need_verify || length <= 1) {
+      return _local_interfaces;
     }
-    if (InstanceKlass::cast(interf())->has_default_methods()) {
-      *has_default_methods = true;
-    }
-    interfaces->at_put(index, interf());
-  }
-
-  if (!_need_verify || length <= 1) {
-    return interfaces;
-  }
-
-  // Check if there's any duplicates in interfaces
-  ResourceMark rm(THREAD);
-  NameSigHash** interface_names = NEW_RESOURCE_ARRAY_IN_THREAD(
-    THREAD, NameSigHash*, HASH_ROW_SIZE);
-  initialize_hashtable(interface_names);
-  bool dup = false;
-  {
-    debug_only(No_Safepoint_Verifier nsv;)
-    for (index = 0; index < length; index++) {
-      Klass* k = interfaces->at(index);
-      Symbol* name = InstanceKlass::cast(k)->name();
-      // If no duplicates, add (name, NULL) in hashtable interface_names.
-      if (!put_after_lookup(name, NULL, interface_names)) {
-        dup = true;
-        break;
+
+    // Check if there's any duplicates in interfaces
+    ResourceMark rm(THREAD);
+    NameSigHash** interface_names = NEW_RESOURCE_ARRAY_IN_THREAD(
+      THREAD, NameSigHash*, HASH_ROW_SIZE);
+    initialize_hashtable(interface_names);
+    bool dup = false;
+    {
+      debug_only(No_Safepoint_Verifier nsv;)
+      for (index = 0; index < length; index++) {
+        Klass* k = _local_interfaces->at(index);
+        Symbol* name = InstanceKlass::cast(k)->name();
+        // If no duplicates, add (name, NULL) in hashtable interface_names.
+        if (!put_after_lookup(name, NULL, interface_names)) {
+          dup = true;
+          break;
+        }
       }
     }
+    if (dup) {
+      classfile_parse_error("Duplicate interface name in class file %s", CHECK_NULL);
+    }
   }
-  if (dup) {
-    classfile_parse_error("Duplicate interface name in class file %s", CHECK_NULL);
-  }
-
-  return interfaces;
+  return _local_interfaces;
 }
 
 
-void ClassFileParser::verify_constantvalue(int constantvalue_index, int signature_index, constantPoolHandle cp, TRAPS) {
+void ClassFileParser::verify_constantvalue(int constantvalue_index, int signature_index, TRAPS) {
   // Make sure the constant pool entry is of a type appropriate to this field
   guarantee_property(
     (constantvalue_index > 0 &&
-      constantvalue_index < cp->length()),
+      constantvalue_index < _cp->length()),
     "Bad initial value index %u in ConstantValue attribute in class file %s",
     constantvalue_index, CHECK);
-  constantTag value_type = cp->tag_at(constantvalue_index);
-  switch ( cp->basic_type_for_signature_at(signature_index) ) {
+  constantTag value_type = _cp->tag_at(constantvalue_index);
+  switch ( _cp->basic_type_for_signature_at(signature_index) ) {
     case T_LONG:
       guarantee_property(value_type.is_long(), "Inconsistent constant value type in class file %s", CHECK);
       break;
@@ -886,7 +850,7 @@
       guarantee_property(value_type.is_int(), "Inconsistent constant value type in class file %s", CHECK);
       break;
     case T_OBJECT:
-      guarantee_property((cp->symbol_at(signature_index)->equals("Ljava/lang/String;")
+      guarantee_property((_cp->symbol_at(signature_index)->equals("Ljava/lang/String;")
                          && value_type.is_string()),
                          "Bad string initial value in class file %s", CHECK);
       break;
@@ -899,15 +863,11 @@
 
 
 // Parse attributes for a field.
-void ClassFileParser::parse_field_attributes(ClassLoaderData* loader_data,
-                                             constantPoolHandle cp,
-                                             u2 attributes_count,
+void ClassFileParser::parse_field_attributes(u2 attributes_count,
                                              bool is_static, u2 signature_index,
                                              u2* constantvalue_index_addr,
                                              bool* is_synthetic_addr,
                                              u2* generic_signature_index_addr,
-                                             AnnotationArray** field_annotations,
-                                             AnnotationArray** field_type_annotations,
                                              ClassFileParser::FieldAnnotationCollector* parsed_annotations,
                                              TRAPS) {
   ClassFileStream* cfs = stream();
@@ -927,12 +887,11 @@
     cfs->guarantee_more(6, CHECK);  // attribute_name_index, attribute_length
     u2 attribute_name_index = cfs->get_u2_fast();
     u4 attribute_length = cfs->get_u4_fast();
-    check_property(valid_cp_range(attribute_name_index, cp->length()) &&
-                   cp->tag_at(attribute_name_index).is_utf8(),
+    check_property(valid_symbol_at(attribute_name_index),
                    "Invalid field attribute index %u in class file %s",
                    attribute_name_index,
                    CHECK);
-    Symbol* attribute_name = cp->symbol_at(attribute_name_index);
+    Symbol* attribute_name = _cp->symbol_at(attribute_name_index);
     if (is_static && attribute_name == vmSymbols::tag_constant_value()) {
       // ignore if non-static
       if (constantvalue_index != 0) {
@@ -944,7 +903,7 @@
         attribute_length, CHECK);
       constantvalue_index = cfs->get_u2(CHECK);
       if (_need_verify) {
-        verify_constantvalue(constantvalue_index, signature_index, cp, CHECK);
+        verify_constantvalue(constantvalue_index, signature_index, CHECK);
       }
     } else if (attribute_name == vmSymbols::tag_synthetic()) {
       if (attribute_length != 0) {
@@ -971,10 +930,8 @@
         runtime_visible_annotations_length = attribute_length;
         runtime_visible_annotations = cfs->get_u1_buffer();
         assert(runtime_visible_annotations != NULL, "null visible annotations");
-        parse_annotations(loader_data,
-                          runtime_visible_annotations,
+        parse_annotations(runtime_visible_annotations,
                           runtime_visible_annotations_length,
-                          cp,
                           parsed_annotations,
                           CHECK);
         cfs->skip_u1(runtime_visible_annotations_length, CHECK);
@@ -1004,18 +961,18 @@
   *constantvalue_index_addr = constantvalue_index;
   *is_synthetic_addr = is_synthetic;
   *generic_signature_index_addr = generic_signature_index;
-  *field_annotations = assemble_annotations(loader_data,
-                                            runtime_visible_annotations,
+  AnnotationArray* a = assemble_annotations(runtime_visible_annotations,
                                             runtime_visible_annotations_length,
                                             runtime_invisible_annotations,
                                             runtime_invisible_annotations_length,
                                             CHECK);
-  *field_type_annotations = assemble_annotations(loader_data,
-                                            runtime_visible_type_annotations,
-                                            runtime_visible_type_annotations_length,
-                                            runtime_invisible_type_annotations,
-                                            runtime_invisible_type_annotations_length,
-                                            CHECK);
+  parsed_annotations->set_field_annotations(a);
+  a = assemble_annotations(runtime_visible_type_annotations,
+                           runtime_visible_type_annotations_length,
+                           runtime_invisible_type_annotations,
+                           runtime_invisible_type_annotations_length,
+                           CHECK);
+  parsed_annotations->set_field_type_annotations(a);
   return;
 }
 
@@ -1106,13 +1063,9 @@
   }
 };
 
-Array<u2>* ClassFileParser::parse_fields(ClassLoaderData* loader_data,
-                                         Symbol* class_name,
-                                         constantPoolHandle cp,
+Array<u2>* ClassFileParser::parse_fields(Symbol* class_name,
                                          bool is_interface,
                                          FieldAllocationCount *fac,
-                                         Array<AnnotationArray*>** fields_annotations,
-                                         Array<AnnotationArray*>** fields_type_annotations,
                                          u2* java_fields_count_ptr, TRAPS) {
   ClassFileStream* cfs = stream();
   cfs->guarantee_more(2, CHECK_NULL);  // length
@@ -1147,8 +1100,6 @@
   u2* fa = NEW_RESOURCE_ARRAY_IN_THREAD(
              THREAD, u2, total_fields * (FieldInfo::field_slots + 1));
 
-  AnnotationArray* field_annotations = NULL;
-  AnnotationArray* field_type_annotations = NULL;
   // The generic signature slots start after all other fields' data.
   int generic_signature_slot = total_fields * FieldInfo::field_slots;
   int num_generic_signature = 0;
@@ -1161,53 +1112,52 @@
     access_flags.set_flags(flags);
 
     u2 name_index = cfs->get_u2_fast();
-    int cp_size = cp->length();
-    check_property(
-      valid_cp_range(name_index, cp_size) && cp->tag_at(name_index).is_utf8(),
+    int cp_size = _cp->length();
+    check_property(valid_symbol_at(name_index),
       "Invalid constant pool index %u for field name in class file %s",
-      name_index, CHECK_NULL);
-    Symbol*  name = cp->symbol_at(name_index);
+      name_index,
+      CHECK_NULL);
+    Symbol*  name = _cp->symbol_at(name_index);
     verify_legal_field_name(name, CHECK_NULL);
 
     u2 signature_index = cfs->get_u2_fast();
-    check_property(
-      valid_cp_range(signature_index, cp_size) &&
-        cp->tag_at(signature_index).is_utf8(),
+    check_property(valid_symbol_at(signature_index),
       "Invalid constant pool index %u for field signature in class file %s",
       signature_index, CHECK_NULL);
-    Symbol*  sig = cp->symbol_at(signature_index);
+    Symbol*  sig = _cp->symbol_at(signature_index);
     verify_legal_field_signature(name, sig, CHECK_NULL);
 
     u2 constantvalue_index = 0;
     bool is_synthetic = false;
     u2 generic_signature_index = 0;
     bool is_static = access_flags.is_static();
-    FieldAnnotationCollector parsed_annotations;
+    FieldAnnotationCollector parsed_annotations(_loader_data);
 
     u2 attributes_count = cfs->get_u2_fast();
     if (attributes_count > 0) {
-      parse_field_attributes(loader_data,
-                             cp, attributes_count, is_static, signature_index,
+      parse_field_attributes(attributes_count, is_static, signature_index,
                              &constantvalue_index, &is_synthetic,
-                             &generic_signature_index, &field_annotations,
-                             &field_type_annotations, &parsed_annotations,
+                             &generic_signature_index, &parsed_annotations,
                              CHECK_NULL);
-      if (field_annotations != NULL) {
-        if (*fields_annotations == NULL) {
-          *fields_annotations = MetadataFactory::new_array<AnnotationArray*>(
-                                             loader_data, length, NULL,
+      if (parsed_annotations.field_annotations() != NULL) {
+        if (_fields_annotations == NULL) {
+          _fields_annotations = MetadataFactory::new_array<AnnotationArray*>(
+                                             _loader_data, length, NULL,
                                              CHECK_NULL);
         }
-        (*fields_annotations)->at_put(n, field_annotations);
+        _fields_annotations->at_put(n, parsed_annotations.field_annotations());
+        parsed_annotations.set_field_annotations(NULL);
       }
-      if (field_type_annotations != NULL) {
-        if (*fields_type_annotations == NULL) {
-          *fields_type_annotations = MetadataFactory::new_array<AnnotationArray*>(
-                                                  loader_data, length, NULL,
+      if (parsed_annotations.field_type_annotations() != NULL) {
+        if (_fields_type_annotations == NULL) {
+          _fields_type_annotations = MetadataFactory::new_array<AnnotationArray*>(
+                                                  _loader_data, length, NULL,
                                                   CHECK_NULL);
         }
-        (*fields_type_annotations)->at_put(n, field_type_annotations);
+        _fields_type_annotations->at_put(n, parsed_annotations.field_type_annotations());
+        parsed_annotations.set_field_type_annotations(NULL);
       }
+
       if (is_synthetic) {
         access_flags.set_is_synthetic();
       }
@@ -1224,7 +1174,7 @@
                       name_index,
                       signature_index,
                       constantvalue_index);
-    BasicType type = cp->basic_type_for_signature_at(signature_index);
+    BasicType type = _cp->basic_type_for_signature_at(signature_index);
 
     // Remember how many oops we encountered and compute allocation type
     FieldAllocationType atype = fac->update(is_static, type);
@@ -1245,8 +1195,8 @@
         bool duplicate = false;
         for (int i = 0; i < length; i++) {
           FieldInfo* f = FieldInfo::from_field_array(fa, i);
-          if (name      == cp->symbol_at(f->name_index()) &&
-              signature == cp->symbol_at(f->signature_index())) {
+          if (name      == _cp->symbol_at(f->name_index()) &&
+              signature == _cp->symbol_at(f->signature_index())) {
             // Symbol is desclared in Java so skip this one
             duplicate = true;
             break;
@@ -1280,8 +1230,9 @@
   // fields array is trimed. Also unused slots that were reserved
   // for generic signature indexes are discarded.
   Array<u2>* fields = MetadataFactory::new_array<u2>(
-          loader_data, index * FieldInfo::field_slots + num_generic_signature,
+          _loader_data, index * FieldInfo::field_slots + num_generic_signature,
           CHECK_NULL);
+  _fields = fields; // save in case of error
   {
     int i = 0;
     for (; i < index * FieldInfo::field_slots; i++) {
@@ -1303,7 +1254,7 @@
     bool dup = false;
     {
       debug_only(No_Safepoint_Verifier nsv;)
-      for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) {
+      for (AllFieldStream fs(fields, _cp); !fs.done(); fs.next()) {
         Symbol* name = fs.name();
         Symbol* sig = fs.signature();
         // If no duplicates, add name/signature in hashtable names_and_sigs.
@@ -1330,10 +1281,8 @@
 }
 
 
-u2* ClassFileParser::parse_exception_table(ClassLoaderData* loader_data,
-                                           u4 code_length,
+u2* ClassFileParser::parse_exception_table(u4 code_length,
                                            u4 exception_table_length,
-                                           constantPoolHandle cp,
                                            TRAPS) {
   ClassFileStream* cfs = stream();
 
@@ -1354,8 +1303,7 @@
                          "Illegal exception table handler in class file %s",
                          CHECK_NULL);
       if (catch_type_index != 0) {
-        guarantee_property(valid_cp_range(catch_type_index, cp->length()) &&
-                           is_klass_reference(cp, catch_type_index),
+        guarantee_property(valid_klass_reference_at(catch_type_index),
                            "Catch type in exception table has bad constant type in class file %s", CHECK_NULL);
       }
     }
@@ -1506,7 +1454,6 @@
 u2* ClassFileParser::parse_localvariable_table(u4 code_length,
                                                u2 max_locals,
                                                u4 code_attribute_length,
-                                               constantPoolHandle cp,
                                                u2* localvariable_table_length,
                                                bool isLVTT,
                                                TRAPS) {
@@ -1544,20 +1491,16 @@
           "Invalid length %u in %s in class file %s",
           length, tbl_name, CHECK_NULL);
       }
-      int cp_size = cp->length();
-      guarantee_property(
-        valid_cp_range(name_index, cp_size) &&
-          cp->tag_at(name_index).is_utf8(),
+      int cp_size = _cp->length();
+      guarantee_property(valid_symbol_at(name_index),
         "Name index %u in %s has bad constant type in class file %s",
         name_index, tbl_name, CHECK_NULL);
-      guarantee_property(
-        valid_cp_range(descriptor_index, cp_size) &&
-          cp->tag_at(descriptor_index).is_utf8(),
+      guarantee_property(valid_symbol_at(descriptor_index),
         "Signature index %u in %s has bad constant type in class file %s",
         descriptor_index, tbl_name, CHECK_NULL);
 
-      Symbol*  name = cp->symbol_at(name_index);
-      Symbol*  sig = cp->symbol_at(descriptor_index);
+      Symbol*  name = _cp->symbol_at(name_index);
+      Symbol*  sig = _cp->symbol_at(descriptor_index);
       verify_legal_field_name(name, CHECK_NULL);
       u2 extra_slot = 0;
       if (!isLVTT) {
@@ -1579,7 +1522,7 @@
 
 
 void ClassFileParser::parse_type_array(u2 array_length, u4 code_length, u4* u1_index, u4* u2_index,
-                                      u1* u1_array, u2* u2_array, constantPoolHandle cp, TRAPS) {
+                                      u1* u1_array, u2* u2_array, TRAPS) {
   ClassFileStream* cfs = stream();
   u2 index = 0; // index in the array with long/double occupying two slots
   u4 i1 = *u1_index;
@@ -1591,8 +1534,7 @@
       index++;
     } else if (tag == ITEM_Object) {
       u2 class_index = u2_array[i2++] = cfs->get_u2(CHECK);
-      guarantee_property(valid_cp_range(class_index, cp->length()) &&
-                         is_klass_reference(cp, class_index),
+      guarantee_property(valid_klass_reference_at(class_index),
                          "Bad class index %u in StackMap in class file %s",
                          class_index, CHECK);
     } else if (tag == ITEM_Uninitialized) {
@@ -1613,8 +1555,7 @@
   *u2_index = i2;
 }
 
-Array<u1>* ClassFileParser::parse_stackmap_table(
-    ClassLoaderData* loader_data,
+u1* ClassFileParser::parse_stackmap_table(
     u4 code_attribute_length, TRAPS) {
   if (code_attribute_length == 0)
     return NULL;
@@ -1629,18 +1570,12 @@
   if (!_need_verify && !DumpSharedSpaces) {
     return NULL;
   }
-
-  Array<u1>* stackmap_data =
-    MetadataFactory::new_array<u1>(loader_data, code_attribute_length, 0, CHECK_NULL);
-
-  memcpy((void*)stackmap_data->adr_at(0),
-         (void*)stackmap_table_start, code_attribute_length);
-  return stackmap_data;
+  return stackmap_table_start;
 }
 
 u2* ClassFileParser::parse_checked_exceptions(u2* checked_exceptions_length,
                                               u4 method_attribute_length,
-                                              constantPoolHandle cp, TRAPS) {
+                                              TRAPS) {
   ClassFileStream* cfs = stream();
   cfs->guarantee_more(2, CHECK_NULL);  // checked_exceptions_length
   *checked_exceptions_length = cfs->get_u2_fast();
@@ -1657,8 +1592,7 @@
     for (int i = 0; i < len; i++) {
       checked_exception = cfs->get_u2_fast();
       check_property(
-        valid_cp_range(checked_exception, cp->length()) &&
-        is_klass_reference(cp, checked_exception),
+        valid_klass_reference_at(checked_exception),
         "Exception name has bad type at constant pool %u in class file %s",
         checked_exception, CHECK_NULL);
     }
@@ -1735,9 +1669,7 @@
 }
 
 // Sift through annotations, looking for those significant to the VM:
-void ClassFileParser::parse_annotations(ClassLoaderData* loader_data,
-                                        u1* buffer, int limit,
-                                        constantPoolHandle cp,
+void ClassFileParser::parse_annotations(u1* buffer, int limit,
                                         ClassFileParser::AnnotationCollector* coll,
                                         TRAPS) {
   // annotations := do(nann:u2) {annotation}
@@ -1767,17 +1699,17 @@
     u1* abase = buffer + index0;
     int atype = Bytes::get_Java_u2(abase + atype_off);
     int count = Bytes::get_Java_u2(abase + count_off);
-    Symbol* aname = check_symbol_at(cp, atype);
+    Symbol* aname = check_symbol_at(_cp, atype);
     if (aname == NULL)  break;  // invalid annotation name
     Symbol* member = NULL;
     if (count >= 1) {
       int member_index = Bytes::get_Java_u2(abase + member_off);
-      member = check_symbol_at(cp, member_index);
+      member = check_symbol_at(_cp, member_index);
       if (member == NULL)  break;  // invalid member name
     }
 
     // Here is where parsing particular annotations will take place.
-    AnnotationCollector::ID id = coll->annotation_index(loader_data, aname);
+    AnnotationCollector::ID id = coll->annotation_index(_loader_data, aname);
     if (id == AnnotationCollector::_unknown)  continue;
     coll->set_annotation(id);
 
@@ -1836,6 +1768,12 @@
     f->set_contended_group(contended_group());
 }
 
+ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
+  // If there's an error deallocate metadata for field annotations
+  MetadataFactory::free_array<u1>(_loader_data, _field_annotations);
+  MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations);
+}
+
 void ClassFileParser::MethodAnnotationCollector::apply_to(methodHandle m) {
   if (has_annotation(_method_ForceInline))
     m->set_force_inline(true);
@@ -1894,10 +1832,9 @@
           && _need_verify
           && _major_version >= JAVA_1_5_VERSION) {
         clear_hashtable(lvt_Hash);
-        ConstantPool* cp = cm->constants();
         classfile_parse_error("Duplicated LocalVariableTable attribute "
                               "entry for '%s' in class file %s",
-                               cp->symbol_at(lvt->name_cp_index)->as_utf8(),
+                               _cp->symbol_at(lvt->name_cp_index)->as_utf8(),
                                CHECK);
       }
     }
@@ -1916,18 +1853,16 @@
       if (entry == NULL) {
         if (_need_verify) {
           clear_hashtable(lvt_Hash);
-          ConstantPool* cp = cm->constants();
           classfile_parse_error("LVTT entry for '%s' in class file %s "
                                 "does not match any LVT entry",
-                                 cp->symbol_at(lvtt_elem.name_cp_index)->as_utf8(),
+                                 _cp->symbol_at(lvtt_elem.name_cp_index)->as_utf8(),
                                  CHECK);
         }
       } else if (entry->_elem->signature_cp_index != 0 && _need_verify) {
         clear_hashtable(lvt_Hash);
-        ConstantPool* cp = cm->constants();
         classfile_parse_error("Duplicated LocalVariableTypeTable attribute "
                               "entry for '%s' in class file %s",
-                               cp->symbol_at(lvtt_elem.name_cp_index)->as_utf8(),
+                               _cp->symbol_at(lvtt_elem.name_cp_index)->as_utf8(),
                                CHECK);
       } else {
         // to add generic signatures into LocalVariableTable
@@ -1939,8 +1874,7 @@
 }
 
 
-void ClassFileParser::copy_method_annotations(ClassLoaderData* loader_data,
-                                       ConstMethod* cm,
+void ClassFileParser::copy_method_annotations(ConstMethod* cm,
                                        u1* runtime_visible_annotations,
                                        int runtime_visible_annotations_length,
                                        u1* runtime_invisible_annotations,
@@ -1961,8 +1895,7 @@
 
   if (runtime_visible_annotations_length +
       runtime_invisible_annotations_length > 0) {
-     a = assemble_annotations(loader_data,
-                              runtime_visible_annotations,
+     a = assemble_annotations(runtime_visible_annotations,
                               runtime_visible_annotations_length,
                               runtime_invisible_annotations,
                               runtime_invisible_annotations_length,
@@ -1972,8 +1905,7 @@
 
   if (runtime_visible_parameter_annotations_length +
       runtime_invisible_parameter_annotations_length > 0) {
-    a = assemble_annotations(loader_data,
-                             runtime_visible_parameter_annotations,
+    a = assemble_annotations(runtime_visible_parameter_annotations,
                              runtime_visible_parameter_annotations_length,
                              runtime_invisible_parameter_annotations,
                              runtime_invisible_parameter_annotations_length,
@@ -1982,8 +1914,7 @@
   }
 
   if (annotation_default_length > 0) {
-    a = assemble_annotations(loader_data,
-                             annotation_default,
+    a = assemble_annotations(annotation_default,
                              annotation_default_length,
                              NULL,
                              0,
@@ -1993,8 +1924,7 @@
 
   if (runtime_visible_type_annotations_length +
       runtime_invisible_type_annotations_length > 0) {
-    a = assemble_annotations(loader_data,
-                             runtime_visible_type_annotations,
+    a = assemble_annotations(runtime_visible_type_annotations,
                              runtime_visible_type_annotations_length,
                              runtime_invisible_type_annotations,
                              runtime_invisible_type_annotations_length,
@@ -2013,9 +1943,7 @@
 // from the method back up to the containing klass. These flag values
 // are added to klass's access_flags.
 
-methodHandle ClassFileParser::parse_method(ClassLoaderData* loader_data,
-                                           constantPoolHandle cp,
-                                           bool is_interface,
+methodHandle ClassFileParser::parse_method(bool is_interface,
                                            AccessFlags *promoted_flags,
                                            TRAPS) {
   ClassFileStream* cfs = stream();
@@ -2026,22 +1954,20 @@
 
   int flags = cfs->get_u2_fast();
   u2 name_index = cfs->get_u2_fast();
-  int cp_size = cp->length();
+  int cp_size = _cp->length();
   check_property(
-    valid_cp_range(name_index, cp_size) &&
-      cp->tag_at(name_index).is_utf8(),
+    valid_symbol_at(name_index),
     "Illegal constant pool index %u for method name in class file %s",
     name_index, CHECK_(nullHandle));
-  Symbol*  name = cp->symbol_at(name_index);
+  Symbol*  name = _cp->symbol_at(name_index);
   verify_legal_method_name(name, CHECK_(nullHandle));
 
   u2 signature_index = cfs->get_u2_fast();
   guarantee_property(
-    valid_cp_range(signature_index, cp_size) &&
-      cp->tag_at(signature_index).is_utf8(),
+    valid_symbol_at(signature_index),
     "Illegal constant pool index %u for method signature in class file %s",
     signature_index, CHECK_(nullHandle));
-  Symbol*  signature = cp->symbol_at(signature_index);
+  Symbol*  signature = _cp->symbol_at(signature_index);
 
   AccessFlags access_flags;
   if (name == vmSymbols::class_initializer_name()) {
@@ -2097,7 +2023,8 @@
   bool parsed_checked_exceptions_attribute = false;
   bool parsed_stackmap_attribute = false;
   // stackmap attribute - JDK1.5
-  Array<u1>* stackmap_data = NULL;
+  u1* stackmap_data = NULL;
+  int stackmap_data_length = 0;
   u2 generic_signature_index = 0;
   MethodAnnotationCollector parsed_annotations;
   u1* runtime_visible_annotations = NULL;
@@ -2122,12 +2049,11 @@
     u2 method_attribute_name_index = cfs->get_u2_fast();
     u4 method_attribute_length = cfs->get_u4_fast();
     check_property(
-      valid_cp_range(method_attribute_name_index, cp_size) &&
-        cp->tag_at(method_attribute_name_index).is_utf8(),
+      valid_symbol_at(method_attribute_name_index),
       "Invalid method attribute name index %u in class file %s",
       method_attribute_name_index, CHECK_(nullHandle));
 
-    Symbol* method_attribute_name = cp->symbol_at(method_attribute_name_index);
+    Symbol* method_attribute_name = _cp->symbol_at(method_attribute_name_index);
     if (method_attribute_name == vmSymbols::tag_code()) {
       // Parse Code attribute
       if (_need_verify) {
@@ -2171,7 +2097,7 @@
       exception_table_length = cfs->get_u2_fast();
       if (exception_table_length > 0) {
         exception_table_start =
-              parse_exception_table(loader_data, code_length, exception_table_length, cp, CHECK_(nullHandle));
+              parse_exception_table(code_length, exception_table_length, CHECK_(nullHandle));
       }
 
       // Parse additional attributes in code attribute
@@ -2204,19 +2130,18 @@
         calculated_attribute_length += code_attribute_length +
                                        sizeof(code_attribute_name_index) +
                                        sizeof(code_attribute_length);
-        check_property(valid_cp_range(code_attribute_name_index, cp_size) &&
-                       cp->tag_at(code_attribute_name_index).is_utf8(),
+        check_property(valid_symbol_at(code_attribute_name_index),
                        "Invalid code attribute name index %u in class file %s",
                        code_attribute_name_index,
                        CHECK_(nullHandle));
         if (LoadLineNumberTables &&
-            cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_line_number_table()) {
+            _cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_line_number_table()) {
           // Parse and compress line number table
           parse_linenumber_table(code_attribute_length, code_length,
             &linenumber_table, CHECK_(nullHandle));
 
         } else if (LoadLocalVariableTables &&
-                   cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_local_variable_table()) {
+                   _cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_local_variable_table()) {
           // Parse local variable table
           if (!lvt_allocated) {
             localvariable_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
@@ -2238,7 +2163,6 @@
             parse_localvariable_table(code_length,
                                       max_locals,
                                       code_attribute_length,
-                                      cp,
                                       &localvariable_table_length[lvt_cnt],
                                       false,    // is not LVTT
                                       CHECK_(nullHandle));
@@ -2246,7 +2170,7 @@
           lvt_cnt++;
         } else if (LoadLocalVariableTypeTables &&
                    _major_version >= JAVA_1_5_VERSION &&
-                   cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_local_variable_type_table()) {
+                   _cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_local_variable_type_table()) {
           if (!lvt_allocated) {
             localvariable_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
               THREAD, u2,  INITIAL_MAX_LVT_NUMBER);
@@ -2268,19 +2192,19 @@
             parse_localvariable_table(code_length,
                                       max_locals,
                                       code_attribute_length,
-                                      cp,
                                       &localvariable_type_table_length[lvtt_cnt],
                                       true,     // is LVTT
                                       CHECK_(nullHandle));
           lvtt_cnt++;
         } else if (UseSplitVerifier &&
                    _major_version >= Verifier::STACKMAP_ATTRIBUTE_MAJOR_VERSION &&
-                   cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_stack_map_table()) {
+                   _cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_stack_map_table()) {
           // Stack map is only needed by the new verifier in JDK1.5.
           if (parsed_stackmap_attribute) {
             classfile_parse_error("Multiple StackMapTable attributes in class file %s", CHECK_(nullHandle));
           }
-          stackmap_data = parse_stackmap_table(loader_data, code_attribute_length, CHECK_(nullHandle));
+          stackmap_data = parse_stackmap_table(code_attribute_length, CHECK_(nullHandle));
+          stackmap_data_length = code_attribute_length;
           parsed_stackmap_attribute = true;
         } else {
           // Skip unknown attributes
@@ -2301,7 +2225,7 @@
       checked_exceptions_start =
             parse_checked_exceptions(&checked_exceptions_length,
                                      method_attribute_length,
-                                     cp, CHECK_(nullHandle));
+                                     CHECK_(nullHandle));
     } else if (method_attribute_name == vmSymbols::tag_method_parameters()) {
       // reject multiple method parameters
       if (method_parameters_seen) {
@@ -2359,9 +2283,8 @@
         runtime_visible_annotations_length = method_attribute_length;
         runtime_visible_annotations = cfs->get_u1_buffer();
         assert(runtime_visible_annotations != NULL, "null visible annotations");
-        parse_annotations(loader_data,
-            runtime_visible_annotations,
-            runtime_visible_annotations_length, cp, &parsed_annotations,
+        parse_annotations(runtime_visible_annotations,
+            runtime_visible_annotations_length, &parsed_annotations,
             CHECK_(nullHandle));
         cfs->skip_u1(runtime_visible_annotations_length, CHECK_(nullHandle));
       } else if (PreserveAllAnnotations && method_attribute_name == vmSymbols::tag_runtime_invisible_annotations()) {
@@ -2434,18 +2357,18 @@
       0);
 
   Method* m = Method::allocate(
-      loader_data, code_length, access_flags, &sizes,
+      _loader_data, code_length, access_flags, &sizes,
       ConstMethod::NORMAL, CHECK_(nullHandle));
 
   ClassLoadingService::add_class_method_size(m->size()*HeapWordSize);
 
   // Fill in information from fixed part (access_flags already set)
-  m->set_constants(cp());
+  m->set_constants(_cp);
   m->set_name_index(name_index);
   m->set_signature_index(signature_index);
 #ifdef CC_INTERP
   // hmm is there a gc issue here??
-  ResultTypeFinder rtf(cp->symbol_at(signature_index));
+  ResultTypeFinder rtf(_cp->symbol_at(signature_index));
   m->set_result_index(rtf.type());
 #endif
 
@@ -2464,7 +2387,10 @@
   // Fill in code attribute information
   m->set_max_stack(max_stack);
   m->set_max_locals(max_locals);
-  m->constMethod()->set_stackmap_data(stackmap_data);
+  if (stackmap_data != NULL) {
+    m->constMethod()->copy_stackmap_data(_loader_data, stackmap_data,
+                                         stackmap_data_length, CHECK_NULL);
+  }
 
   // Copy byte codes
   m->set_code(code_start);
@@ -2520,7 +2446,7 @@
     parsed_annotations.apply_to(m);
 
   // Copy annotations
-  copy_method_annotations(loader_data, m->constMethod(),
+  copy_method_annotations(m->constMethod(),
                           runtime_visible_annotations,
                           runtime_visible_annotations_length,
                           runtime_invisible_annotations,
@@ -2560,9 +2486,7 @@
 // from the methods back up to the containing klass. These flag values
 // are added to klass's access_flags.
 
-Array<Method*>* ClassFileParser::parse_methods(ClassLoaderData* loader_data,
-                                               constantPoolHandle cp,
-                                               bool is_interface,
+Array<Method*>* ClassFileParser::parse_methods(bool is_interface,
                                                AccessFlags* promoted_flags,
                                                bool* has_final_method,
                                                bool* has_default_methods,
@@ -2571,15 +2495,13 @@
   cfs->guarantee_more(2, CHECK_NULL);  // length
   u2 length = cfs->get_u2_fast();
   if (length == 0) {
-    return Universe::the_empty_method_array();
+    _methods = Universe::the_empty_method_array();
   } else {
-    // FIXME: Handle leaks at later failures.
-    Array<Method*>* methods = MetadataFactory::new_array<Method*>(loader_data, length, NULL, CHECK_NULL);
+    _methods = MetadataFactory::new_array<Method*>(_loader_data, length, NULL, CHECK_NULL);
 
     HandleMark hm(THREAD);
     for (int index = 0; index < length; index++) {
-      methodHandle method = parse_method(loader_data,
-                                         cp, is_interface,
+      methodHandle method = parse_method(is_interface,
                                          promoted_flags,
                                          CHECK_NULL);
 
@@ -2590,7 +2512,7 @@
         // default method
         *has_default_methods = true;
       }
-      methods->at_put(index, method());
+      _methods->at_put(index, method());
     }
 
     if (_need_verify && length > 1) {
@@ -2603,7 +2525,7 @@
       {
         debug_only(No_Safepoint_Verifier nsv;)
         for (int i = 0; i < length; i++) {
-          Method* m = methods->at(i);
+          Method* m = _methods->at(i);
           // If no duplicates, add name/signature in hashtable names_and_sigs.
           if (!put_after_lookup(m->name(), m->signature(), names_and_sigs)) {
             dup = true;
@@ -2616,14 +2538,12 @@
                               CHECK_NULL);
       }
     }
-    return methods;
   }
+  return _methods;
 }
 
 
-Array<int>* ClassFileParser::sort_methods(ClassLoaderData* loader_data,
-                                          Array<Method*>* methods,
-                                          TRAPS) {
+intArray* ClassFileParser::sort_methods(Array<Method*>* methods) {
   int length = methods->length();
   // If JVMTI original method ordering or sharing is enabled we have to
   // remember the original class file ordering.
@@ -2641,10 +2561,11 @@
   // Note that the ordering is not alphabetical, see Symbol::fast_compare
   Method::sort_methods(methods);
 
+  intArray* method_ordering = NULL;
   // If JVMTI original method ordering or sharing is enabled construct int
   // array remembering the original ordering
   if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) {
-    Array<int>* method_ordering = MetadataFactory::new_array<int>(loader_data, length, CHECK_NULL);
+    method_ordering = new intArray(length);
     for (int index = 0; index < length; index++) {
       Method* m = methods->at(index);
       int old_index = m->vtable_index();
@@ -2652,29 +2573,25 @@
       method_ordering->at_put(index, old_index);
       m->set_vtable_index(Method::invalid_vtable_index);
     }
-    return method_ordering;
-  } else {
-    return Universe::the_empty_int_array();
   }
+  return method_ordering;
 }
 
 
-void ClassFileParser::parse_classfile_sourcefile_attribute(constantPoolHandle cp, TRAPS) {
+void ClassFileParser::parse_classfile_sourcefile_attribute(TRAPS) {
   ClassFileStream* cfs = stream();
   cfs->guarantee_more(2, CHECK);  // sourcefile_index
   u2 sourcefile_index = cfs->get_u2_fast();
   check_property(
-    valid_cp_range(sourcefile_index, cp->length()) &&
-      cp->tag_at(sourcefile_index).is_utf8(),
+    valid_symbol_at(sourcefile_index),
     "Invalid SourceFile attribute at constant pool index %u in class file %s",
     sourcefile_index, CHECK);
-  set_class_sourcefile(cp->symbol_at(sourcefile_index));
+  set_class_sourcefile(_cp->symbol_at(sourcefile_index));
 }
 
 
 
-void ClassFileParser::parse_classfile_source_debug_extension_attribute(constantPoolHandle cp,
-                                                                       int length, TRAPS) {
+void ClassFileParser::parse_classfile_source_debug_extension_attribute(int length, TRAPS) {
   ClassFileStream* cfs = stream();
   u1* sde_buffer = cfs->get_u1_buffer();
   assert(sde_buffer != NULL, "null sde buffer");
@@ -2698,12 +2615,10 @@
 #define RECOGNIZED_INNER_CLASS_MODIFIERS (JVM_RECOGNIZED_CLASS_MODIFIERS | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED | JVM_ACC_STATIC)
 
 // Return number of classes in the inner classes attribute table
-u2 ClassFileParser::parse_classfile_inner_classes_attribute(ClassLoaderData* loader_data,
-                                                            u1* inner_classes_attribute_start,
+u2 ClassFileParser::parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start,
                                                             bool parsed_enclosingmethod_attribute,
                                                             u2 enclosing_method_class_index,
                                                             u2 enclosing_method_method_index,
-                                                            constantPoolHandle cp,
                                                             TRAPS) {
   ClassFileStream* cfs = stream();
   u1* current_mark = cfs->current();
@@ -2724,33 +2639,31 @@
   //    enclosing_method_class_index,
   //    enclosing_method_method_index]
   int size = length * 4 + (parsed_enclosingmethod_attribute ? 2 : 0);
-  // FIXME: Will leak on exceptions.
-  Array<u2>* inner_classes = MetadataFactory::new_array<u2>(loader_data, size, CHECK_0);
+  Array<u2>* inner_classes = MetadataFactory::new_array<u2>(_loader_data, size, CHECK_0);
+  _inner_classes = inner_classes;
+
   int index = 0;
-  int cp_size = cp->length();
+  int cp_size = _cp->length();
   cfs->guarantee_more(8 * length, CHECK_0);  // 4-tuples of u2
   for (int n = 0; n < length; n++) {
     // Inner class index
     u2 inner_class_info_index = cfs->get_u2_fast();
     check_property(
       inner_class_info_index == 0 ||
-        (valid_cp_range(inner_class_info_index, cp_size) &&
-        is_klass_reference(cp, inner_class_info_index)),
+        valid_klass_reference_at(inner_class_info_index),
       "inner_class_info_index %u has bad constant type in class file %s",
       inner_class_info_index, CHECK_0);
     // Outer class index
     u2 outer_class_info_index = cfs->get_u2_fast();
     check_property(
       outer_class_info_index == 0 ||
-        (valid_cp_range(outer_class_info_index, cp_size) &&
-        is_klass_reference(cp, outer_class_info_index)),
+        valid_klass_reference_at(outer_class_info_index),
       "outer_class_info_index %u has bad constant type in class file %s",
       outer_class_info_index, CHECK_0);
     // Inner class name
     u2 inner_name_index = cfs->get_u2_fast();
     check_property(
-      inner_name_index == 0 || (valid_cp_range(inner_name_index, cp_size) &&
-        cp->tag_at(inner_name_index).is_utf8()),
+      inner_name_index == 0 || valid_symbol_at(inner_name_index),
       "inner_name_index %u has bad constant type in class file %s",
       inner_name_index, CHECK_0);
     if (_need_verify) {
@@ -2794,33 +2707,27 @@
   }
   assert(index == size, "wrong size");
 
-  // Update InstanceKlass with inner class info.
-  set_class_inner_classes(inner_classes);
-
   // Restore buffer's current position.
   cfs->set_current(current_mark);
 
   return length;
 }
 
-void ClassFileParser::parse_classfile_synthetic_attribute(constantPoolHandle cp, TRAPS) {
+void ClassFileParser::parse_classfile_synthetic_attribute(TRAPS) {
   set_class_synthetic_flag(true);
 }
 
-void ClassFileParser::parse_classfile_signature_attribute(constantPoolHandle cp, TRAPS) {
+void ClassFileParser::parse_classfile_signature_attribute(TRAPS) {
   ClassFileStream* cfs = stream();
   u2 signature_index = cfs->get_u2(CHECK);
   check_property(
-    valid_cp_range(signature_index, cp->length()) &&
-      cp->tag_at(signature_index).is_utf8(),
+    valid_symbol_at(signature_index),
     "Invalid constant pool index %u in Signature attribute in class file %s",
     signature_index, CHECK);
-  set_class_generic_signature(cp->symbol_at(signature_index));
+  set_class_generic_signature(_cp->symbol_at(signature_index));
 }
 
-void ClassFileParser::parse_classfile_bootstrap_methods_attribute(ClassLoaderData* loader_data,
-                                                                  constantPoolHandle cp,
-                                                                  u4 attribute_byte_length, TRAPS) {
+void ClassFileParser::parse_classfile_bootstrap_methods_attribute(u4 attribute_byte_length, TRAPS) {
   ClassFileStream* cfs = stream();
   u1* current_start = cfs->current();
 
@@ -2841,10 +2748,14 @@
   // The array begins with a series of short[2] pairs, one for each tuple.
   int index_size = (attribute_array_length * 2);
 
-  Array<u2>* operands = MetadataFactory::new_array<u2>(loader_data, index_size + operand_count, CHECK);
+  Array<u2>* operands = MetadataFactory::new_array<u2>(_loader_data, index_size + operand_count, CHECK);
+
+  // Eagerly assign operands so they will be deallocated with the constant
+  // pool if there is an error.
+  _cp->set_operands(operands);
 
   int operand_fill_index = index_size;
-  int cp_size = cp->length();
+  int cp_size = _cp->length();
 
   for (int n = 0; n < attribute_array_length; n++) {
     // Store a 32-bit offset into the header of the operand array.
@@ -2856,7 +2767,7 @@
     u2 argument_count = cfs->get_u2_fast();
     check_property(
       valid_cp_range(bootstrap_method_index, cp_size) &&
-      cp->tag_at(bootstrap_method_index).is_method_handle(),
+      _cp->tag_at(bootstrap_method_index).is_method_handle(),
       "bootstrap_method_index %u has bad constant type in class file %s",
       bootstrap_method_index,
       CHECK);
@@ -2868,7 +2779,7 @@
       u2 argument_index = cfs->get_u2_fast();
       check_property(
         valid_cp_range(argument_index, cp_size) &&
-        cp->tag_at(argument_index).is_loadable_constant(),
+        _cp->tag_at(argument_index).is_loadable_constant(),
         "argument_index %u has bad constant type in class file %s",
         argument_index,
         CHECK);
@@ -2883,17 +2794,13 @@
   guarantee_property(current_end == current_start + attribute_byte_length,
                      "Bad length on BootstrapMethods in class file %s",
                      CHECK);
-
-  cp->set_operands(operands);
 }
 
-void ClassFileParser::parse_classfile_attributes(ClassLoaderData* loader_data,
-                                                 constantPoolHandle cp,
-                                                 ClassFileParser::ClassAnnotationCollector* parsed_annotations,
+void ClassFileParser::parse_classfile_attributes(ClassFileParser::ClassAnnotationCollector* parsed_annotations,
                                                  TRAPS) {
   ClassFileStream* cfs = stream();
   // Set inner classes attribute to default sentinel
-  set_class_inner_classes(Universe::the_empty_short_array());
+  _inner_classes = Universe::the_empty_short_array();
   cfs->guarantee_more(2, CHECK);  // attributes_count
   u2 attributes_count = cfs->get_u2_fast();
   bool parsed_sourcefile_attribute = false;
@@ -2918,11 +2825,10 @@
     u2 attribute_name_index = cfs->get_u2_fast();
     u4 attribute_length = cfs->get_u4_fast();
     check_property(
-      valid_cp_range(attribute_name_index, cp->length()) &&
-        cp->tag_at(attribute_name_index).is_utf8(),
+      valid_symbol_at(attribute_name_index),
       "Attribute name has bad constant pool index %u in class file %s",
       attribute_name_index, CHECK);
-    Symbol* tag = cp->symbol_at(attribute_name_index);
+    Symbol* tag = _cp->symbol_at(attribute_name_index);
     if (tag == vmSymbols::tag_source_file()) {
       // Check for SourceFile tag
       if (_need_verify) {
@@ -2933,10 +2839,10 @@
       } else {
         parsed_sourcefile_attribute = true;
       }
-      parse_classfile_sourcefile_attribute(cp, CHECK);
+      parse_classfile_sourcefile_attribute(CHECK);
     } else if (tag == vmSymbols::tag_source_debug_extension()) {
       // Check for SourceDebugExtension tag
-      parse_classfile_source_debug_extension_attribute(cp, (int)attribute_length, CHECK);
+      parse_classfile_source_debug_extension_attribute((int)attribute_length, CHECK);
     } else if (tag == vmSymbols::tag_inner_classes()) {
       // Check for InnerClasses tag
       if (parsed_innerclasses_attribute) {
@@ -2955,7 +2861,7 @@
           "Invalid Synthetic classfile attribute length %u in class file %s",
           attribute_length, CHECK);
       }
-      parse_classfile_synthetic_attribute(cp, CHECK);
+      parse_classfile_synthetic_attribute(CHECK);
     } else if (tag == vmSymbols::tag_deprecated()) {
       // Check for Deprecatd tag - 4276120
       if (attribute_length != 0) {
@@ -2970,15 +2876,13 @@
             "Wrong Signature attribute length %u in class file %s",
             attribute_length, CHECK);
         }
-        parse_classfile_signature_attribute(cp, CHECK);
+        parse_classfile_signature_attribute(CHECK);
       } else if (tag == vmSymbols::tag_runtime_visible_annotations()) {
         runtime_visible_annotations_length = attribute_length;
         runtime_visible_annotations = cfs->get_u1_buffer();
         assert(runtime_visible_annotations != NULL, "null visible annotations");
-        parse_annotations(loader_data,
-                          runtime_visible_annotations,
+        parse_annotations(runtime_visible_annotations,
                           runtime_visible_annotations_length,
-                          cp,
                           parsed_annotations,
                           CHECK);
         cfs->skip_u1(runtime_visible_annotations_length, CHECK);
@@ -3000,13 +2904,11 @@
           classfile_parse_error("Invalid class index in EnclosingMethod attribute in class file %s", CHECK);
         }
         // Validate the constant pool indices and types
-        if (!cp->is_within_bounds(enclosing_method_class_index) ||
-            !is_klass_reference(cp, enclosing_method_class_index)) {
-          classfile_parse_error("Invalid or out-of-bounds class index in EnclosingMethod attribute in class file %s", CHECK);
-        }
+        check_property(valid_klass_reference_at(enclosing_method_class_index),
+          "Invalid or out-of-bounds class index in EnclosingMethod attribute in class file %s", CHECK);
         if (enclosing_method_method_index != 0 &&
-            (!cp->is_within_bounds(enclosing_method_method_index) ||
-             !cp->tag_at(enclosing_method_method_index).is_name_and_type())) {
+            (!_cp->is_within_bounds(enclosing_method_method_index) ||
+             !_cp->tag_at(enclosing_method_method_index).is_name_and_type())) {
           classfile_parse_error("Invalid or out-of-bounds method index in EnclosingMethod attribute in class file %s", CHECK);
         }
       } else if (tag == vmSymbols::tag_bootstrap_methods() &&
@@ -3014,7 +2916,7 @@
         if (parsed_bootstrap_methods_attribute)
           classfile_parse_error("Multiple BootstrapMethods attributes in class file %s", CHECK);
         parsed_bootstrap_methods_attribute = true;
-        parse_classfile_bootstrap_methods_attribute(loader_data, cp, attribute_length, CHECK);
+        parse_classfile_bootstrap_methods_attribute(attribute_length, CHECK);
       } else if (tag == vmSymbols::tag_runtime_visible_type_annotations()) {
         runtime_visible_type_annotations_length = attribute_length;
         runtime_visible_type_annotations = cfs->get_u1_buffer();
@@ -3035,29 +2937,24 @@
       cfs->skip_u1(attribute_length, CHECK);
     }
   }
-  AnnotationArray* annotations = assemble_annotations(loader_data,
-                                                      runtime_visible_annotations,
-                                                      runtime_visible_annotations_length,
-                                                      runtime_invisible_annotations,
-                                                      runtime_invisible_annotations_length,
-                                                      CHECK);
-  set_class_annotations(annotations);
-  AnnotationArray* type_annotations = assemble_annotations(loader_data,
-                                                           runtime_visible_type_annotations,
-                                                           runtime_visible_type_annotations_length,
-                                                           runtime_invisible_type_annotations,
-                                                           runtime_invisible_type_annotations_length,
-                                                           CHECK);
-  set_class_type_annotations(type_annotations);
+  _annotations = assemble_annotations(runtime_visible_annotations,
+                                      runtime_visible_annotations_length,
+                                      runtime_invisible_annotations,
+                                      runtime_invisible_annotations_length,
+                                      CHECK);
+  _type_annotations = assemble_annotations(runtime_visible_type_annotations,
+                                           runtime_visible_type_annotations_length,
+                                           runtime_invisible_type_annotations,
+                                           runtime_invisible_type_annotations_length,
+                                           CHECK);
 
   if (parsed_innerclasses_attribute || parsed_enclosingmethod_attribute) {
     u2 num_of_classes = parse_classfile_inner_classes_attribute(
-                            loader_data,
                             inner_classes_attribute_start,
                             parsed_innerclasses_attribute,
                             enclosing_method_class_index,
                             enclosing_method_method_index,
-                            cp, CHECK);
+                            CHECK);
     if (parsed_innerclasses_attribute &&_need_verify && _major_version >= JAVA_1_5_VERSION) {
       guarantee_property(
         inner_classes_attribute_length == sizeof(num_of_classes) + 4 * sizeof(u2) * num_of_classes,
@@ -3085,18 +2982,43 @@
   if (_sde_buffer != NULL) {
     k->set_source_debug_extension(_sde_buffer, _sde_length);
   }
-  k->set_inner_classes(_inner_classes);
 }
 
-AnnotationArray* ClassFileParser::assemble_annotations(ClassLoaderData* loader_data,
-                                                       u1* runtime_visible_annotations,
+// Transfer ownership of metadata allocated to the InstanceKlass.
+void ClassFileParser::apply_parsed_class_metadata(
+                                            instanceKlassHandle this_klass,
+                                            int java_fields_count, TRAPS) {
+  // Assign annotations if needed
+  if (_annotations != NULL || _type_annotations != NULL ||
+      _fields_annotations != NULL || _fields_type_annotations != NULL) {
+    Annotations* annotations = Annotations::allocate(_loader_data, CHECK);
+    annotations->set_class_annotations(_annotations);
+    annotations->set_class_type_annotations(_type_annotations);
+    annotations->set_fields_annotations(_fields_annotations);
+    annotations->set_fields_type_annotations(_fields_type_annotations);
+    this_klass->set_annotations(annotations);
+  }
+
+  _cp->set_pool_holder(this_klass());
+  this_klass->set_constants(_cp);
+  this_klass->set_fields(_fields, java_fields_count);
+  this_klass->set_methods(_methods);
+  this_klass->set_inner_classes(_inner_classes);
+  this_klass->set_local_interfaces(_local_interfaces);
+  this_klass->set_transitive_interfaces(_transitive_interfaces);
+
+  // Clear out these fields so they don't get deallocated by the destructor
+  clear_class_metadata();
+}
+
+AnnotationArray* ClassFileParser::assemble_annotations(u1* runtime_visible_annotations,
                                                        int runtime_visible_annotations_length,
                                                        u1* runtime_invisible_annotations,
                                                        int runtime_invisible_annotations_length, TRAPS) {
   AnnotationArray* annotations = NULL;
   if (runtime_visible_annotations != NULL ||
       runtime_invisible_annotations != NULL) {
-    annotations = MetadataFactory::new_array<u1>(loader_data,
+    annotations = MetadataFactory::new_array<u1>(_loader_data,
                                           runtime_visible_annotations_length +
                                           runtime_invisible_annotations_length,
                                           CHECK_(annotations));
@@ -3144,6 +3066,581 @@
 #endif // ndef PRODUCT
 
 
+instanceKlassHandle ClassFileParser::parse_super_class(int super_class_index,
+                                                       TRAPS) {
+  instanceKlassHandle super_klass;
+  if (super_class_index == 0) {
+    check_property(_class_name == vmSymbols::java_lang_Object(),
+                   "Invalid superclass index %u in class file %s",
+                   super_class_index,
+                   CHECK_NULL);
+  } else {
+    check_property(valid_klass_reference_at(super_class_index),
+                   "Invalid superclass index %u in class file %s",
+                   super_class_index,
+                   CHECK_NULL);
+    // The class name should be legal because it is checked when parsing constant pool.
+    // However, make sure it is not an array type.
+    bool is_array = false;
+    if (_cp->tag_at(super_class_index).is_klass()) {
+      super_klass = instanceKlassHandle(THREAD, _cp->resolved_klass_at(super_class_index));
+      if (_need_verify)
+        is_array = super_klass->oop_is_array();
+    } else if (_need_verify) {
+      is_array = (_cp->unresolved_klass_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY);
+    }
+    if (_need_verify) {
+      guarantee_property(!is_array,
+                        "Bad superclass name in class file %s", CHECK_NULL);
+    }
+  }
+  return super_klass;
+}
+
+
+// Values needed for oopmap and InstanceKlass creation
+class FieldLayoutInfo : public StackObj {
+ public:
+  int*          nonstatic_oop_offsets;
+  unsigned int* nonstatic_oop_counts;
+  unsigned int  nonstatic_oop_map_count;
+  unsigned int  total_oop_map_count;
+  int           instance_size;
+  int           nonstatic_field_size;
+  int           static_field_size;
+  bool          has_nonstatic_fields;
+};
+
+// Layout fields and fill in FieldLayoutInfo.  Could use more refactoring!
+void ClassFileParser::layout_fields(Handle class_loader,
+                                    FieldAllocationCount* fac,
+                                    ClassAnnotationCollector* parsed_annotations,
+                                    FieldLayoutInfo* info,
+                                    TRAPS) {
+
+  // get the padding width from the option
+  // TODO: Ask VM about specific CPU we are running on
+  int pad_size = ContendedPaddingWidth;
+
+  // Field size and offset computation
+  int nonstatic_field_size = _super_klass() == NULL ? 0 : _super_klass()->nonstatic_field_size();
+#ifndef PRODUCT
+  int orig_nonstatic_field_size = 0;
+#endif
+  int next_static_oop_offset;
+  int next_static_double_offset;
+  int next_static_word_offset;
+  int next_static_short_offset;
+  int next_static_byte_offset;
+  int next_nonstatic_oop_offset;
+  int next_nonstatic_double_offset;
+  int next_nonstatic_word_offset;
+  int next_nonstatic_short_offset;
+  int next_nonstatic_byte_offset;
+  int next_nonstatic_type_offset;
+  int first_nonstatic_oop_offset;
+  int first_nonstatic_field_offset;
+  int next_nonstatic_field_offset;
+  int next_nonstatic_padded_offset;
+
+  // Count the contended fields by type.
+  int nonstatic_contended_count = 0;
+  FieldAllocationCount fac_contended;
+  for (AllFieldStream fs(_fields, _cp); !fs.done(); fs.next()) {
+    FieldAllocationType atype = (FieldAllocationType) fs.allocation_type();
+    if (fs.is_contended()) {
+      fac_contended.count[atype]++;
+      if (!fs.access_flags().is_static()) {
+        nonstatic_contended_count++;
+      }
+    }
+  }
+  int contended_count = nonstatic_contended_count;
+
+
+  // Calculate the starting byte offsets
+  next_static_oop_offset      = InstanceMirrorKlass::offset_of_static_fields();
+  next_static_double_offset   = next_static_oop_offset +
+                                ((fac->count[STATIC_OOP]) * heapOopSize);
+  if ( fac->count[STATIC_DOUBLE] &&
+       (Universe::field_type_should_be_aligned(T_DOUBLE) ||
+        Universe::field_type_should_be_aligned(T_LONG)) ) {
+    next_static_double_offset = align_size_up(next_static_double_offset, BytesPerLong);
+  }
+
+  next_static_word_offset     = next_static_double_offset +
+                                ((fac->count[STATIC_DOUBLE]) * BytesPerLong);
+  next_static_short_offset    = next_static_word_offset +
+                                ((fac->count[STATIC_WORD]) * BytesPerInt);
+  next_static_byte_offset     = next_static_short_offset +
+                                ((fac->count[STATIC_SHORT]) * BytesPerShort);
+
+  first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
+                                 nonstatic_field_size * heapOopSize;
+
+  // class is contended, pad before all the fields
+  if (parsed_annotations->is_contended()) {
+    first_nonstatic_field_offset += pad_size;
+  }
+
+  next_nonstatic_field_offset = first_nonstatic_field_offset;
+
+  unsigned int nonstatic_double_count = fac->count[NONSTATIC_DOUBLE] - fac_contended.count[NONSTATIC_DOUBLE];
+  unsigned int nonstatic_word_count   = fac->count[NONSTATIC_WORD]   - fac_contended.count[NONSTATIC_WORD];
+  unsigned int nonstatic_short_count  = fac->count[NONSTATIC_SHORT]  - fac_contended.count[NONSTATIC_SHORT];
+  unsigned int nonstatic_byte_count   = fac->count[NONSTATIC_BYTE]   - fac_contended.count[NONSTATIC_BYTE];
+  unsigned int nonstatic_oop_count    = fac->count[NONSTATIC_OOP]    - fac_contended.count[NONSTATIC_OOP];
+
+  bool super_has_nonstatic_fields =
+          (_super_klass() != NULL && _super_klass->has_nonstatic_fields());
+  bool has_nonstatic_fields = super_has_nonstatic_fields ||
+          ((nonstatic_double_count + nonstatic_word_count +
+            nonstatic_short_count + nonstatic_byte_count +
+            nonstatic_oop_count) != 0);
+
+
+  // Prepare list of oops for oop map generation.
+  int* nonstatic_oop_offsets;
+  unsigned int* nonstatic_oop_counts;
+  unsigned int nonstatic_oop_map_count = 0;
+
+  nonstatic_oop_offsets = NEW_RESOURCE_ARRAY_IN_THREAD(
+            THREAD, int, nonstatic_oop_count + 1);
+  nonstatic_oop_counts  = NEW_RESOURCE_ARRAY_IN_THREAD(
+            THREAD, unsigned int, nonstatic_oop_count + 1);
+
+  first_nonstatic_oop_offset = 0; // will be set for first oop field
+
+#ifndef PRODUCT
+  if( PrintCompactFieldsSavings ) {
+    next_nonstatic_double_offset = next_nonstatic_field_offset +
+                                   (nonstatic_oop_count * heapOopSize);
+    if ( nonstatic_double_count > 0 ) {
+      next_nonstatic_double_offset = align_size_up(next_nonstatic_double_offset, BytesPerLong);
+    }
+    next_nonstatic_word_offset  = next_nonstatic_double_offset +
+                                  (nonstatic_double_count * BytesPerLong);
+    next_nonstatic_short_offset = next_nonstatic_word_offset +
+                                  (nonstatic_word_count * BytesPerInt);
+    next_nonstatic_byte_offset  = next_nonstatic_short_offset +
+                                  (nonstatic_short_count * BytesPerShort);
+    next_nonstatic_type_offset  = align_size_up((next_nonstatic_byte_offset +
+                                  nonstatic_byte_count ), heapOopSize );
+    orig_nonstatic_field_size   = nonstatic_field_size +
+    ((next_nonstatic_type_offset - first_nonstatic_field_offset)/heapOopSize);
+  }
+#endif
+  bool compact_fields   = CompactFields;
+  int  allocation_style = FieldsAllocationStyle;
+  if( allocation_style < 0 || allocation_style > 2 ) { // Out of range?
+    assert(false, "0 <= FieldsAllocationStyle <= 2");
+    allocation_style = 1; // Optimistic
+  }
+
+  // The next classes have predefined hard-coded fields offsets
+  // (see in JavaClasses::compute_hard_coded_offsets()).
+  // Use default fields allocation order for them.
+  if( (allocation_style != 0 || compact_fields ) && class_loader.is_null() &&
+      (_class_name == vmSymbols::java_lang_AssertionStatusDirectives() ||
+       _class_name == vmSymbols::java_lang_Class() ||
+       _class_name == vmSymbols::java_lang_ClassLoader() ||
+       _class_name == vmSymbols::java_lang_ref_Reference() ||
+       _class_name == vmSymbols::java_lang_ref_SoftReference() ||
+       _class_name == vmSymbols::java_lang_StackTraceElement() ||
+       _class_name == vmSymbols::java_lang_String() ||
+       _class_name == vmSymbols::java_lang_Throwable() ||
+       _class_name == vmSymbols::java_lang_Boolean() ||
+       _class_name == vmSymbols::java_lang_Character() ||
+       _class_name == vmSymbols::java_lang_Float() ||
+       _class_name == vmSymbols::java_lang_Double() ||
+       _class_name == vmSymbols::java_lang_Byte() ||
+       _class_name == vmSymbols::java_lang_Short() ||
+       _class_name == vmSymbols::java_lang_Integer() ||
+       _class_name == vmSymbols::java_lang_Long())) {
+    allocation_style = 0;     // Allocate oops first
+    compact_fields   = false; // Don't compact fields
+  }
+
+  if( allocation_style == 0 ) {
+    // Fields order: oops, longs/doubles, ints, shorts/chars, bytes, padded fields
+    next_nonstatic_oop_offset    = next_nonstatic_field_offset;
+    next_nonstatic_double_offset = next_nonstatic_oop_offset +
+                                    (nonstatic_oop_count * heapOopSize);
+  } else if( allocation_style == 1 ) {
+    // Fields order: longs/doubles, ints, shorts/chars, bytes, oops, padded fields
+    next_nonstatic_double_offset = next_nonstatic_field_offset;
+  } else if( allocation_style == 2 ) {
+    // Fields allocation: oops fields in super and sub classes are together.
+    if( nonstatic_field_size > 0 && _super_klass() != NULL &&
+        _super_klass->nonstatic_oop_map_size() > 0 ) {
+      unsigned int map_count = _super_klass->nonstatic_oop_map_count();
+      OopMapBlock* first_map = _super_klass->start_of_nonstatic_oop_maps();
+      OopMapBlock* last_map = first_map + map_count - 1;
+      int next_offset = last_map->offset() + (last_map->count() * heapOopSize);
+      if (next_offset == next_nonstatic_field_offset) {
+        allocation_style = 0;   // allocate oops first
+        next_nonstatic_oop_offset    = next_nonstatic_field_offset;
+        next_nonstatic_double_offset = next_nonstatic_oop_offset +
+                                       (nonstatic_oop_count * heapOopSize);
+      }
+    }
+    if( allocation_style == 2 ) {
+      allocation_style = 1;     // allocate oops last
+      next_nonstatic_double_offset = next_nonstatic_field_offset;
+    }
+  } else {
+    ShouldNotReachHere();
+  }
+
+  int nonstatic_oop_space_count   = 0;
+  int nonstatic_word_space_count  = 0;
+  int nonstatic_short_space_count = 0;
+  int nonstatic_byte_space_count  = 0;
+  int nonstatic_oop_space_offset;
+  int nonstatic_word_space_offset;
+  int nonstatic_short_space_offset;
+  int nonstatic_byte_space_offset;
+
+  if( nonstatic_double_count > 0 ) {
+    int offset = next_nonstatic_double_offset;
+    next_nonstatic_double_offset = align_size_up(offset, BytesPerLong);
+    if( compact_fields && offset != next_nonstatic_double_offset ) {
+      // Allocate available fields into the gap before double field.
+      int length = next_nonstatic_double_offset - offset;
+      assert(length == BytesPerInt, "");
+      nonstatic_word_space_offset = offset;
+      if( nonstatic_word_count > 0 ) {
+        nonstatic_word_count      -= 1;
+        nonstatic_word_space_count = 1; // Only one will fit
+        length -= BytesPerInt;
+        offset += BytesPerInt;
+      }
+      nonstatic_short_space_offset = offset;
+      while( length >= BytesPerShort && nonstatic_short_count > 0 ) {
+        nonstatic_short_count       -= 1;
+        nonstatic_short_space_count += 1;
+        length -= BytesPerShort;
+        offset += BytesPerShort;
+      }
+      nonstatic_byte_space_offset = offset;
+      while( length > 0 && nonstatic_byte_count > 0 ) {
+        nonstatic_byte_count       -= 1;
+        nonstatic_byte_space_count += 1;
+        length -= 1;
+      }
+      // Allocate oop field in the gap if there are no other fields for that.
+      nonstatic_oop_space_offset = offset;
+      if( length >= heapOopSize && nonstatic_oop_count > 0 &&
+          allocation_style != 0 ) { // when oop fields not first
+        nonstatic_oop_count      -= 1;
+        nonstatic_oop_space_count = 1; // Only one will fit
+        length -= heapOopSize;
+        offset += heapOopSize;
+      }
+    }
+  }
+
+  next_nonstatic_word_offset  = next_nonstatic_double_offset +
+                                (nonstatic_double_count * BytesPerLong);
+  next_nonstatic_short_offset = next_nonstatic_word_offset +
+                                (nonstatic_word_count * BytesPerInt);
+  next_nonstatic_byte_offset  = next_nonstatic_short_offset +
+                                (nonstatic_short_count * BytesPerShort);
+  next_nonstatic_padded_offset = next_nonstatic_byte_offset +
+                                nonstatic_byte_count;
+
+  // let oops jump before padding with this allocation style
+  if( allocation_style == 1 ) {
+    next_nonstatic_oop_offset = next_nonstatic_padded_offset;
+    if( nonstatic_oop_count > 0 ) {
+      next_nonstatic_oop_offset = align_size_up(next_nonstatic_oop_offset, heapOopSize);
+    }
+    next_nonstatic_padded_offset = next_nonstatic_oop_offset + (nonstatic_oop_count * heapOopSize);
+  }
+
+  // Iterate over fields again and compute correct offsets.
+  // The field allocation type was temporarily stored in the offset slot.
+  // oop fields are located before non-oop fields (static and non-static).
+  for (AllFieldStream fs(_fields, _cp); !fs.done(); fs.next()) {
+
+    // skip already laid out fields
+    if (fs.is_offset_set()) continue;
+
+    // contended instance fields are handled below
+    if (fs.is_contended() && !fs.access_flags().is_static()) continue;
+
+    int real_offset;
+    FieldAllocationType atype = (FieldAllocationType) fs.allocation_type();
+
+    // pack the rest of the fields
+    switch (atype) {
+      case STATIC_OOP:
+        real_offset = next_static_oop_offset;
+        next_static_oop_offset += heapOopSize;
+        break;
+      case STATIC_BYTE:
+        real_offset = next_static_byte_offset;
+        next_static_byte_offset += 1;
+        break;
+      case STATIC_SHORT:
+        real_offset = next_static_short_offset;
+        next_static_short_offset += BytesPerShort;
+        break;
+      case STATIC_WORD:
+        real_offset = next_static_word_offset;
+        next_static_word_offset += BytesPerInt;
+        break;
+      case STATIC_DOUBLE:
+        real_offset = next_static_double_offset;
+        next_static_double_offset += BytesPerLong;
+        break;
+      case NONSTATIC_OOP:
+        if( nonstatic_oop_space_count > 0 ) {
+          real_offset = nonstatic_oop_space_offset;
+          nonstatic_oop_space_offset += heapOopSize;
+          nonstatic_oop_space_count  -= 1;
+        } else {
+          real_offset = next_nonstatic_oop_offset;
+          next_nonstatic_oop_offset += heapOopSize;
+        }
+        // Update oop maps
+        if( nonstatic_oop_map_count > 0 &&
+            nonstatic_oop_offsets[nonstatic_oop_map_count - 1] ==
+            real_offset -
+            int(nonstatic_oop_counts[nonstatic_oop_map_count - 1]) *
+            heapOopSize ) {
+          // Extend current oop map
+          nonstatic_oop_counts[nonstatic_oop_map_count - 1] += 1;
+        } else {
+          // Create new oop map
+          nonstatic_oop_offsets[nonstatic_oop_map_count] = real_offset;
+          nonstatic_oop_counts [nonstatic_oop_map_count] = 1;
+          nonstatic_oop_map_count += 1;
+          if( first_nonstatic_oop_offset == 0 ) { // Undefined
+            first_nonstatic_oop_offset = real_offset;
+          }
+        }
+        break;
+      case NONSTATIC_BYTE:
+        if( nonstatic_byte_space_count > 0 ) {
+          real_offset = nonstatic_byte_space_offset;
+          nonstatic_byte_space_offset += 1;
+          nonstatic_byte_space_count  -= 1;
+        } else {
+          real_offset = next_nonstatic_byte_offset;
+          next_nonstatic_byte_offset += 1;
+        }
+        break;
+      case NONSTATIC_SHORT:
+        if( nonstatic_short_space_count > 0 ) {
+          real_offset = nonstatic_short_space_offset;
+          nonstatic_short_space_offset += BytesPerShort;
+          nonstatic_short_space_count  -= 1;
+        } else {
+          real_offset = next_nonstatic_short_offset;
+          next_nonstatic_short_offset += BytesPerShort;
+        }
+        break;
+      case NONSTATIC_WORD:
+        if( nonstatic_word_space_count > 0 ) {
+          real_offset = nonstatic_word_space_offset;
+          nonstatic_word_space_offset += BytesPerInt;
+          nonstatic_word_space_count  -= 1;
+        } else {
+          real_offset = next_nonstatic_word_offset;
+          next_nonstatic_word_offset += BytesPerInt;
+        }
+        break;
+      case NONSTATIC_DOUBLE:
+        real_offset = next_nonstatic_double_offset;
+        next_nonstatic_double_offset += BytesPerLong;
+        break;
+      default:
+        ShouldNotReachHere();
+    }
+    fs.set_offset(real_offset);
+  }
+
+
+  // Handle the contended cases.
+  //
+  // Each contended field should not intersect the cache line with another contended field.
+  // In the absence of alignment information, we end up with pessimistically separating
+  // the fields with full-width padding.
+  //
+  // Additionally, this should not break alignment for the fields, so we round the alignment up
+  // for each field.
+  if (contended_count > 0) {
+
+    // if there is at least one contended field, we need to have pre-padding for them
+    if (nonstatic_contended_count > 0) {
+      next_nonstatic_padded_offset += pad_size;
+    }
+
+    // collect all contended groups
+    BitMap bm(_cp->size());
+    for (AllFieldStream fs(_fields, _cp); !fs.done(); fs.next()) {
+      // skip already laid out fields
+      if (fs.is_offset_set()) continue;
+
+      if (fs.is_contended()) {
+        bm.set_bit(fs.contended_group());
+      }
+    }
+
+    int current_group = -1;
+    while ((current_group = (int)bm.get_next_one_offset(current_group + 1)) != (int)bm.size()) {
+
+      for (AllFieldStream fs(_fields, _cp); !fs.done(); fs.next()) {
+
+        // skip already laid out fields
+        if (fs.is_offset_set()) continue;
+
+        // skip non-contended fields and fields from different group
+        if (!fs.is_contended() || (fs.contended_group() != current_group)) continue;
+
+        // handle statics below
+        if (fs.access_flags().is_static()) continue;
+
+        int real_offset;
+        FieldAllocationType atype = (FieldAllocationType) fs.allocation_type();
+
+        switch (atype) {
+          case NONSTATIC_BYTE:
+            next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, 1);
+            real_offset = next_nonstatic_padded_offset;
+            next_nonstatic_padded_offset += 1;
+            break;
+
+          case NONSTATIC_SHORT:
+            next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, BytesPerShort);
+            real_offset = next_nonstatic_padded_offset;
+            next_nonstatic_padded_offset += BytesPerShort;
+            break;
+
+          case NONSTATIC_WORD:
+            next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, BytesPerInt);
+            real_offset = next_nonstatic_padded_offset;
+            next_nonstatic_padded_offset += BytesPerInt;
+            break;
+
+          case NONSTATIC_DOUBLE:
+            next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, BytesPerLong);
+            real_offset = next_nonstatic_padded_offset;
+            next_nonstatic_padded_offset += BytesPerLong;
+            break;
+
+          case NONSTATIC_OOP:
+            next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, heapOopSize);
+            real_offset = next_nonstatic_padded_offset;
+            next_nonstatic_padded_offset += heapOopSize;
+
+            // Create new oop map
+            nonstatic_oop_offsets[nonstatic_oop_map_count] = real_offset;
+            nonstatic_oop_counts [nonstatic_oop_map_count] = 1;
+            nonstatic_oop_map_count += 1;
+            if( first_nonstatic_oop_offset == 0 ) { // Undefined
+              first_nonstatic_oop_offset = real_offset;
+            }
+            break;
+
+          default:
+            ShouldNotReachHere();
+        }
+
+        if (fs.contended_group() == 0) {
+          // Contended group defines the equivalence class over the fields:
+          // the fields within the same contended group are not inter-padded.
+          // The only exception is default group, which does not incur the
+          // equivalence, and so requires intra-padding.
+          next_nonstatic_padded_offset += pad_size;
+        }
+
+        fs.set_offset(real_offset);
+      } // for
+
+      // Start laying out the next group.
+      // Note that this will effectively pad the last group in the back;
+      // this is expected to alleviate memory contention effects for
+      // subclass fields and/or adjacent object.
+      // If this was the default group, the padding is already in place.
+      if (current_group != 0) {
+        next_nonstatic_padded_offset += pad_size;
+      }
+    }
+
+    // handle static fields
+  }
+
+  // Size of instances
+  int notaligned_offset = next_nonstatic_padded_offset;
+
+  // Entire class is contended, pad in the back.
+  // This helps to alleviate memory contention effects for subclass fields
+  // and/or adjacent object.
+  if (parsed_annotations->is_contended()) {
+    notaligned_offset += pad_size;
+  }
+
+  int next_static_type_offset     = align_size_up(next_static_byte_offset, wordSize);
+  int static_field_size           = (next_static_type_offset -
+                                InstanceMirrorKlass::offset_of_static_fields()) / wordSize;
+
+  next_nonstatic_type_offset = align_size_up(notaligned_offset, heapOopSize );
+  nonstatic_field_size = nonstatic_field_size + ((next_nonstatic_type_offset
+                                 - first_nonstatic_field_offset)/heapOopSize);
+
+  next_nonstatic_type_offset = align_size_up(notaligned_offset, wordSize );
+  int instance_size = align_object_size(next_nonstatic_type_offset / wordSize);
+
+  assert(instance_size == align_object_size(align_size_up(
+         (instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize + ((parsed_annotations->is_contended()) ? pad_size : 0)),
+          wordSize) / wordSize), "consistent layout helper value");
+
+  // Number of non-static oop map blocks allocated at end of klass.
+  const unsigned int total_oop_map_count =
+    compute_oop_map_count(_super_klass, nonstatic_oop_map_count,
+                          first_nonstatic_oop_offset);
+
+#ifndef PRODUCT
+  if( PrintCompactFieldsSavings ) {
+    ResourceMark rm;
+    if( nonstatic_field_size < orig_nonstatic_field_size ) {
+      tty->print("[Saved %d of %d bytes in %s]\n",
+               (orig_nonstatic_field_size - nonstatic_field_size)*heapOopSize,
+               orig_nonstatic_field_size*heapOopSize,
+               _class_name);
+    } else if( nonstatic_field_size > orig_nonstatic_field_size ) {
+      tty->print("[Wasted %d over %d bytes in %s]\n",
+               (nonstatic_field_size - orig_nonstatic_field_size)*heapOopSize,
+               orig_nonstatic_field_size*heapOopSize,
+               _class_name);
+    }
+  }
+
+  if (PrintFieldLayout) {
+    print_field_layout(_class_name,
+          _fields,
+          _cp,
+          instance_size,
+          first_nonstatic_field_offset,
+          next_nonstatic_field_offset,
+          next_static_type_offset);
+  }
+
+#endif
+  // Pass back information needed for InstanceKlass creation
+  info->nonstatic_oop_offsets = nonstatic_oop_offsets;
+  info->nonstatic_oop_counts = nonstatic_oop_counts;
+  info->nonstatic_oop_map_count = nonstatic_oop_map_count;
+  info->total_oop_map_count = total_oop_map_count;
+  info->instance_size = instance_size;
+  info->static_field_size = static_field_size;
+  info->nonstatic_field_size = nonstatic_field_size;
+  info->has_nonstatic_fields = has_nonstatic_fields;
+}
+
+
 instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
                                                     ClassLoaderData* loader_data,
                                                     Handle protection_domain,
@@ -3176,7 +3673,7 @@
                             jt->get_thread_stat()->perf_timers_addr(),
                             PerfClassTraceTime::PARSE_CLASS);
 
-  init_parsed_class_attributes();
+  init_parsed_class_attributes(loader_data);
 
   if (JvmtiExport::should_post_class_file_load_hook()) {
     // Get the cached class file bytes (if any) from the class that
@@ -3271,8 +3768,7 @@
   _relax_verify = Verifier::relax_verify_for(class_loader());
 
   // Constant pool
-  constantPoolHandle cp = parse_constant_pool(loader_data, CHECK_(nullHandle));
-  ConstantPoolCleaner error_handler(cp); // set constant pool to be cleaned up.
+  constantPoolHandle cp = parse_constant_pool(CHECK_(nullHandle));
 
   int cp_size = cp->length();
 
@@ -3290,7 +3786,6 @@
   access_flags.set_flags(flags);
 
   // This class and superclass
-  instanceKlassHandle super_klass;
   u2 this_class_index = cfs->get_u2_fast();
   check_property(
     valid_cp_range(this_class_index, cp_size) &&
@@ -3345,59 +3840,27 @@
     }
 
     u2 super_class_index = cfs->get_u2_fast();
-    if (super_class_index == 0) {
-      check_property(class_name == vmSymbols::java_lang_Object(),
-                     "Invalid superclass index %u in class file %s",
-                     super_class_index,
-                     CHECK_(nullHandle));
-    } else {
-      check_property(valid_cp_range(super_class_index, cp_size) &&
-                     is_klass_reference(cp, super_class_index),
-                     "Invalid superclass index %u in class file %s",
-                     super_class_index,
-                     CHECK_(nullHandle));
-      // The class name should be legal because it is checked when parsing constant pool.
-      // However, make sure it is not an array type.
-      bool is_array = false;
-      if (cp->tag_at(super_class_index).is_klass()) {
-        super_klass = instanceKlassHandle(THREAD, cp->resolved_klass_at(super_class_index));
-        if (_need_verify)
-          is_array = super_klass->oop_is_array();
-      } else if (_need_verify) {
-        is_array = (cp->unresolved_klass_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY);
-      }
-      if (_need_verify) {
-        guarantee_property(!is_array,
-                          "Bad superclass name in class file %s", CHECK_(nullHandle));
-      }
-    }
+    instanceKlassHandle super_klass = parse_super_class(super_class_index,
+                                                        CHECK_NULL);
 
     // Interfaces
     u2 itfs_len = cfs->get_u2_fast();
-    Array<Klass*>* local_interfaces;
-    if (itfs_len == 0) {
-      local_interfaces = Universe::the_empty_klass_array();
-    } else {
-      local_interfaces = parse_interfaces(
-          cp, itfs_len, loader_data, protection_domain, _class_name,
-          &has_default_methods, CHECK_(nullHandle));
-    }
+    Array<Klass*>* local_interfaces =
+      parse_interfaces(itfs_len, protection_domain, _class_name,
+                       &has_default_methods, CHECK_(nullHandle));
 
     u2 java_fields_count = 0;
     // Fields (offsets are filled in later)
     FieldAllocationCount fac;
-    Array<AnnotationArray*>* fields_annotations = NULL;
-    Array<AnnotationArray*>* fields_type_annotations = NULL;
-    Array<u2>* fields = parse_fields(loader_data, class_name, cp, access_flags.is_interface(), &fac, &fields_annotations,
-                                          &fields_type_annotations,
-                                          &java_fields_count,
-                                          CHECK_(nullHandle));
+    Array<u2>* fields = parse_fields(class_name,
+                                     access_flags.is_interface(),
+                                     &fac, &java_fields_count,
+                                     CHECK_(nullHandle));
     // Methods
     bool has_final_method = false;
     AccessFlags promoted_flags;
     promoted_flags.set_flags(0);
-    Array<Method*>* methods = parse_methods(loader_data,
-                                            cp, access_flags.is_interface(),
+    Array<Method*>* methods = parse_methods(access_flags.is_interface(),
                                             &promoted_flags,
                                             &has_final_method,
                                             &has_default_methods,
@@ -3405,7 +3868,7 @@
 
     // Additional attributes
     ClassAnnotationCollector parsed_annotations;
-    parse_classfile_attributes(loader_data, cp, &parsed_annotations, CHECK_(nullHandle));
+    parse_classfile_attributes(&parsed_annotations, CHECK_(nullHandle));
 
     // Make sure this is the end of class file stream
     guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
@@ -3452,13 +3915,15 @@
       }
     }
 
+    // save super klass for error handling.
+    _super_klass = super_klass;
+
     // Compute the transitive list of all unique interfaces implemented by this class
-    Array<Klass*>* transitive_interfaces = compute_transitive_interfaces(loader_data, super_klass, local_interfaces, CHECK_(nullHandle));
+    _transitive_interfaces =
+          compute_transitive_interfaces(super_klass, local_interfaces, CHECK_(nullHandle));
 
     // sort methods
-    Array<int>* method_ordering = sort_methods(loader_data,
-                                               methods,
-                                               CHECK_(nullHandle));
+    intArray* method_ordering = sort_methods(methods);
 
     // promote flags from parse_methods() to the klass' flags
     access_flags.add_promoted_flags(promoted_flags.as_int());
@@ -3476,587 +3941,14 @@
                                                       CHECK_(nullHandle));
 
     // Size of Java itable (in words)
-    itable_size = access_flags.is_interface() ? 0 : klassItable::compute_itable_size(transitive_interfaces);
-
-    // get the padding width from the option
-    // TODO: Ask VM about specific CPU we are running on
-    int pad_size = ContendedPaddingWidth;
-
-    // Field size and offset computation
-    int nonstatic_field_size = super_klass() == NULL ? 0 : super_klass->nonstatic_field_size();
-#ifndef PRODUCT
-    int orig_nonstatic_field_size = 0;
-#endif
-    int next_static_oop_offset;
-    int next_static_double_offset;
-    int next_static_word_offset;
-    int next_static_short_offset;
-    int next_static_byte_offset;
-    int next_static_padded_offset;
-    int next_nonstatic_oop_offset;
-    int next_nonstatic_double_offset;
-    int next_nonstatic_word_offset;
-    int next_nonstatic_short_offset;
-    int next_nonstatic_byte_offset;
-    int next_nonstatic_type_offset;
-    int first_nonstatic_oop_offset;
-    int first_nonstatic_field_offset;
-    int next_nonstatic_field_offset;
-    int next_nonstatic_padded_offset;
-
-    // Count the contended fields by type.
-    int static_contended_count = 0;
-    int nonstatic_contended_count = 0;
-    FieldAllocationCount fac_contended;
-    for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) {
-      FieldAllocationType atype = (FieldAllocationType) fs.allocation_type();
-      if (fs.is_contended()) {
-        fac_contended.count[atype]++;
-        if (fs.access_flags().is_static()) {
-          static_contended_count++;
-        } else {
-          nonstatic_contended_count++;
-        }
-      }
-    }
-    int contended_count = static_contended_count + nonstatic_contended_count;
-
-
-    // Calculate the starting byte offsets
-    next_static_oop_offset      = InstanceMirrorKlass::offset_of_static_fields();
-
-    // class is contended, pad before all the fields
-    if (parsed_annotations.is_contended()) {
-      next_static_oop_offset += pad_size;
-    }
-
-    next_static_double_offset   = next_static_oop_offset +
-                                  ((fac.count[STATIC_OOP] - fac_contended.count[STATIC_OOP]) * heapOopSize);
-    if ( fac.count[STATIC_DOUBLE] &&
-         (Universe::field_type_should_be_aligned(T_DOUBLE) ||
-          Universe::field_type_should_be_aligned(T_LONG)) ) {
-      next_static_double_offset = align_size_up(next_static_double_offset, BytesPerLong);
-    }
-
-    next_static_word_offset     = next_static_double_offset +
-                                  ((fac.count[STATIC_DOUBLE] - fac_contended.count[STATIC_DOUBLE]) * BytesPerLong);
-    next_static_short_offset    = next_static_word_offset +
-                                  ((fac.count[STATIC_WORD]   - fac_contended.count[STATIC_WORD]) * BytesPerInt);
-    next_static_byte_offset     = next_static_short_offset +
-                                  ((fac.count[STATIC_SHORT]  - fac_contended.count[STATIC_SHORT]) * BytesPerShort);
-    next_static_padded_offset   = next_static_byte_offset +
-                                  ((fac.count[STATIC_BYTE]   - fac_contended.count[STATIC_BYTE]) * 1);
-
-    first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
-                                   nonstatic_field_size * heapOopSize;
-
-    // class is contended, pad before all the fields
-    if (parsed_annotations.is_contended()) {
-      first_nonstatic_field_offset += pad_size;
-    }
-
-    next_nonstatic_field_offset = first_nonstatic_field_offset;
-
-    unsigned int nonstatic_double_count = fac.count[NONSTATIC_DOUBLE] - fac_contended.count[NONSTATIC_DOUBLE];
-    unsigned int nonstatic_word_count   = fac.count[NONSTATIC_WORD]   - fac_contended.count[NONSTATIC_WORD];
-    unsigned int nonstatic_short_count  = fac.count[NONSTATIC_SHORT]  - fac_contended.count[NONSTATIC_SHORT];
-    unsigned int nonstatic_byte_count   = fac.count[NONSTATIC_BYTE]   - fac_contended.count[NONSTATIC_BYTE];
-    unsigned int nonstatic_oop_count    = fac.count[NONSTATIC_OOP]    - fac_contended.count[NONSTATIC_OOP];
-
-    bool super_has_nonstatic_fields =
-            (super_klass() != NULL && super_klass->has_nonstatic_fields());
-    bool has_nonstatic_fields  =  super_has_nonstatic_fields ||
-            ((nonstatic_double_count + nonstatic_word_count +
-              nonstatic_short_count + nonstatic_byte_count +
-              nonstatic_oop_count) != 0);
-
-
-    // Prepare list of oops for oop map generation.
-    int* nonstatic_oop_offsets;
-    unsigned int* nonstatic_oop_counts;
-    unsigned int nonstatic_oop_map_count = 0;
-
-    nonstatic_oop_offsets = NEW_RESOURCE_ARRAY_IN_THREAD(
-              THREAD, int, nonstatic_oop_count + 1);
-    nonstatic_oop_counts  = NEW_RESOURCE_ARRAY_IN_THREAD(
-              THREAD, unsigned int, nonstatic_oop_count + 1);
-
-    first_nonstatic_oop_offset = 0; // will be set for first oop field
-
-#ifndef PRODUCT
-    if( PrintCompactFieldsSavings ) {
-      next_nonstatic_double_offset = next_nonstatic_field_offset +
-                                     (nonstatic_oop_count * heapOopSize);
-      if ( nonstatic_double_count > 0 ) {
-        next_nonstatic_double_offset = align_size_up(next_nonstatic_double_offset, BytesPerLong);
-      }
-      next_nonstatic_word_offset  = next_nonstatic_double_offset +
-                                    (nonstatic_double_count * BytesPerLong);
-      next_nonstatic_short_offset = next_nonstatic_word_offset +
-                                    (nonstatic_word_count * BytesPerInt);
-      next_nonstatic_byte_offset  = next_nonstatic_short_offset +
-                                    (nonstatic_short_count * BytesPerShort);
-      next_nonstatic_type_offset  = align_size_up((next_nonstatic_byte_offset +
-                                    nonstatic_byte_count ), heapOopSize );
-      orig_nonstatic_field_size   = nonstatic_field_size +
-      ((next_nonstatic_type_offset - first_nonstatic_field_offset)/heapOopSize);
-    }
-#endif
-    bool compact_fields   = CompactFields;
-    int  allocation_style = FieldsAllocationStyle;
-    if( allocation_style < 0 || allocation_style > 2 ) { // Out of range?
-      assert(false, "0 <= FieldsAllocationStyle <= 2");
-      allocation_style = 1; // Optimistic
-    }
-
-    // The next classes have predefined hard-coded fields offsets
-    // (see in JavaClasses::compute_hard_coded_offsets()).
-    // Use default fields allocation order for them.
-    if( (allocation_style != 0 || compact_fields ) && class_loader.is_null() &&
-        (class_name == vmSymbols::java_lang_AssertionStatusDirectives() ||
-         class_name == vmSymbols::java_lang_Class() ||
-         class_name == vmSymbols::java_lang_ClassLoader() ||
-         class_name == vmSymbols::java_lang_ref_Reference() ||
-         class_name == vmSymbols::java_lang_ref_SoftReference() ||
-         class_name == vmSymbols::java_lang_StackTraceElement() ||
-         class_name == vmSymbols::java_lang_String() ||
-         class_name == vmSymbols::java_lang_Throwable() ||
-         class_name == vmSymbols::java_lang_Boolean() ||
-         class_name == vmSymbols::java_lang_Character() ||
-         class_name == vmSymbols::java_lang_Float() ||
-         class_name == vmSymbols::java_lang_Double() ||
-         class_name == vmSymbols::java_lang_Byte() ||
-         class_name == vmSymbols::java_lang_Short() ||
-         class_name == vmSymbols::java_lang_Integer() ||
-         class_name == vmSymbols::java_lang_Long())) {
-      allocation_style = 0;     // Allocate oops first
-      compact_fields   = false; // Don't compact fields
-    }
-
-    if( allocation_style == 0 ) {
-      // Fields order: oops, longs/doubles, ints, shorts/chars, bytes, padded fields
-      next_nonstatic_oop_offset    = next_nonstatic_field_offset;
-      next_nonstatic_double_offset = next_nonstatic_oop_offset +
-                                      (nonstatic_oop_count * heapOopSize);
-    } else if( allocation_style == 1 ) {
-      // Fields order: longs/doubles, ints, shorts/chars, bytes, oops, padded fields
-      next_nonstatic_double_offset = next_nonstatic_field_offset;
-    } else if( allocation_style == 2 ) {
-      // Fields allocation: oops fields in super and sub classes are together.
-      if( nonstatic_field_size > 0 && super_klass() != NULL &&
-          super_klass->nonstatic_oop_map_size() > 0 ) {
-        int map_count = super_klass->nonstatic_oop_map_count();
-        OopMapBlock* first_map = super_klass->start_of_nonstatic_oop_maps();
-        OopMapBlock* last_map = first_map + map_count - 1;
-        int next_offset = last_map->offset() + (last_map->count() * heapOopSize);
-        if (next_offset == next_nonstatic_field_offset) {
-          allocation_style = 0;   // allocate oops first
-          next_nonstatic_oop_offset    = next_nonstatic_field_offset;
-          next_nonstatic_double_offset = next_nonstatic_oop_offset +
-                                         (nonstatic_oop_count * heapOopSize);
-        }
-      }
-      if( allocation_style == 2 ) {
-        allocation_style = 1;     // allocate oops last
-        next_nonstatic_double_offset = next_nonstatic_field_offset;
-      }
-    } else {
-      ShouldNotReachHere();
-    }
-
-    int nonstatic_oop_space_count   = 0;
-    int nonstatic_word_space_count  = 0;
-    int nonstatic_short_space_count = 0;
-    int nonstatic_byte_space_count  = 0;
-    int nonstatic_oop_space_offset;
-    int nonstatic_word_space_offset;
-    int nonstatic_short_space_offset;
-    int nonstatic_byte_space_offset;
-
-    if( nonstatic_double_count > 0 ) {
-      int offset = next_nonstatic_double_offset;
-      next_nonstatic_double_offset = align_size_up(offset, BytesPerLong);
-      if( com