changeset 45741:ee4958177e69

Merge
author duke
date Thu, 24 Aug 2017 16:24:44 +0200
parents 224d0d2dd36e 3532c702cd17
children 8327d73befff
files hotspot/test/runtime/modules/JVMAddModulePackage.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogException.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/BootstrapResolver.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Debug.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/FileURL.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Namespaces.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/PublicId.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/CatalogReader.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogParser.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/ExtendedXMLCatalogReader.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/OASISXMLCatalogReader.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogParser.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXParserHandler.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TR9401CatalogReader.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TextCatalogReader.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/XCatalogReader.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingParser.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLFilter.java jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLReader.java jdk/make/src/classes/build/tools/docs/GenDocsBundlePage.java jdk/make/src/classes/build/tools/docs/docs-bundle-page.html jdk/make/src/classes/build/tools/docs/docs-module-groups.properties jdk/src/java.base/share/specs/serialization/class.md jdk/src/java.base/share/specs/serialization/examples.md jdk/src/java.base/share/specs/serialization/exceptions.md jdk/src/java.base/share/specs/serialization/images/version.gif jdk/src/java.base/share/specs/serialization/index.md jdk/src/java.base/share/specs/serialization/input.md jdk/src/java.base/share/specs/serialization/output.md jdk/src/java.base/share/specs/serialization/protocol.md jdk/src/java.base/share/specs/serialization/security.md jdk/src/java.base/share/specs/serialization/serial-arch.md jdk/src/java.base/share/specs/serialization/version.md jdk/src/java.desktop/share/specs/AWT_Native_Interface.html jdk/src/java.instrument/share/classes/java/lang/instrument/package.html jdk/src/java.management/share/specs/JVM-MANAGEMENT-MIB.mib jdk/test/java/io/File/MacPathTest.sh jdk/test/java/io/File/basic.sh jdk/test/java/io/FileOutputStream/FileOpen.sh jdk/test/java/io/FileOutputStream/FileOpenNeg.java jdk/test/java/io/FileOutputStream/FileOpenPos.java jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh jdk/test/java/nio/charset/Charset/default.sh jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh jdk/test/java/nio/charset/spi/Test.java jdk/test/java/nio/charset/spi/basic.sh jdk/test/java/nio/file/Path/MacPathTest.sh jdk/test/java/util/ServiceLoader/modules/BadProvidersTest.java jdk/test/java/util/ServiceLoader/modules/Basic.java jdk/test/java/util/ServiceLoader/modules/badfactories/badreturntype/ProviderFactory.java jdk/test/java/util/ServiceLoader/modules/badfactories/classnotpublic/ProviderFactory.java jdk/test/java/util/ServiceLoader/modules/badfactories/classnotpublic/Service.java jdk/test/java/util/ServiceLoader/modules/badfactories/methodnotpublic/ProviderFactory.java jdk/test/java/util/ServiceLoader/modules/badfactories/methodnotpublic/Service.java jdk/test/java/util/ServiceLoader/modules/badfactories/returnsnull/ProviderFactory.java jdk/test/java/util/ServiceLoader/modules/badfactories/returnsnull/Service.java jdk/test/java/util/ServiceLoader/modules/badfactories/throwsexception/ProviderFactory.java jdk/test/java/util/ServiceLoader/modules/badfactories/throwsexception/Service.java jdk/test/java/util/ServiceLoader/modules/badproviders/ctornotpublic/Provider.java jdk/test/java/util/ServiceLoader/modules/badproviders/ctornotpublic/Service.java jdk/test/java/util/ServiceLoader/modules/badproviders/notasubtype/Provider.java jdk/test/java/util/ServiceLoader/modules/badproviders/notpublic/Provider.java jdk/test/java/util/ServiceLoader/modules/badproviders/notpublic/Service.java jdk/test/java/util/ServiceLoader/modules/badproviders/throwsexception/Provider.java jdk/test/java/util/ServiceLoader/modules/badproviders/throwsexception/Service.java jdk/test/java/util/ServiceLoader/modules/modules/bananascript/module-info.java jdk/test/java/util/ServiceLoader/modules/modules/bananascript/org/banana/BananaScript.java jdk/test/java/util/ServiceLoader/modules/modules/bananascript/org/banana/BananaScriptEngineFactory.java jdk/test/java/util/ServiceLoader/modules/modules/test1/module-info.java jdk/test/java/util/ServiceLoader/modules/modules/test1/p/ProviderFactory.java jdk/test/java/util/ServiceLoader/modules/modules/test1/p/Service.java jdk/test/java/util/ServiceLoader/modules/modules/test2/module-info.java jdk/test/java/util/ServiceLoader/modules/modules/test2/p/Provider.java jdk/test/java/util/ServiceLoader/modules/modules/test2/p/Service.java jdk/test/java/util/ServiceLoader/modules/src/pearscript/META-INF/services/javax.script.ScriptEngineFactory jdk/test/java/util/ServiceLoader/modules/src/pearscript/org/pear/PearScript.java jdk/test/java/util/ServiceLoader/modules/src/pearscript/org/pear/PearScriptEngineFactory.java jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java jdk/test/tools/launcher/modules/permit/AttemptAccess.java jdk/test/tools/launcher/modules/permit/PermitIllegalAccess.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/LayoutParser.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/XMLNode.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml
diffstat 805 files changed, 20932 insertions(+), 30119 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Jun 28 11:27:28 2017 -0700
+++ b/.hgtags	Thu Aug 24 16:24:44 2017 +0200
@@ -1,3 +1,4 @@
+94680c6d60ecd9ed3ffd1847706efde7eb947afc jdk-9+174
 6dd7fda42bab7ecf648cafb0a4e9b4ca11b3094f jdk-9+173
 dad6746278facbbea57dd462cb56fb743dc0a5f0 jdk-9+172
 643b5f18c2656fe91b69fea85b07b98d5fad394d jdk-9+171
@@ -428,3 +429,4 @@
 aa5b01f5e5620438fd39efdb2e2f6365a2c7d898 jdk-10+9
 b0f2b8ff25a2209b2c807785d75f20e5086bbfc2 jdk-10+10
 036dbf8b381798e5d31065109714d04d97bf98a4 jdk-10+11
+e6d70017f5b9adbb2ec82d826973d0251800a3c3 jdk-10+12
--- a/.hgtags-top-repo	Wed Jun 28 11:27:28 2017 -0700
+++ b/.hgtags-top-repo	Thu Aug 24 16:24:44 2017 +0200
@@ -428,3 +428,7 @@
 2c25fc24103251f9711a1c280c31e1e41016d90f jdk-9+172
 6b750cdb823a029a25ff2e560302cc2d28a86cb6 jdk-10+11
 88d7fd969e7df0e07a53b201cfd29393ca33ede9 jdk-9+173
+5466f409346e0446ee9a6daeb7f5d75c8fc76823 jdk-9+174
+8d4ed1e06fe184c9cb08c5b708e7d6f5c066644f jdk-10+12
+8f7227c6012b0051ea4e0bcee040c627bf699b88 jdk-9+175
+d67a3f1f057f7e31e12f33ebe3667cb73d252268 jdk-10+13
--- a/.jcheck/conf	Wed Jun 28 11:27:28 2017 -0700
+++ b/.jcheck/conf	Thu Aug 24 16:24:44 2017 +0200
@@ -1,1 +1,2 @@
 project=jdk10
+bugids=dup
--- a/common/autoconf/generated-configure.sh	Wed Jun 28 11:27:28 2017 -0700
+++ b/common/autoconf/generated-configure.sh	Thu Aug 24 16:24:44 2017 +0200
@@ -688,6 +688,7 @@
 LIBFFI_CFLAGS
 ALSA_LIBS
 ALSA_CFLAGS
+FREETYPE_LICENSE
 FREETYPE_BUNDLE_LIB_PATH
 FREETYPE_LIBS
 FREETYPE_CFLAGS
@@ -1200,6 +1201,7 @@
 with_freetype_lib
 with_freetype_src
 enable_freetype_bundling
+with_freetype_license
 with_alsa
 with_alsa_include
 with_alsa_lib
@@ -2153,6 +2155,7 @@
   --with-freetype-src     specify directory with freetype sources to
                           automatically build the library (experimental,
                           Windows-only)
+  --with-freetype-license if bundling freetype, also bundle this license file
   --with-alsa             specify prefix directory for the alsa package
                           (expecting the libraries under PATH/lib and the
                           headers under PATH/include)
@@ -5186,7 +5189,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1494858828
+DATE_WHEN_GENERATED=1496926402
 
 ###############################################################################
 #
@@ -57906,6 +57909,12 @@
 fi
 
 
+# Check whether --with-freetype-license was given.
+if test "${with_freetype_license+set}" = set; then :
+  withval=$with_freetype_license;
+fi
+
+
   # Need to specify explicitly since it needs to be overridden on some versions of macosx
   FREETYPE_BASE_NAME=freetype
   FREETYPE_CFLAGS=
@@ -63852,6 +63861,153 @@
 
   fi # end freetype needed
 
+  FREETYPE_LICENSE=""
+  if test "x$with_freetype_license" = "xyes"; then
+    as_fn_error $? "--with-freetype-license must have a value" "$LINENO" 5
+  elif test "x$with_freetype_license" != "x"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype license" >&5
+$as_echo_n "checking for freetype license... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_freetype_license" >&5
+$as_echo "$with_freetype_license" >&6; }
+    FREETYPE_LICENSE="$with_freetype_license"
+
+  # Only process if variable expands to non-empty
+
+  if test "x$FREETYPE_LICENSE" != x; then
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$FREETYPE_LICENSE"
+  new_path=`$CYGPATH -u "$path"`
+
+  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+  # "foo.exe" is OK but "foo" is an error.
+  #
+  # This test is therefore slightly more accurate than "test -f" to check for file precense.
+  # It is also a way to make sure we got the proper file name for the real test later on.
+  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+  if test "x$test_shortpath" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of FREETYPE_LICENSE" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-style (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    FREETYPE_LICENSE="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&6;}
+  fi
+
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$FREETYPE_LICENSE"
+  has_colon=`$ECHO $path | $GREP ^.:`
+  new_path="$path"
+  if test "x$has_colon" = x; then
+    # Not in mixed or Windows style, start by that.
+    new_path=`cmd //c echo $path`
+  fi
+
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  fi
+
+
+  windows_path="$new_path"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    new_path="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    new_path="$unix_path"
+  fi
+
+  if test "x$path" != "x$new_path"; then
+    FREETYPE_LICENSE="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&6;}
+  fi
+
+  # Save the first 10 bytes of this path to the storage, so fixpath can work.
+  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+    else
+      # We're on a unix platform. Hooray! :)
+      path="$FREETYPE_LICENSE"
+      has_space=`$ECHO "$path" | $GREP " "`
+      if test "x$has_space" != x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&6;}
+        as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+      fi
+
+      # Use eval to expand a potential ~
+      eval path="$path"
+      if test ! -f "$path" && test ! -d "$path"; then
+        as_fn_error $? "The path of FREETYPE_LICENSE, which resolves as \"$path\", is not found." "$LINENO" 5
+      fi
+
+      if test -d "$path"; then
+        FREETYPE_LICENSE="`cd "$path"; $THEPWDCMD -L`"
+      else
+        dir="`$DIRNAME "$path"`"
+        base="`$BASENAME "$path"`"
+        FREETYPE_LICENSE="`cd "$dir"; $THEPWDCMD -L`/$base"
+      fi
+    fi
+  fi
+
+    if test ! -f "$FREETYPE_LICENSE"; then
+      as_fn_error $? "$FREETYPE_LICENSE cannot be found" "$LINENO" 5
+    fi
+  fi
+
+
 
 
 
--- a/common/autoconf/lib-freetype.m4	Wed Jun 28 11:27:28 2017 -0700
+++ b/common/autoconf/lib-freetype.m4	Thu Aug 24 16:24:44 2017 +0200
@@ -194,6 +194,8 @@
       [specify directory with freetype sources to automatically build the library (experimental, Windows-only)])])
   AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
       [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])
+  AC_ARG_WITH(freetype-license, [AS_HELP_STRING([--with-freetype-license],
+      [if bundling freetype, also bundle this license file])])
 
   # Need to specify explicitly since it needs to be overridden on some versions of macosx
   FREETYPE_BASE_NAME=freetype
@@ -443,7 +445,21 @@
 
   fi # end freetype needed
 
+  FREETYPE_LICENSE=""
+  if test "x$with_freetype_license" = "xyes"; then
+    AC_MSG_ERROR([--with-freetype-license must have a value])
+  elif test "x$with_freetype_license" != "x"; then
+    AC_MSG_CHECKING([for freetype license])
+    AC_MSG_RESULT([$with_freetype_license])
+    FREETYPE_LICENSE="$with_freetype_license"
+    BASIC_FIXUP_PATH(FREETYPE_LICENSE)
+    if test ! -f "$FREETYPE_LICENSE"; then
+      AC_MSG_ERROR([$FREETYPE_LICENSE cannot be found])
+    fi
+  fi
+
   AC_SUBST(FREETYPE_BUNDLE_LIB_PATH)
   AC_SUBST(FREETYPE_CFLAGS)
   AC_SUBST(FREETYPE_LIBS)
+  AC_SUBST(FREETYPE_LICENSE)
 ])
--- a/common/autoconf/spec.gmk.in	Wed Jun 28 11:27:28 2017 -0700
+++ b/common/autoconf/spec.gmk.in	Thu Aug 24 16:24:44 2017 +0200
@@ -312,6 +312,7 @@
 FREETYPE_LIBS:=@FREETYPE_LIBS@
 FREETYPE_CFLAGS:=@FREETYPE_CFLAGS@
 FREETYPE_BUNDLE_LIB_PATH=@FREETYPE_BUNDLE_LIB_PATH@
+FREETYPE_LICENSE=@FREETYPE_LICENSE@
 CUPS_CFLAGS:=@CUPS_CFLAGS@
 ALSA_LIBS:=@ALSA_LIBS@
 ALSA_CFLAGS:=@ALSA_CFLAGS@
--- a/common/conf/jib-profiles.js	Wed Jun 28 11:27:28 2017 -0700
+++ b/common/conf/jib-profiles.js	Thu Aug 24 16:24:44 2017 +0200
@@ -893,6 +893,16 @@
             }
         });
 
+    // The windows ri profile needs to add the freetype license file
+    profilesRiFreetype = {
+        "windows-x86-ri": {
+            configure_args: "--with-freetype-license="
+                + input.get("freetype", "install_path")
+                + "/freetype-2.7.1-v120-x86/freetype.md"
+        }
+    };
+    profiles = concatObjects(profiles, profilesRiFreetype);
+
     // Generate the missing platform attributes
     profiles = generatePlatformAttributes(profiles);
     profiles = generateDefaultMakeTargetsConfigureArg(common, profiles);
--- a/common/doc/testing.html	Wed Jun 28 11:27:28 2017 -0700
+++ b/common/doc/testing.html	Thu Aug 24 16:24:44 2017 +0200
@@ -18,14 +18,16 @@
 </header>
 <nav id="TOC">
 <ul>
-<li><a href="#using-the-run-test-framework">Using the run-test framework</a></li>
+<li><a href="#using-the-run-test-framework">Using the run-test framework</a><ul>
+<li><a href="#configuration">Configuration</a></li>
+</ul></li>
 <li><a href="#test-selection">Test selection</a><ul>
-<li><a href="#jtreg">JTreg</a></li>
+<li><a href="#jtreg">JTReg</a></li>
 <li><a href="#gtest">Gtest</a></li>
 </ul></li>
 <li><a href="#test-results-and-summary">Test results and summary</a></li>
 <li><a href="#test-suite-control">Test suite control</a><ul>
-<li><a href="#jtreg-keywords">JTreg keywords</a></li>
+<li><a href="#jtreg-keywords">JTReg keywords</a></li>
 <li><a href="#gtest-keywords">Gtest keywords</a></li>
 </ul></li>
 </ul>
@@ -41,14 +43,17 @@
 $ make run-test TEST=&quot;hotspot/test:hotspot_gc&quot; JTREG=&quot;JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;
 $ make run-test TEST=&quot;jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java&quot;
 $ make exploded-run-test TEST=hotspot_tier1</code></pre>
+
+<h3 id="configuration">Configuration</h3>
+<p>To be able to run JTReg tests, <code>configure</code> needs to know where to find the JTReg test framework. If it is not picked up automatically by configure, use the <code>--with-jtreg=&lt;path to jtreg home&gt;</code> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing <code>lib/jtreg.jar</code> etc. (An alternative is to set the <code>JT_HOME</code> environment variable to point to the JTReg home before running <code>configure</code>.)</p>
 <h2 id="test-selection">Test selection</h2>
 <p>All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the <code>TEST</code> variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.</p>
-<p>For some common top-level tests, direct make targets have been generated. This includes all JTreg test groups, the hotspot gtest, and custom tests (if present). This means that <code>make run-test-tier1</code> is equivalent to <code>make run-test TEST=&quot;tier1&quot;</code>, but the latter is more tab-completion friendly. For more complex test runs, the <code>run-test TEST=&quot;x&quot;</code> solution needs to be used.</p>
+<p>For some common top-level tests, direct make targets have been generated. This includes all JTReg test groups, the hotspot gtest, and custom tests (if present). This means that <code>make run-test-tier1</code> is equivalent to <code>make run-test TEST=&quot;tier1&quot;</code>, but the latter is more tab-completion friendly. For more complex test runs, the <code>run-test TEST=&quot;x&quot;</code> solution needs to be used.</p>
 <p>The test specifications given in <code>TEST</code> is parsed into fully qualified test descriptors, which clearly and unambigously show which tests will be run. As an example, <code>:tier1</code> will expand to <code>jtreg:jdk/test:tier1 jtreg:langtools/test:tier1 jtreg:nashorn/test:tier1 jtreg:jaxp/test:tier1</code>. You can always submit a list of fully qualified test descriptors in the <code>TEST</code> variable if you want to shortcut the parser.</p>
-<h3 id="jtreg">JTreg</h3>
-<p>JTreg test groups can be specified either without a test root, e.g. <code>:tier1</code> (or <code>tier1</code>, the initial colon is optional), or with, e.g. <code>hotspot/test:tier1</code>, <code>jdk/test:jdk_util</code>.</p>
+<h3 id="jtreg">JTReg</h3>
+<p>JTReg test groups can be specified either without a test root, e.g. <code>:tier1</code> (or <code>tier1</code>, the initial colon is optional), or with, e.g. <code>hotspot/test:tier1</code>, <code>jdk/test:jdk_util</code>.</p>
 <p>When specified without a test root, all matching groups from all tests roots will be added. Otherwise, only the group from the specified test root will be added.</p>
-<p>Individual JTreg tests or directories containing JTreg tests can also be specified, like <code>hotspot/test/native_sanity/JniVersion.java</code> or <code>hotspot/test/native_sanity</code>. You can also specify an absolute path, to point to a JTreg test outside the source tree.</p>
+<p>Individual JTReg tests or directories containing JTReg tests can also be specified, like <code>hotspot/test/native_sanity/JniVersion.java</code> or <code>hotspot/test/native_sanity</code>. You can also specify an absolute path, to point to a JTReg test outside the source tree.</p>
 <p>As long as the test groups or test paths can be uniquely resolved, you do not need to enter the <code>jtreg:</code> prefix. If this is not possible, or if you want to use a fully qualified test descriptor, add <code>jtreg:</code>, e.g. <code>jtreg:hotspot/test/native_sanity</code>.</p>
 <h3 id="gtest">Gtest</h3>
 <p>Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just <code>gtest</code>, or as a fully qualified test descriptor <code>gtest:all</code>.</p>
@@ -67,15 +72,15 @@
 <p>Tests where the number of TOTAL tests does not equal the number of PASSed tests will be considered a test failure. These are marked with the <code>&gt;&gt; ... &lt;&lt;</code> marker for easy identification.</p>
 <p>The classification of non-passed tests differs a bit between test suites. In the summary, ERROR is used as a catch-all for tests that neither passed nor are classified as failed by the framework. This might indicate test framework error, timeout or other problems.</p>
 <p>In case of test failures, <code>make run-test</code> will exit with a non-zero exit value.</p>
-<p>All tests have their result stored in <code>build/$BUILD/test-result/$TEST_ID</code>, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for <code>jtreg:jdk/test:tier1</code> the TEST_ID is <code>jtreg_jdk_test_tier1</code>. This path is also printed in the log at the end of the test run.</p>
+<p>All tests have their result stored in <code>build/$BUILD/test-results/$TEST_ID</code>, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for <code>jtreg:jdk/test:tier1</code> the TEST_ID is <code>jtreg_jdk_test_tier1</code>. This path is also printed in the log at the end of the test run.</p>
 <p>Additional work data is stored in <code>build/$BUILD/test-support/$TEST_ID</code>. For some frameworks, this directory might contain information that is useful in determining the cause of a failed test.</p>
 <h2 id="test-suite-control">Test suite control</h2>
 <p>It is possible to control various aspects of the test suites using make control variables.</p>
-<p>These variables use a keyword=value approach to allow multiple values to be set. So, for instance, <code>JTREG=&quot;JOBS=1;TIMEOUT=8&quot;</code> will set the JTreg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting <code>JTREG_JOBS=1 JTREG_TIMEOUT=8</code>, but using the keyword format means that the <code>JTREG</code> variable is parsed and verified for correctness, so <code>JTREG=&quot;TMIEOUT=8&quot;</code> would give an error, while <code>JTREG_TMIEOUT=8</code> would just pass unnoticed.</p>
+<p>These variables use a keyword=value approach to allow multiple values to be set. So, for instance, <code>JTREG=&quot;JOBS=1;TIMEOUT=8&quot;</code> will set the JTReg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting <code>JTREG_JOBS=1 JTREG_TIMEOUT=8</code>, but using the keyword format means that the <code>JTREG</code> variable is parsed and verified for correctness, so <code>JTREG=&quot;TMIEOUT=8&quot;</code> would give an error, while <code>JTREG_TMIEOUT=8</code> would just pass unnoticed.</p>
 <p>To separate multiple keyword=value pairs, use <code>;</code> (semicolon). Since the shell normally eats <code>;</code>, the recommended usage is to write the assignment inside qoutes, e.g. <code>JTREG=&quot;...;...&quot;</code>. This will also make sure spaces are preserved, as in <code>JTREG=&quot;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;</code>.</p>
 <p>(Other ways are possible, e.g. using backslash: <code>JTREG=JOBS=1\;TIMEOUT=8</code>. Also, as a special technique, the string <code>%20</code> will be replaced with space for certain options, e.g. <code>JTREG=VM_OTIONS=-XshowSettings%20-Xlog:gc+ref=debug</code>. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)</p>
 <p>As far as possible, the names of the keywords have been standardized between test suites.</p>
-<h3 id="jtreg-keywords">JTreg keywords</h3>
+<h3 id="jtreg-keywords">JTReg keywords</h3>
 <h4 id="jobs">JOBS</h4>
 <p>The test concurrency (<code>-concurrency</code>).</p>
 <p>Defaults to TEST_JOBS (if set by <code>--with-test-jobs=</code>), otherwise it defaults to JOBS, except for Hotspot, where the default is <em>number of CPU cores/2</em>, but never more than 12.</p>
@@ -96,15 +101,15 @@
 <p>Defaults to <code>fail,error</code>.</p>
 <h4 id="max_mem">MAX_MEM</h4>
 <p>Limit memory consumption (<code>-Xmx</code> and <code>-vmoption:-Xmx</code>, or none).</p>
-<p>Limit memory consumption for JTreg test framework and VM under test. Set to 0 to disable the limits.</p>
+<p>Limit memory consumption for JTReg test framework and VM under test. Set to 0 to disable the limits.</p>
 <p>Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).</p>
 <h4 id="options">OPTIONS</h4>
-<p>Additional options to the JTreg test framework.</p>
-<p>Use <code>JTREG=&quot;OPTIONS=--help all&quot;</code> to see all available JTreg options.</p>
+<p>Additional options to the JTReg test framework.</p>
+<p>Use <code>JTREG=&quot;OPTIONS=--help all&quot;</code> to see all available JTReg options.</p>
 <h4 id="java_options">JAVA_OPTIONS</h4>
-<p>Additional Java options to JTreg (<code>-javaoption</code>).</p>
+<p>Additional Java options to JTReg (<code>-javaoption</code>).</p>
 <h4 id="vm_options">VM_OPTIONS</h4>
-<p>Additional VM options to JTreg (<code>-vmoption</code>).</p>
+<p>Additional VM options to JTReg (<code>-vmoption</code>).</p>
 <h3 id="gtest-keywords">Gtest keywords</h3>
 <h4 id="repeat">REPEAT</h4>
 <p>The number of times to repeat the tests (<code>--gtest_repeat</code>).</p>
--- a/common/doc/testing.md	Wed Jun 28 11:27:28 2017 -0700
+++ b/common/doc/testing.md	Thu Aug 24 16:24:44 2017 +0200
@@ -22,6 +22,15 @@
     $ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
     $ make exploded-run-test TEST=hotspot_tier1
 
+### Configuration
+
+To be able to run JTReg tests, `configure` needs to know where to find the
+JTReg test framework. If it is not picked up automatically by configure, use
+the `--with-jtreg=<path to jtreg home>` option to point to the JTReg framework.
+Note that this option should point to the JTReg home, i.e. the top directory,
+containing `lib/jtreg.jar` etc. (An alternative is to set the `JT_HOME`
+environment variable to point to the JTReg home before running `configure`.)
+
 ## Test selection
 
 All functionality is available using the run-test make target. In this use
@@ -30,7 +39,7 @@
 be used instead, which do not depend on the source and test image build.
 
 For some common top-level tests, direct make targets have been generated. This
-includes all JTreg test groups, the hotspot gtest, and custom tests (if
+includes all JTReg test groups, the hotspot gtest, and custom tests (if
 present). This means that `make run-test-tier1` is equivalent to `make run-test
 TEST="tier1"`, but the latter is more tab-completion friendly. For more complex
 test runs, the `run-test TEST="x"` solution needs to be used.
@@ -42,9 +51,9 @@
 can always submit a list of fully qualified test descriptors in the `TEST`
 variable if you want to shortcut the parser.
 
-### JTreg
+### JTReg
 
-JTreg test groups can be specified either without a test root, e.g. `:tier1`
+JTReg test groups can be specified either without a test root, e.g. `:tier1`
 (or `tier1`, the initial colon is optional), or with, e.g.
 `hotspot/test:tier1`, `jdk/test:jdk_util`.
 
@@ -52,10 +61,10 @@
 will be added. Otherwise, only the group from the specified test root will be
 added.
 
-Individual JTreg tests or directories containing JTreg tests can also be
+Individual JTReg tests or directories containing JTReg tests can also be
 specified, like `hotspot/test/native_sanity/JniVersion.java` or
 `hotspot/test/native_sanity`. You can also specify an absolute path, to point
-to a JTreg test outside the source tree.
+to a JTReg test outside the source tree.
 
 As long as the test groups or test paths can be uniquely resolved, you do not
 need to enter the `jtreg:` prefix. If this is not possible, or if you want to
@@ -99,7 +108,7 @@
 
 In case of test failures, `make run-test` will exit with a non-zero exit value.
 
-All tests have their result stored in `build/$BUILD/test-result/$TEST_ID`,
+All tests have their result stored in `build/$BUILD/test-results/$TEST_ID`,
 where TEST_ID is a path-safe conversion from the fully qualified test
 descriptor, e.g. for `jtreg:jdk/test:tier1` the TEST_ID is
 `jtreg_jdk_test_tier1`. This path is also printed in the log at the end of the
@@ -115,7 +124,7 @@
 variables.
 
 These variables use a keyword=value approach to allow multiple values to be
-set. So, for instance, `JTREG="JOBS=1;TIMEOUT=8"` will set the JTreg
+set. So, for instance, `JTREG="JOBS=1;TIMEOUT=8"` will set the JTReg
 concurrency level to 1 and the timeout factor to 8. This is equivalent to
 setting `JTREG_JOBS=1 JTREG_TIMEOUT=8`, but using the keyword format means that
 the `JTREG` variable is parsed and verified for correctness, so
@@ -136,7 +145,7 @@
 As far as possible, the names of the keywords have been standardized between
 test suites.
 
-### JTreg keywords
+### JTReg keywords
 
 #### JOBS
 The test concurrency (`-concurrency`).
@@ -174,21 +183,21 @@
 #### MAX_MEM
 Limit memory consumption (`-Xmx` and `-vmoption:-Xmx`, or none).
 
-Limit memory consumption for JTreg test framework and VM under test. Set to 0
+Limit memory consumption for JTReg test framework and VM under test. Set to 0
 to disable the limits.
 
 Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).
 
 #### OPTIONS
-Additional options to the JTreg test framework.
+Additional options to the JTReg test framework.
 
-Use `JTREG="OPTIONS=--help all"` to see all available JTreg options.
+Use `JTREG="OPTIONS=--help all"` to see all available JTReg options.
 
 #### JAVA_OPTIONS
-Additional Java options to JTreg (`-javaoption`).
+Additional Java options to JTReg (`-javaoption`).
 
 #### VM_OPTIONS
-Additional VM options to JTreg (`-vmoption`).
+Additional VM options to JTReg (`-vmoption`).
 
 ### Gtest keywords
 
--- a/corba/.hgtags	Wed Jun 28 11:27:28 2017 -0700
+++ b/corba/.hgtags	Thu Aug 24 16:24:44 2017 +0200
@@ -428,3 +428,7 @@
 95ed14547ca9246baed34f90ef3ca13217538a8c jdk-9+172
 8ef8a0f1c4dfea17e10125e1f885920538e63085 jdk-10+11
 534ba4f8cfcf12accc5b9adb943103f2ff79fe16 jdk-9+173
+3615768c12904e29bb2ec1b506cd4633cd8a9ced jdk-9+174
+00ae6307d78bac49883ddc85d687aa88c49f3971 jdk-10+12
+dc78a3dd6b3a4f11cdae8a3e3d160e6a78bc7838 jdk-9+175
+564fced058bd2c8375e9104aa8f9494642cd7bdd jdk-10+13
--- a/corba/.jcheck/conf	Wed Jun 28 11:27:28 2017 -0700
+++ b/corba/.jcheck/conf	Thu Aug 24 16:24:44 2017 +0200
@@ -1,1 +1,2 @@
 project=jdk10
+bugids=dup
--- a/corba/src/java.corba/share/classes/module-info.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/corba/src/java.corba/share/classes/module-info.java	Thu Aug 24 16:24:44 2017 +0200
@@ -26,18 +26,21 @@
 /**
  * Defines the Java binding of the OMG CORBA APIs, and the RMI-IIOP API.
  *
+ * <p> This module is upgradeble.
+ *
  * @moduleGraph
  * @since 9
  */
 @Deprecated(since="9", forRemoval=true)
 module java.corba {
-    requires transitive java.desktop;
-    requires transitive java.rmi;
     requires java.logging;
     requires java.naming;
     requires java.transaction;
     requires jdk.unsupported;
 
+    requires transitive java.desktop;
+    requires transitive java.rmi;
+
     exports javax.activity;
     exports javax.rmi;
     exports javax.rmi.CORBA;
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/BoundsHelper.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/BoundsHelper.java	Thu Aug 24 16:24:44 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 /**
  * This Helper class is used to facilitate the marshalling of {@code Bounds}.
  * For more information on Helper files, see
- * <a href="doc-files/generatedfiles.html#helper">
+ * <a href="{@docRoot}/org/omg/CORBA/doc-files/generatedfiles.html#helper">
  * "Generated Files: Helper Files"</a>.
  */
 
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/ORBPackage/InvalidNameHelper.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/ORBPackage/InvalidNameHelper.java	Thu Aug 24 16:24:44 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * This Helper class is used to facilitate the marshalling of
  * {@code ORBPackage/InvalidName}.
  * For more information on Helper files, see
- * <a href="doc-files/generatedfiles.html#helper">
+ * <a href="{@docRoot}/org/omg/CORBA/doc-files/generatedfiles.html#helper">
  * "Generated Files: Helper Files"</a>.
  */
 
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BadKindHelper.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BadKindHelper.java	Thu Aug 24 16:24:44 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * This Helper class is used to facilitate the marshalling of
  * {@code TypeCodePackage/BadKind}.
  * For more information on Helper files, see
- * <a href="doc-files/generatedfiles.html#helper">
+ * <a href="{@docRoot}/org/omg/CORBA/doc-files/generatedfiles.html#helper">
  * "Generated Files: Helper Files"</a>.
  */
 
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BoundsHelper.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCodePackage/BoundsHelper.java	Thu Aug 24 16:24:44 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * This Helper class is used to facilitate the marshalling of
  * {@code TypeCodePackage/Bounds}.
  * For more information on Helper files, see
- * <a href="doc-files/generatedfiles.html#helper">
+ * <a href="{@docRoot}/org/omg/CORBA/doc-files/generatedfiles.html#helper">
  * "Generated Files: Helper Files"</a>.
  */
 
--- a/hotspot/.hgtags	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/.hgtags	Thu Aug 24 16:24:44 2017 +0200
@@ -588,3 +588,7 @@
 1ae9e84f68b359420d2d153ecfe5ee2903e33a2e jdk-9+172
 7f14e550f1e8abea41c223e5fdad2261e99ba929 jdk-10+11
 e64b1cb48d6e7703928a9d1da106fc27f8cb65fd jdk-9+173
+944791f8160185bffa13fbb821fc09b6198f1f25 jdk-9+174
+070aa7a2eb14c4645f7eb31384cba0a2ba72a4b5 jdk-10+12
+8f04d457168b9f1f4a1b2c37f49e0513ca9d33a7 jdk-9+175
+a9da03357f190807591177fe9846d6e68ad64fc0 jdk-10+13
--- a/hotspot/.jcheck/conf	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/.jcheck/conf	Thu Aug 24 16:24:44 2017 +0200
@@ -1,1 +1,2 @@
 project=jdk10
+bugids=dup
--- a/hotspot/make/symbols/symbols-unix	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/make/symbols/symbols-unix	Thu Aug 24 16:24:44 2017 +0200
@@ -188,7 +188,6 @@
 JVM_AddModuleExports
 JVM_AddModuleExportsToAll
 JVM_AddModuleExportsToAllUnnamed
-JVM_AddModulePackage
 JVM_AddReadsModule
 JVM_DefineModule
 JVM_SetBootLoaderUnnamedModule
--- a/hotspot/make/test/JtregNative.gmk	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/make/test/JtregNative.gmk	Thu Aug 24 16:24:44 2017 +0200
@@ -56,6 +56,7 @@
     $(HOTSPOT_TOPDIR)/test/compiler/floatingpoint/ \
     $(HOTSPOT_TOPDIR)/test/compiler/calls \
     $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/GetNamedModule \
+    $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/IsModifiableModule \
     $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleReads \
     $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleExportsAndOpens \
     $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleUsesAndProvides \
@@ -85,6 +86,7 @@
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_liboverflow := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libSimpleClassFileLoadHook := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetNamedModuleTest := -lc
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libIsModifiableModuleTest := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleReadsTest := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleExportsAndOpensTest := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleUsesAndProvidesTest := -lc
--- a/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -109,9 +109,15 @@
   // for the callee's params we only need to account for the extra
   // locals.
   int size = overhead +
-         (callee_locals - callee_params)*Interpreter::stackElementWords +
+         (callee_locals - callee_params) +
          monitors * frame::interpreter_frame_monitor_size() +
-         temps* Interpreter::stackElementWords + extra_args;
+         // On the top frame, at all times SP <= ESP, and SP is
+         // 16-aligned.  We ensure this by adjusting SP on method
+         // entry and re-entry to allow room for the maximum size of
+         // the expression stack.  When we call another method we bump
+         // SP so that no stack space is wasted.  So, only on the top
+         // frame do we need to allow max_stack words.
+         (is_top_frame ? max_stack : temps + extra_args);
 
   // On AArch64 we always keep the stack pointer 16-aligned, so we
   // must round up here.
--- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -598,12 +598,12 @@
   } else {
     assert (x->op() == Bytecodes::_imul, "expect imul");
     if (right.is_constant()) {
-      int c = right.get_jint_constant();
-      if (! is_power_of_2(c) && ! is_power_of_2(c + 1) && ! is_power_of_2(c - 1)) {
+      jint c = right.get_jint_constant();
+      if (c > 0 && c < max_jint && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) {
+        right_arg->dont_load_item();
+      } else {
         // Cannot use constant op.
-        right.load_item();
-      } else {
-        right.dont_load_item();
+        right_arg->load_item();
       }
     } else {
       right.load_item();
--- a/hotspot/src/cpu/aarch64/vm/vtableStubs_aarch64.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/cpu/aarch64/vm/vtableStubs_aarch64.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -51,6 +51,11 @@
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
   const int aarch64_code_length = VtableStub::pd_code_size_limit(true);
   VtableStub* s = new(aarch64_code_length) VtableStub(true, vtable_index);
+  // Can be NULL if there is no free space in the code cache.
+  if (s == NULL) {
+    return NULL;
+  }
+
   ResourceMark rm;
   CodeBuffer cb(s->entry_point(), aarch64_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
--- a/hotspot/src/cpu/arm/vm/c1_LIRGenerator_arm.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/cpu/arm/vm/c1_LIRGenerator_arm.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -923,8 +923,8 @@
   } else {
     left_arg->load_item();
     if (x->op() == Bytecodes::_imul && right_arg->is_constant()) {
-      int c = right_arg->get_jint_constant();
-      if (c > 0 && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) {
+      jint c = right_arg->get_jint_constant();
+      if (c > 0 && c < max_jint && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) {
         right_arg->dont_load_item();
       } else {
         right_arg->load_item();
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -234,8 +234,8 @@
 }
 
 
-bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) {
-  if (tmp->is_valid()) {
+bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, jint c, LIR_Opr result, LIR_Opr tmp) {
+  if (tmp->is_valid() && c > 0 && c < max_jint) {
     if (is_power_of_2(c + 1)) {
       __ move(left, tmp);
       __ shift_left(left, log2_intptr(c + 1), left);
@@ -603,8 +603,8 @@
       bool use_constant = false;
       bool use_tmp = false;
       if (right_arg->is_constant()) {
-        int iconst = right_arg->get_jint_constant();
-        if (iconst > 0) {
+        jint iconst = right_arg->get_jint_constant();
+        if (iconst > 0 && iconst < max_jint) {
           if (is_power_of_2(iconst)) {
             use_constant = true;
           } else if (is_power_of_2(iconst - 1) || is_power_of_2(iconst + 1)) {
--- a/hotspot/src/jdk.aot/share/classes/module-info.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/jdk.aot/share/classes/module-info.java	Thu Aug 24 16:24:44 2017 +0200
@@ -23,8 +23,15 @@
  * questions.
  */
 
+/**
+ * Defines the Ahead-of-Time (AOT) compiler, <em>{@index jaotc jaotc tool}</em>,
+ * for compiling Java classes into AOT library.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.aot {
-    requires jdk.management;
     requires jdk.internal.vm.ci;
     requires jdk.internal.vm.compiler;
+    requires jdk.management;
 }
--- a/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java	Thu Aug 24 16:24:44 2017 +0200
@@ -26,6 +26,15 @@
 /**
  * Defines the implementation of the HotSpot Serviceability Agent.
  *
+ * <p> This module includes the <em>{@index jhsdb jhsdb tool}</em> tool to
+ * attach to a running Java Virtual Machine (JVM) or launch a postmortem
+ * debugger to analyze the content of a core-dump from a crashed JVM.
+ *
+ * <dl style="font-family:'DejaVu Sans', Arial, Helvetica, sans serif">
+ * <dt class="simpleTagLabel">Tool Guides:</dt>
+ * <dd> {@extLink jhsdb_tool_reference jhsdb}</dd>
+ * </dl>
+ *
  * @moduleGraph
  * @since 9
  */
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Thu Aug 24 16:24:44 2017 +0200
@@ -644,4 +644,9 @@
      *         {@link Long}
      */
     native Object getFlagValue(String name);
+
+    /**
+     * Gets the host class for {@code type}.
+     */
+    native HotSpotResolvedObjectTypeImpl getHostClass(HotSpotResolvedObjectTypeImpl type);
 }
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java	Thu Aug 24 16:24:44 2017 +0200
@@ -412,6 +412,14 @@
     }
 
     @Override
+    public ResolvedJavaType getHostClass() {
+        if (isArray()) {
+            return null;
+        }
+        return compilerToVM().getHostClass(this);
+    }
+
+    @Override
     public boolean isJavaLangObject() {
         return javaClass.equals(Object.class);
     }
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java	Thu Aug 24 16:24:44 2017 +0200
@@ -154,6 +154,11 @@
     }
 
     @Override
+    public ResolvedJavaType getHostClass() {
+        return null;
+    }
+
+    @Override
     public JavaKind getJavaKind() {
         return kind;
     }
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java	Thu Aug 24 16:24:44 2017 +0200
@@ -105,6 +105,13 @@
     boolean isAssignableFrom(ResolvedJavaType other);
 
     /**
+     * Returns the {@link ResolvedJavaType} object representing the host class of this VM anonymous
+     * class (as opposed to the unrelated concept specified by {@link Class#isAnonymousClass()}) or
+     * {@code null} if this object does not represent a VM anonymous class.
+     */
+    ResolvedJavaType getHostClass();
+
+    /**
      * Returns true if this type is exactly the type {@link java.lang.Object}.
      */
     default boolean isJavaLangObject() {
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/module-info.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/module-info.java	Thu Aug 24 16:24:44 2017 +0200
@@ -26,11 +26,9 @@
 module jdk.internal.vm.compiler {
     requires java.instrument;
     requires java.management;
+    requires jdk.internal.vm.ci;
     requires jdk.management;
-    requires jdk.internal.vm.ci;
-
-    // sun.misc.Unsafe is used
-    requires jdk.unsupported;
+    requires jdk.unsupported;   // sun.misc.Unsafe is used
 
     uses org.graalvm.compiler.code.DisassemblerProvider;
     uses org.graalvm.compiler.core.match.MatchStatementSet;
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java	Thu Aug 24 16:24:44 2017 +0200
@@ -251,7 +251,13 @@
 
         for (JavaKind kind : new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object}) {
             Class<?> javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass();
-            r.register5("compareAndSwap" + kind.name(), Receiver.class, Object.class, long.class, javaClass, javaClass, new InvocationPlugin() {
+            String casName;
+            if (Java8OrEarlier) {
+                casName = "compareAndSwap";
+            } else {
+                casName = "compareAndSet";
+            }
+            r.register5(casName + kind.name(), Receiver.class, Object.class, long.class, javaClass, javaClass, new InvocationPlugin() {
                 @Override
                 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode expected, ValueNode x) {
                     // Emits a null-check for the otherwise unused receiver
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -545,11 +545,11 @@
 
     case Bytecodes::_imul:
       {
-        bool    did_strength_reduce = false;
+        bool did_strength_reduce = false;
 
         if (right->is_constant()) {
-          int c = right->as_jint();
-          if (is_power_of_2(c)) {
+          jint c = right->as_jint();
+          if (c > 0 && is_power_of_2(c)) {
             // do not need tmp here
             __ shift_left(left_op, exact_log2(c), result_op);
             did_strength_reduce = true;
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Thu Aug 24 16:24:44 2017 +0200
@@ -313,7 +313,7 @@
   // is_strictfp is only needed for mul and div (and only generates different code on i486)
   void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp, CodeEmitInfo* info = NULL);
   // machine dependent.  returns true if it emitted code for the multiply
-  bool strength_reduce_multiply(LIR_Opr left, int constant, LIR_Opr result, LIR_Opr tmp);
+  bool strength_reduce_multiply(LIR_Opr left, jint constant, LIR_Opr result, LIR_Opr tmp);
 
   void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes);
 
--- a/hotspot/src/share/vm/classfile/modules.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/classfile/modules.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -722,74 +722,6 @@
   return NULL;
 }
 
-void Modules::add_module_package(jobject module, const char* package_name, TRAPS) {
-  ResourceMark rm(THREAD);
-
-  if (module == NULL) {
-    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
-              "module is null");
-  }
-  if (package_name == NULL) {
-    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
-              "package is null");
-  }
-  ModuleEntry* module_entry = get_module_entry(module, CHECK);
-  if (module_entry == NULL) {
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              "module is invalid");
-  }
-  if (!module_entry->is_named()) {
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              "module cannot be an unnamed module");
-  }
-  if (!verify_package_name(package_name)) {
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              err_msg("Invalid package name: %s", package_name));
-  }
-
-  ClassLoaderData *loader_data = module_entry->loader_data();
-
-  // Only modules defined to either the boot or platform class loader, can define a "java/" package.
-  if (!loader_data->is_the_null_class_loader_data() &&
-      !loader_data->is_platform_class_loader_data() &&
-      (strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0 &&
-        (package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) {
-    const char* class_loader_name = SystemDictionary::loader_name(loader_data);
-    size_t pkg_len = strlen(package_name);
-    char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len);
-    strncpy(pkg_name, package_name, pkg_len);
-    StringUtils::replace_no_expand(pkg_name, "/", ".");
-    const char* msg_text1 = "Class loader (instance of): ";
-    const char* msg_text2 = " tried to define prohibited package name: ";
-    size_t len = strlen(msg_text1) + strlen(class_loader_name) + strlen(msg_text2) + pkg_len + 1;
-    char* message = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, len);
-    jio_snprintf(message, len, "%s%s%s%s", msg_text1, class_loader_name, msg_text2, pkg_name);
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), message);
-  }
-
-  log_debug(module)("add_module_package(): Adding package %s to module %s",
-                    package_name, module_entry->name()->as_C_string());
-
-  TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK);
-  PackageEntryTable* package_table = loader_data->packages();
-  assert(package_table != NULL, "Missing package_table");
-
-  PackageEntry* existing_pkg = NULL;
-  {
-    MutexLocker ml(Module_lock, THREAD);
-
-    // Check that the package does not exist in the class loader's package table.
-    existing_pkg = package_table->lookup_only(pkg_symbol);
-    if (existing_pkg == NULL) {
-      PackageEntry* pkg = package_table->locked_create_entry_or_null(pkg_symbol, module_entry);
-      assert(pkg != NULL, "Unable to create a module's package entry");
-    }
-  }
-  if (existing_pkg != NULL) {
-    throw_dup_pkg_exception(module_entry->name()->as_C_string(), existing_pkg, CHECK);
-  }
-}
-
 // Export package in module to all unnamed modules.
 void Modules::add_module_exports_to_all_unnamed(jobject module, const char* package_name, TRAPS) {
   if (module == NULL) {
--- a/hotspot/src/share/vm/classfile/modules.hpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/classfile/modules.hpp	Thu Aug 24 16:24:44 2017 +0200
@@ -113,14 +113,6 @@
   // Returns NULL if package is invalid or not defined by loader.
   static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS);
 
-  // This adds package to module.
-  // It throws IllegalArgumentException if:
-  // * Module is bad
-  // * Module is unnamed
-  // * Package is not syntactically correct
-  // * Package is already defined for module's class loader.
-  static void add_module_package(jobject module, const char* package, TRAPS);
-
   // Marks the specified package as exported to all unnamed modules.
   // If either module or package is null then NullPointerException is thrown.
   // If module or package is bad, or module is unnamed, or package is not in
--- a/hotspot/src/share/vm/code/codeCache.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/code/codeCache.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -130,6 +130,7 @@
 // Iterate over all CodeHeaps
 #define FOR_ALL_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _heaps->begin(); heap != _heaps->end(); ++heap)
 #define FOR_ALL_NMETHOD_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _nmethod_heaps->begin(); heap != _nmethod_heaps->end(); ++heap)
+#define FOR_ALL_ALLOCABLE_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _allocable_heaps->begin(); heap != _allocable_heaps->end(); ++heap)
 
 // Iterate over all CodeBlobs (cb) on the given CodeHeap
 #define FOR_ALL_BLOBS(cb, heap) for (CodeBlob* cb = first_blob(heap); cb != NULL; cb = next_blob(heap, cb))
@@ -140,10 +141,11 @@
 bool CodeCache::_needs_cache_clean = false;
 nmethod* CodeCache::_scavenge_root_nmethods = NULL;
 
-// Initialize array of CodeHeaps
+// Initialize arrays of CodeHeap subsets
 GrowableArray<CodeHeap*>* CodeCache::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
 GrowableArray<CodeHeap*>* CodeCache::_compiled_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
 GrowableArray<CodeHeap*>* CodeCache::_nmethod_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
+GrowableArray<CodeHeap*>* CodeCache::_allocable_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
 
 void CodeCache::check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set) {
   size_t total_size = non_nmethod_size + profiled_size + non_profiled_size;
@@ -338,6 +340,7 @@
   return rs;
 }
 
+// Heaps available for allocation
 bool CodeCache::heap_available(int code_blob_type) {
   if (!SegmentedCodeCache) {
     // No segmentation: use a single code heap
@@ -391,6 +394,9 @@
   if (code_blob_type_accepts_nmethod(type)) {
     _nmethod_heaps->insert_sorted<code_heap_compare>(heap);
   }
+  if (code_blob_type_accepts_allocable(type)) {
+    _allocable_heaps->insert_sorted<code_heap_compare>(heap);
+  }
 }
 
 void CodeCache::add_heap(ReservedSpace rs, const char* name, int code_blob_type) {
@@ -620,7 +626,7 @@
 
 void CodeCache::blobs_do(void f(CodeBlob* nm)) {
   assert_locked_or_safepoint(CodeCache_lock);
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_HEAPS(heap) {
     FOR_ALL_BLOBS(cb, *heap) {
       f(cb);
     }
@@ -663,7 +669,7 @@
 
 void CodeCache::blobs_do(CodeBlobClosure* f) {
   assert_locked_or_safepoint(CodeCache_lock);
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
     FOR_ALL_BLOBS(cb, *heap) {
       if (cb->is_alive()) {
         f->do_code_blob(cb);
@@ -960,7 +966,7 @@
 
 size_t CodeCache::capacity() {
   size_t cap = 0;
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
     cap += (*heap)->capacity();
   }
   return cap;
@@ -973,7 +979,7 @@
 
 size_t CodeCache::unallocated_capacity() {
   size_t unallocated_cap = 0;
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
     unallocated_cap += (*heap)->unallocated_capacity();
   }
   return unallocated_cap;
@@ -981,7 +987,7 @@
 
 size_t CodeCache::max_capacity() {
   size_t max_cap = 0;
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
     max_cap += (*heap)->max_capacity();
   }
   return max_cap;
@@ -1007,7 +1013,7 @@
 
 size_t CodeCache::bytes_allocated_in_freelists() {
   size_t allocated_bytes = 0;
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
     allocated_bytes += (*heap)->allocated_in_freelist();
   }
   return allocated_bytes;
@@ -1015,7 +1021,7 @@
 
 int CodeCache::allocated_segments() {
   int number_of_segments = 0;
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
     number_of_segments += (*heap)->allocated_segments();
   }
   return number_of_segments;
@@ -1023,7 +1029,7 @@
 
 size_t CodeCache::freelists_length() {
   size_t length = 0;
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
     length += (*heap)->freelist_length();
   }
   return length;
@@ -1354,7 +1360,7 @@
 
 void CodeCache::print_memory_overhead() {
   size_t wasted_bytes = 0;
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
       CodeHeap* curr_heap = *heap;
       for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) {
         HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
@@ -1400,7 +1406,7 @@
   ResourceMark rm;
 
   int i = 0;
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
     if ((_nmethod_heaps->length() >= 1) && Verbose) {
       tty->print_cr("-- %s --", (*heap)->name());
     }
@@ -1497,7 +1503,7 @@
   CodeBlob_sizes live;
   CodeBlob_sizes dead;
 
-  FOR_ALL_NMETHOD_HEAPS(heap) {
+  FOR_ALL_ALLOCABLE_HEAPS(heap) {
     FOR_ALL_BLOBS(cb, *heap) {
       if (!cb->is_alive()) {
         dead.add(cb);
@@ -1523,7 +1529,7 @@
     int number_of_blobs = 0;
     int number_of_oop_maps = 0;
     int map_size = 0;
-    FOR_ALL_NMETHOD_HEAPS(heap) {
+    FOR_ALL_ALLOCABLE_HEAPS(heap) {
       FOR_ALL_BLOBS(cb, *heap) {
         if (cb->is_alive()) {
           number_of_blobs++;
--- a/hotspot/src/share/vm/code/codeCache.hpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/code/codeCache.hpp	Thu Aug 24 16:24:44 2017 +0200
@@ -85,6 +85,7 @@
   static GrowableArray<CodeHeap*>* _heaps;
   static GrowableArray<CodeHeap*>* _compiled_heaps;
   static GrowableArray<CodeHeap*>* _nmethod_heaps;
+  static GrowableArray<CodeHeap*>* _allocable_heaps;
 
   static address _low_bound;                            // Lower bound of CodeHeap addresses
   static address _high_bound;                           // Upper bound of CodeHeap addresses
@@ -237,6 +238,11 @@
     return type == CodeBlobType::All || type <= CodeBlobType::MethodProfiled;
   }
 
+  static bool code_blob_type_accepts_allocable(int type) {
+    return type <= CodeBlobType::All;
+  }
+
+
   // Returns the CodeBlobType for the given compilation level
   static int get_code_blob_type(int comp_level) {
     if (comp_level == CompLevel_none ||
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -1557,7 +1557,7 @@
 
   // First thread to get here will initialize the compiler interface
 
-  if (!ciObjectFactory::is_initialized()) {
+  {
     ASSERT_IN_VM;
     MutexLocker only_one (CompileThread_lock, thread);
     if (!ciObjectFactory::is_initialized()) {
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -1687,6 +1687,13 @@
   }
 C2V_END
 
+C2V_VMENTRY(jobject, getHostClass, (JNIEnv*, jobject, jobject jvmci_type))
+  InstanceKlass* k = InstanceKlass::cast(CompilerToVM::asKlass(jvmci_type));
+  InstanceKlass* host = k->host_klass();
+  oop result = CompilerToVM::get_jvmci_type(host, CHECK_NULL);
+  return JNIHandles::make_local(THREAD, result);
+C2V_END
+
 C2V_VMENTRY(int, interpreterFrameSize, (JNIEnv*, jobject, jobject bytecode_frame_handle))
   if (bytecode_frame_handle == NULL) {
     THROW_0(vmSymbols::java_lang_NullPointerException());
@@ -1817,6 +1824,7 @@
   {CC "flushDebugOutput",                             CC "()V",                                                                             FN_PTR(flushDebugOutput)},
   {CC "methodDataProfileDataSize",                    CC "(JI)I",                                                                           FN_PTR(methodDataProfileDataSize)},
   {CC "getFingerprint",                               CC "(J)J",                                                                            FN_PTR(getFingerprint)},
+  {CC "getHostClass",                                 CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_KLASS,                                       FN_PTR(getHostClass)},
   {CC "interpreterFrameSize",                         CC "(" BYTECODE_FRAME ")I",                                                           FN_PTR(interpreterFrameSize)},
   {CC "compileToBytecode",                            CC "(" OBJECT ")V",                                                                   FN_PTR(compileToBytecode)},
   {CC "getFlagValue",                                 CC "(" STRING ")" OBJECT,                                                             FN_PTR(getFlagValue)},
--- a/hotspot/src/share/vm/prims/jvm.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -1039,11 +1039,6 @@
   Modules::add_reads_module(from_module, source_module, CHECK);
 JVM_END
 
-JVM_ENTRY (void, JVM_AddModulePackage(JNIEnv *env, jobject module, const char* package))
-  JVMWrapper("JVM_AddModulePackage");
-  Modules::add_module_package(module, package, CHECK);
-JVM_END
-
 // Reflection support //////////////////////////////////////////////////////////////////////////////
 
 JVM_ENTRY(jstring, JVM_GetClassName(JNIEnv *env, jclass cls))
--- a/hotspot/src/share/vm/prims/jvm.h	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/prims/jvm.h	Thu Aug 24 16:24:44 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -467,14 +467,6 @@
 JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module);
 
 /*
- * Add a package to a module.
- *  module:  module that will contain the package
- *  package: package to add to the module
- */
-JNIEXPORT void JNICALL
-JVM_AddModulePackage(JNIEnv* env,  jobject module, const char* package);
-
-/*
  * Reflection support functions
  */
 
--- a/hotspot/src/share/vm/prims/whitebox.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/prims/whitebox.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1457,15 +1457,6 @@
   Modules::add_reads_module(from_module, source_module, CHECK);
 WB_END
 
-WB_ENTRY(void, WB_AddModulePackage(JNIEnv* env, jobject o, jclass module, jstring package))
-  ResourceMark rm(THREAD);
-  char* package_name = NULL;
-  if (package != NULL) {
-      package_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(package));
-  }
-  Modules::add_module_package(module, package_name, CHECK);
-WB_END
-
 WB_ENTRY(jobject, WB_GetModuleByPackageName(JNIEnv* env, jobject o, jobject loader, jstring package))
   ResourceMark rm(THREAD);
   char* package_name = NULL;
@@ -1910,8 +1901,6 @@
                                                       (void*)&WB_AddModuleExports },
   {CC"AddReadsModule",     CC"(Ljava/lang/Object;Ljava/lang/Object;)V",
                                                       (void*)&WB_AddReadsModule },
-  {CC"AddModulePackage",   CC"(Ljava/lang/Object;Ljava/lang/String;)V",
-                                                      (void*)&WB_AddModulePackage },
   {CC"GetModuleByPackageName", CC"(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;",
                                                       (void*)&WB_GetModuleByPackageName },
   {CC"AddModuleExportsToAllUnnamed", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -2861,8 +2861,8 @@
       if (res != JNI_OK) {
         return res;
       }
-    } else if (match_option(option, "--permit-illegal-access")) {
-      if (!create_property("jdk.module.permitIllegalAccess", "true", ExternalProperty)) {
+    } else if (match_option(option, "--illegal-access=", &tail)) {
+      if (!create_property("jdk.module.illegalAccess", tail, ExternalProperty)) {
         return JNI_ENOMEM;
       }
     // -agentlib and -agentpath
--- a/hotspot/src/share/vm/services/lowMemoryDetector.cpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/services/lowMemoryDetector.cpp	Thu Aug 24 16:24:44 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -296,19 +296,41 @@
     Klass* k = Management::sun_management_Sensor_klass(CHECK);
     instanceKlassHandle sensorKlass (THREAD, k);
     Handle sensor_h(THREAD, _sensor_obj);
-    Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, CHECK);
+
+    Symbol* trigger_method_signature;
 
     JavaValue result(T_VOID);
     JavaCallArguments args(sensor_h);
     args.push_int((int) count);
-    args.push_oop(usage_h);
+
+    Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, THREAD);
+    // Call Sensor::trigger(int, MemoryUsage) to send notification to listeners.
+    // When OOME occurs and fails to allocate MemoryUsage object, call
+    // Sensor::trigger(int) instead.  The pending request will be processed
+    // but no notification will be sent.
+    if (HAS_PENDING_EXCEPTION) {
+       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
+       CLEAR_PENDING_EXCEPTION;
+       trigger_method_signature = vmSymbols::int_void_signature();
+    } else {
+       trigger_method_signature = vmSymbols::trigger_method_signature();
+       args.push_oop(usage_h);
+    }
 
     JavaCalls::call_virtual(&result,
-                            sensorKlass,
-                            vmSymbols::trigger_name(),
-                            vmSymbols::trigger_method_signature(),
-                            &args,
-                            CHECK);
+                        sensorKlass,
+                        vmSymbols::trigger_name(),
+                        trigger_method_signature,
+                        &args,
+                        THREAD);
+
+    if (HAS_PENDING_EXCEPTION) {
+       // We just clear the OOM pending exception that we might have encountered
+       // in Java's tiggerAction(), and continue with updating the counters since
+       // the Java counters have been updated too.
+       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
+       CLEAR_PENDING_EXCEPTION;
+     }
   }
 
   {
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Thu Aug 24 16:24:44 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1095,8 +1095,11 @@
 #undef min
 #endif
 
-#define max(a,b) Do_not_use_max_use_MAX2_instead
-#define min(a,b) Do_not_use_min_use_MIN2_instead
+// The following defines serve the purpose of preventing use of accidentally
+// included min max macros from compiling, while continuing to allow innocent
+// min and max identifiers in the code to compile as intended.
+#define max max
+#define min min
 
 // It is necessary to use templates here. Having normal overloaded
 // functions does not work because it is necessary to provide both 32-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/c1/MultiplyByMaxInt.java	Thu Aug 24 16:24:44 2017 +0200
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8181872
+ *
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,compiler.c1.MultiplyByMaxInt::test
+ *                   compiler.c1.MultiplyByMaxInt
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-BackgroundCompilation
+ *                   -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=3
+ *                   -XX:CompileCommand=dontinline,compiler.c1.MultiplyByMaxInt::test
+ *                   compiler.c1.MultiplyByMaxInt
+ */
+package compiler.c1;
+
+public class MultiplyByMaxInt {
+    static int test(int x) {
+        int loops = (x >>> 4) & 7;
+        while (loops-- > 0) {
+            x = (x * 2147483647) % 16807;
+        }
+        return x;
+    }
+
+    public static void main(String[] args) {
+        for (int i = 0; i < 20000; i++) {
+            test(i);
+        }
+    }
+}
--- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java	Thu Aug 24 16:24:44 2017 +0200
@@ -773,221 +773,221 @@
 
   static void test_ci(int[] a) {
     for (int i = 0; i < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), -1, -123);
+      unsafe.compareAndSetInt(a, byte_offset(i), -1, -123);
     }
   }
   static void test_vi(int[] a, int b, int old) {
     for (int i = 0; i < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
+      unsafe.compareAndSetInt(a, byte_offset(i), old, b);
     }
   }
   static void test_cp(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
+      unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]);
     }
   }
   static void test_2ci(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
-      unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
+      unsafe.compareAndSetInt(a, byte_offset(i), 123, -123);
+      unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
     }
   }
   static void test_2vi(int[] a, int[] b, int c, int d) {
     for (int i = 0; i < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
-      unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
+      unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
+      unsafe.compareAndSetInt(b, byte_offset(i), -103, d);
     }
   }
   static void test_ci_neg(int[] a, int old) {
     for (int i = ARRLEN-1; i >= 0; i-=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), old, -123);
+      unsafe.compareAndSetInt(a, byte_offset(i), old, -123);
     }
   }
   static void test_vi_neg(int[] a, int b, int old) {
     for (int i = ARRLEN-1; i >= 0; i-=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
+      unsafe.compareAndSetInt(a, byte_offset(i), old, b);
     }
   }
   static void test_cp_neg(int[] a, int[] b) {
     for (int i = ARRLEN-1; i >= 0; i-=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
+      unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]);
     }
   }
   static void test_2ci_neg(int[] a, int[] b) {
     for (int i = ARRLEN-1; i >= 0; i-=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
-      unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
+      unsafe.compareAndSetInt(a, byte_offset(i), 123, -123);
+      unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
     }
   }
   static void test_2vi_neg(int[] a, int[] b, int c, int d) {
     for (int i = ARRLEN-1; i >= 0; i-=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
-      unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
+      unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
+      unsafe.compareAndSetInt(b, byte_offset(i), -103, d);
     }
   }
   static void test_ci_oppos(int[] a, int old) {
     int limit = ARRLEN-1;
     for (int i = 0; i < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, -123);
+      unsafe.compareAndSetInt(a, byte_offset(limit-i), old, -123);
     }
   }
   static void test_vi_oppos(int[] a, int b, int old) {
     int limit = ARRLEN-1;
     for (int i = limit; i >= 0; i-=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, b);
+      unsafe.compareAndSetInt(a, byte_offset(limit-i), old, b);
     }
   }
   static void test_cp_oppos(int[] a, int[] b) {
     int limit = ARRLEN-1;
     for (int i = 0; i < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[limit-i]);
+      unsafe.compareAndSetInt(a, byte_offset(i), -123, b[limit-i]);
     }
   }
   static void test_2ci_oppos(int[] a, int[] b) {
     int limit = ARRLEN-1;
     for (int i = 0; i < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(limit-i), 123, -123);
-      unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
+      unsafe.compareAndSetInt(a, byte_offset(limit-i), 123, -123);
+      unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
     }
   }
   static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
     int limit = ARRLEN-1;
     for (int i = limit; i >= 0; i-=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
-      unsafe.compareAndSwapInt(b, byte_offset(limit-i), -103, d);
+      unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
+      unsafe.compareAndSetInt(b, byte_offset(limit-i), -103, d);
     }
   }
   static void test_ci_off(int[] a, int old) {
     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, -123);
+      unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, -123);
     }
   }
   static void test_vi_off(int[] a, int b, int old) {
     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, b);
+      unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, b);
     }
   }
   static void test_cp_off(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
+      unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
     }
   }
   static void test_2ci_off(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), 123, -123);
-      unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), 123, -103);
+      unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), 123, -123);
+      unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), 123, -103);
     }
   }
   static void test_2vi_off(int[] a, int[] b, int c, int d) {
     for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, c);
-      unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), -103, d);
+      unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, c);
+      unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), -103, d);
     }
   }
   static void test_ci_inv(int[] a, int k, int old) {
     for (int i = 0; i < ARRLEN-k; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+k), old, -123);
+      unsafe.compareAndSetInt(a, byte_offset(i+k), old, -123);
     }
   }
   static void test_vi_inv(int[] a, int b, int k, int old) {
     for (int i = 0; i < ARRLEN-k; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+k), old, b);
+      unsafe.compareAndSetInt(a, byte_offset(i+k), old, b);
     }
   }
   static void test_cp_inv(int[] a, int[] b, int k) {
     for (int i = 0; i < ARRLEN-k; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, b[i+k]);
+      unsafe.compareAndSetInt(a, byte_offset(i+k), -123, b[i+k]);
     }
   }
   static void test_2ci_inv(int[] a, int[] b, int k) {
     for (int i = 0; i < ARRLEN-k; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+k), 123, -123);
-      unsafe.compareAndSwapInt(b, byte_offset(i+k), 123, -103);
+      unsafe.compareAndSetInt(a, byte_offset(i+k), 123, -123);
+      unsafe.compareAndSetInt(b, byte_offset(i+k), 123, -103);
     }
   }
   static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
     for (int i = 0; i < ARRLEN-k; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, c);
-      unsafe.compareAndSwapInt(b, byte_offset(i+k), -103, d);
+      unsafe.compareAndSetInt(a, byte_offset(i+k), -123, c);
+      unsafe.compareAndSetInt(b, byte_offset(i+k), -103, d);
     }
   }
   static void test_ci_scl(int[] a, int old) {
     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, -123);
+      unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, -123);
     }
   }
   static void test_vi_scl(int[] a, int b, int old) {
     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, b);
+      unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, b);
     }
   }
   static void test_cp_scl(int[] a, int[] b) {
     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
+      unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
     }
   }
   static void test_2ci_scl(int[] a, int[] b) {
     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), 123, -123);
-      unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), 123, -103);
+      unsafe.compareAndSetInt(a, byte_offset(i*SCALE), 123, -123);
+      unsafe.compareAndSetInt(b, byte_offset(i*SCALE), 123, -103);
     }
   }
   static void test_2vi_scl(int[] a, int[] b, int c, int d) {
     for (int i = 0; i*SCALE < ARRLEN; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, c);
-      unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), -103, d);
+      unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, c);
+      unsafe.compareAndSetInt(b, byte_offset(i*SCALE), -103, d);
     }
   }
   static void test_cp_alndst(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
+      unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
     }
   }
   static void test_cp_alnsrc(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
       int old = unsafe.getIntVolatile(a, byte_offset(i));
-      unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
+      unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
     }
   }
   static void test_2ci_aln(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
+      unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
       int old = unsafe.getIntVolatile(b, byte_offset(i));
-      unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
+      unsafe.compareAndSetInt(b, byte_offset(i), old, -103);
     }
   }
   static void test_2vi_aln(int[] a, int[] b, int c, int d) {
     for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
       int old = unsafe.getIntVolatile(a, byte_offset(i));
-      unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
+      unsafe.compareAndSetInt(a, byte_offset(i), old, c);
       old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF));
-      unsafe.compareAndSwapInt(b, byte_offset(i+ALIGN_OFF), old, d);
+      unsafe.compareAndSetInt(b, byte_offset(i+ALIGN_OFF), old, d);
     }
   }
   static void test_cp_unalndst(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
+      unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
     }
   }
   static void test_cp_unalnsrc(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
       int old = unsafe.getIntVolatile(a, byte_offset(i));
-      unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
+      unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
     }
   }
   static void test_2ci_unaln(int[] a, int[] b) {
     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
-      unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
+      unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
       int old = unsafe.getIntVolatile(b, byte_offset(i));
-      unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
+      unsafe.compareAndSetInt(b, byte_offset(i), old, -103);
     }
   }
   static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
     for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
       int old = unsafe.getIntVolatile(a, byte_offset(i));
-      unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
+      unsafe.compareAndSetInt(a, byte_offset(i), old, c);
       old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF));
-      unsafe.compareAndSwapInt(b, byte_offset(i+UNALIGN_OFF), old, d);
+      unsafe.compareAndSetInt(b, byte_offset(i+UNALIGN_OFF), old, d);
     }
   }
 
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java	Thu Aug 24 16:24:44 2017 +0200
@@ -54,6 +54,7 @@
 import java.lang.reflect.Modifier;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.function.Supplier;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -143,6 +144,27 @@
     }
 
     @Test
+    public void getHostClassTest() {
+        for (Class<?> c : classes) {
+            ResolvedJavaType type = metaAccess.lookupJavaType(c);
+            ResolvedJavaType host = type.getHostClass();
+            assertNull(host);
+        }
+
+        class LocalClass {}
+        Cloneable clone = new Cloneable() {};
+        assertNull(metaAccess.lookupJavaType(LocalClass.class).getHostClass());
+        assertNull(metaAccess.lookupJavaType(clone.getClass()).getHostClass());
+
+        Supplier<Runnable> lambda = () -> () -> System.out.println("run");
+        ResolvedJavaType lambdaType = metaAccess.lookupJavaType(lambda.getClass());
+        ResolvedJavaType nestedLambdaType = metaAccess.lookupJavaType(lambda.get().getClass());
+        assertNotNull(lambdaType.getHostClass());
+        assertNotNull(nestedLambdaType.getHostClass());
+        assertEquals(lambdaType.getHostClass(), nestedLambdaType.getHostClass());
+    }
+
+    @Test
     public void getModifiersTest() {
         for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
--- a/hotspot/test/compiler/profiling/UnsafeAccess.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/test/compiler/profiling/UnsafeAccess.java	Thu Aug 24 16:24:44 2017 +0200
@@ -64,7 +64,7 @@
     static Object helperUnsafeLoadStore(Object o, boolean isObjArray) {
         if (isObjArray) {
             Object o1 = U.getObject(o, off);
-            U.compareAndSwapObject(o, off, o1, new Object());
+            U.compareAndSetObject(o, off, o1, new Object());
         }
         return o;
     }
--- a/hotspot/test/runtime/modules/JVMAddModulePackage.java	Wed Jun 28 11:27:28 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @modules java.base/jdk.internal.misc
- * @library /test/lib ..
- * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModulePackage
- */
-
-import static jdk.test.lib.Asserts.*;
-import java.sql.Time;
-
-public class JVMAddModulePackage {
-
-    public static void main(String args[]) throws Throwable {
-        MyClassLoader cl1 = new MyClassLoader();
-        MyClassLoader cl3 = new MyClassLoader();
-        Object module_one, module_two, module_three;
-        boolean result;
-
-        module_one = ModuleHelper.ModuleObject("module_one", cl1, new String[] { "mypackage" });
-        assertNotNull(module_one, "Module should not be null");
-        ModuleHelper.DefineModule(module_one, "9.0", "module_one/here", new String[] { "mypackage" });
-        module_two = ModuleHelper.ModuleObject("module_two", cl1, new String[] { "yourpackage" });
-        assertNotNull(module_two, "Module should not be null");
-        ModuleHelper.DefineModule(module_two, "9.0", "module_two/here", new String[] { "yourpackage" });
-        module_three = ModuleHelper.ModuleObject("module_three", cl3, new String[] { "apackage/num3" });
-        assertNotNull(module_three, "Module should not be null");
-        ModuleHelper.DefineModule(module_three, "9.0", "module_three/here", new String[] { "apackage/num3" });
-
-        // Simple call
-        ModuleHelper.AddModulePackage(module_one, "new_package");
-
-        // Add a package and export it
-        ModuleHelper.AddModulePackage(module_one, "apackage/num3");
-        ModuleHelper.AddModuleExportsToAll(module_one, "apackage/num3");
-
-        // Null module argument, expect an NPE
-        try {
-            ModuleHelper.AddModulePackage(null, "new_package");
-            throw new RuntimeException("Failed to get the expected NPE");
-        } catch(NullPointerException e) {
-            // Expected
-        }
-
-        // Bad module argument, expect an IAE
-        try {
-            ModuleHelper.AddModulePackage(cl1, "new_package");
-            throw new RuntimeException("Failed to get the expected IAE");
-        } catch(IllegalArgumentException e) {
-            // Expected
-        }
-
-        // Null package argument, expect an NPE
-        try {
-            ModuleHelper.AddModulePackage(module_one, null);
-            throw new RuntimeException("Failed to get the expected NPE");
-        } catch(NullPointerException e) {
-            // Expected
-        }
-
-        // Existing package, expect an ISE
-        try {
-            ModuleHelper.AddModulePackage(module_one, "yourpackage");
-            throw new RuntimeException("Failed to get the expected ISE");
-        } catch(IllegalStateException e) {
-            // Expected
-        }
-
-        // Invalid package name, expect an IAE
-        try {
-            ModuleHelper.AddModulePackage(module_one, "your.apackage");
-            throw new RuntimeException("Failed to get the expected IAE");
-        } catch(IllegalArgumentException e) {
-            // Expected
-        }
-
-        // Invalid package name, expect an IAE
-        try {
-            ModuleHelper.AddModulePackage(module_one, ";your/apackage");
-            throw new RuntimeException("Failed to get the expected IAE");
-        } catch(IllegalArgumentException e) {
-            // Expected
-        }
-
-        // Invalid package name, expect an IAE
-        try {
-            ModuleHelper.AddModulePackage(module_one, "7[743");
-            throw new RuntimeException("Failed to get the expected IAE");
-        } catch(IllegalArgumentException e) {
-            // Expected
-        }
-
-        // Empty package name, expect an IAE
-        try {
-            ModuleHelper.AddModulePackage(module_one, "");
-            throw new RuntimeException("Failed to get the expected IAE");
-        } catch(IllegalArgumentException e) {
-            // Expected
-        }
-
-        // Add package named "java" to an module defined to a class loader other than the boot or platform loader.
-        try {
-            // module_one is defined to a MyClassLoader class loader.
-            ModuleHelper.AddModulePackage(module_one, "java/foo");
-            throw new RuntimeException("Failed to get the expected IAE");
-        } catch(IllegalArgumentException e) {
-            if (!e.getMessage().contains("prohibited package name")) {
-              throw new RuntimeException("Failed to get expected IAE message for prohibited package name: " + e.getMessage());
-            }
-        }
-
-        // Package "javabar" should be ok
-        ModuleHelper.AddModulePackage(module_one, "javabar");
-
-        // Package named "java" defined to the boot class loader, should be ok
-        Object module_javabase = module_one.getClass().getModule();
-        ModuleHelper.AddModulePackage(module_javabase, "java/foo");
-
-        // Package named "java" defined to the platform class loader, should be ok
-        // The module java.sql is defined to the platform class loader.
-        java.sql.Time jst = new java.sql.Time(45000); // milliseconds
-        Object module_javasql = jst.getClass().getModule();
-        ModuleHelper.AddModulePackage(module_javasql, "java/foo");
-    }
-
-    static class MyClassLoader extends ClassLoader { }
-}
-
--- a/hotspot/test/runtime/modules/ModuleHelper.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/test/runtime/modules/ModuleHelper.java	Thu Aug 24 16:24:44 2017 +0200
@@ -49,12 +49,6 @@
         java.lang.ModuleHelper.addReadsNoSync((Module)from, (Module)to);
     }
 
-    public static void AddModulePackage(Object m, String pkg) throws Throwable {
-        WhiteBox wb = WhiteBox.getWhiteBox();
-        wb.AddModulePackage(m, pkg);
-        java.lang.ModuleHelper.addPackageNoSync((Module)m, pkg);
-    }
-
     public static Module GetModuleByPackageName(Object ldr, String pkg) throws Throwable {
         WhiteBox wb = WhiteBox.getWhiteBox();
         return (Module)wb.GetModuleByPackageName(ldr, pkg);
--- a/hotspot/test/runtime/modules/java.base/java/lang/ModuleHelper.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/test/runtime/modules/java.base/java/lang/ModuleHelper.java	Thu Aug 24 16:24:44 2017 +0200
@@ -63,11 +63,4 @@
         }
     }
 
-    /**
-     * Adds a package to a module without notifying the VM.
-     */
-    public static void addPackageNoSync(Module m, String pkg) {
-        m.implAddPackageNoSync(pkg);
-    }
-
 }
--- a/hotspot/test/serviceability/jvmti/GetNamedModule/MyPackage/GetNamedModuleTest.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/test/serviceability/jvmti/GetNamedModule/MyPackage/GetNamedModuleTest.java	Thu Aug 24 16:24:44 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 /**
  * @test
  * @summary Verifies the JVMTI GetNamedModule API
+ * @modules jdk.jdi
  * @compile GetNamedModuleTest.java
  * @run main/othervm/native -agentlib:GetNamedModuleTest MyPackage.GetNamedModuleTest
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/IsModifiableModule/MyPackage/IsModifiableModuleTest.java	Thu Aug 24 16:24:44 2017 +0200
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package MyPackage;
+
+/**
+ * @test
+ * @summary Verifies the JVMTI IsModifiableModule API
+ * @modules jdk.jdi
+ * @compile IsModifiableModuleTest.java
+ * @run main/othervm/native -agentlib:IsModifiableModuleTest MyPackage.IsModifiableModuleTest
+ */
+
+import java.io.PrintStream;
+
+public class IsModifiableModuleTest {
+
+    static {
+        try {
+            System.loadLibrary("IsModifiableModuleTest");
+        } catch (UnsatisfiedLinkError ule) {
+            System.err.println("Could not load IsModifiableModuleTest library");
+            System.err.println("java.library.path: "
+                + System.getProperty("java.library.path"));
+            throw ule;
+        }
+    }
+
+    native static int check();
+
+    public static void main(String args[]) {
+        int status = check();
+        if (status != 0) {
+            throw new RuntimeException("Non-zero status returned from the agent: " + status);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/IsModifiableModule/libIsModifiableModuleTest.c	Thu Aug 24 16:24:44 2017 +0200
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "jvmti.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JNI_ENV_ARG
+
+#ifdef __cplusplus
+#define JNI_ENV_ARG(x, y) y
+#define JNI_ENV_PTR(x) x
+#else
+#define JNI_ENV_ARG(x,y) x, y
+#define JNI_ENV_PTR(x) (*x)
+#endif
+
+#endif
+
+#define TranslateError(err) "JVMTI error"
+
+#define PASSED 0
+#define FAILED 2
+
+static const char *EXC_CNAME = "java/lang/AssertionError";
+
+static jvmtiEnv *jvmti = NULL;
+static jint result = PASSED;
+static jboolean printdump = JNI_FALSE;
+
+static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
+
+JNIEXPORT
+jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
+    return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
+    return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
+    return JNI_VERSION_1_8;
+}
+
+static
+jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+    jint res;
+
+    if (options != NULL && strcmp(options, "printdump") == 0) {
+        printdump = JNI_TRUE;
+    }
+
+    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
+        JVMTI_VERSION_9);
+    if (res != JNI_OK || jvmti == NULL) {
+        printf("    Error: wrong result of a valid call to GetEnv!\n");
+        return JNI_ERR;
+    }
+
+    return JNI_OK;
+}
+
+static
+jclass find_class(JNIEnv *env, const char* cname) {
+    jclass cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, cname));
+
+    if (cls == NULL) {
+        printf("find_class: Error: FindClass(env, \"%s\") returned NULL\n", cname);
+    }
+    return cls;
+}
+
+static
+jint throw_exc(JNIEnv *env, char *msg) {
+    jclass exc_class = find_class(env, EXC_CNAME);
+
+    if (exc_class == NULL) {
+        printf("throw_exc: Error in find_class(env, \"%s\")\n", EXC_CNAME);
+        return -1;
+    }
+    return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg);
+}
+
+static jobject get_module_by_class_name(JNIEnv *env, const char* cname) {
+    jobject module = NULL;
+    jclass cls = find_class(env, cname);
+
+    printf(">>> getting module by class name: \"%s\"\n", cname);
+    if (cls == NULL) {
+        printf("get_module_by_class_name: Error in find_class(env, \"%s\")\n", cname);
+        return NULL;
+    }
+    module = JNI_ENV_PTR(env)->GetModule(JNI_ENV_ARG(env, cls));
+    if (module == NULL) {
+        printf("get_module_by_class_name: Error in GetModule for class \"%s\"\n", cname);
+    }
+    return module;
+}
+
+static
+jint check_is_modifiable_error_codes(jobject module, jobject not_a_module) {
+    jvmtiError err = JVMTI_ERROR_NONE;
+    jboolean is_modifiable = JNI_FALSE;
+
+    printf(">>> passing a bad module argument to JVMTI IsModifiableModule\n");
+    err = (*jvmti)->IsModifiableModule(jvmti, not_a_module, &is_modifiable);
+    if (err != JVMTI_ERROR_INVALID_MODULE) {
+        printf("    Error #EC0: Did not get expected INVALID_MODULE error code from"
+               " IsModifiableModule: %s (%d)\n", TranslateError(err), err);
+        return FAILED;
+    }
+    printf(">>> passing NULL module argument to JVMTI IsModifiableModule\n");
+    err = (*jvmti)->IsModifiableModule(jvmti, NULL, &is_modifiable);
+    if (err != JVMTI_ERROR_NULL_POINTER) {
+        printf("    Error #EC1: Did not get expected NULL_POINTER error code from"
+               " IsModifiableModule: %s (%d)\n", TranslateError(err), err);
+        return FAILED;
+    }
+    printf(">>> passing NULL status pointer to JVMTI IsModifiableModule\n");
+    err = (*jvmti)->IsModifiableModule(jvmti, module, NULL);
+    if (err != JVMTI_ERROR_NULL_POINTER) {
+        printf("    Error #EC2: Did not get expected NULL_POINTER error code from"
+               " IsModifiableModule: %s (%d)\n", TranslateError(err), err);
+        return FAILED;
+    }
+    return PASSED;
+}
+
+static
+jint check_is_modifiable(jobject module) {
+    jvmtiError err = JVMTI_ERROR_NONE;
+    jboolean is_modifiable = JNI_FALSE;
+
+    printf(">>> checking module %p is modifiable\n", module);
+    err = (*jvmti)->IsModifiableModule(jvmti, module, &is_modifiable);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in IsModifiableModule for module %p: %s (%d)\n",
+               module, TranslateError(err), err);
+        return FAILED;
+    }
+    if (is_modifiable == JNI_FALSE) {
+        printf("    unexpected non-modifiable status for module: %p\n", module);
+        return FAILED;
+    }
+    return PASSED;
+}
+
+JNIEXPORT jint JNICALL
+Java_MyPackage_IsModifiableModuleTest_check(JNIEnv *env, jclass cls) {
+    jobject module = NULL;
+
+    if (jvmti == NULL) {
+        throw_exc(env, "JVMTI client was not properly loaded!\n");
+        return FAILED;
+    }
+
+    printf("\n*** Testing IsModifiableModule ***\n\n");
+
+    if (check_is_modifiable_error_codes(module, cls) == FAILED) {
+        throw_exc(env, "check #MM0: failed to return expected error code from "
+                      "a bad call to JVMTI IsModifiableModule");
+        return FAILED;
+    }
+
+    module = get_module_by_class_name(env, "java/lang/Class");
+    if (check_is_modifiable(module) == FAILED) {
+        throw_exc(env, "check #MM1: failed to return modifiable module status");
+        return FAILED;
+    }
+
+    module = get_module_by_class_name(env, "com/sun/jdi/VirtualMachine");
+    if (check_is_modifiable(module) == FAILED) {
+        throw_exc(env, "check #MM2: failed to return modifiable module status");
+        return FAILED;
+    }
+
+    module = get_module_by_class_name(env, "MyPackage/IsModifiableModuleTest");
+    if (check_is_modifiable(module) == FAILED) {
+        throw_exc(env, "check #MM3: failed to return modifiable module status");
+        return FAILED;
+    }
+
+    return PASSED;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java	Wed Jun 28 11:27:28 2017 -0700
+++ b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java	Thu Aug 24 16:24:44 2017 +0200
@@ -51,8 +51,7 @@
         VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero", "isEmbedded"),
         MODE("isInt", "isMixed", "isComp"),
         IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild",
-                "shouldSAAttach", "canPtraceAttachLinux", "canAttachOSX",
-                "isTieredSupported");
+                "shouldSAAttach", "isTieredSupported");
 
         public final List<String> methodNames;
 
--- a/jaxp/.hgtags	Wed Jun 28 11:27:28 2017 -0700
+++ b/jaxp/.hgtags	Thu Aug 24 16:24:44 2017 +0200
@@ -428,3 +428,7 @@
 eedb6e54c8bd6197ecba5fc0d8568bac8ae852dd jdk-9+172
 95bab8bf9201ae8bfdf28e164bf33b78e49477e7 jdk-10+11
 9788347e0629d0cb3a0e55a903494ff741d4fa15 jdk-9+173
+b9c0b105002272d7414c8b34af9aded151f9cad6 jdk-9+174
+ff293e39e83366c40a5687dacd1ccb2305ed2c1e jdk-10+12
+736412a8dccee9d439044e6b1af2e7470d0a3563 jdk-9+175
+5d374af9e78d02976e0e7f8dc2706f91a020f025 jdk-10+13
--- a/jaxp/.jcheck/conf	Wed Jun 28 11:27:28 2017 -0700
+++ b/jaxp/.jcheck/conf	Thu Aug 24 16:24:44 2017 +0200
@@ -1,1 +1,2 @@
 project=jdk10
+bugids=dup
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java	Wed Jun 28 11:27:28 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,596 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xerces.internal.util;
-
-import java.io.IOException;
-
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.EntityResolver2;
-
-import org.w3c.dom.ls.LSInput;
-import org.w3c.dom.ls.LSResourceResolver;
-
-import javax.xml.parsers.SAXParserFactory;
-
-import com.sun.org.apache.xerces.internal.dom.DOMInputImpl;
-import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
-
-import com.sun.org.apache.xerces.internal.xni.XNIException;
-import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
-
-import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
-import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
-
-import com.sun.org.apache.xml.internal.resolver.Catalog;
-import com.sun.org.apache.xml.internal.resolver.CatalogManager;
-import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader;
-import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader;
-
-/**
- * <p>The catalog resolver handles the resolution of external
- * identifiers and URI references through XML catalogs. This
- * component supports XML catalogs defined by the
- * <a href="http://www.oasis-open.org/committees/entity/spec.html">
- * OASIS XML Catalogs Specification</a>. It encapsulates the
- * <a href="http://xml.apache.org/commons/">XML Commons</a> resolver.
- * An instance of this class may be registered on the parser
- * as a SAX entity resolver, as a DOM LSResourceResolver or
- * as an XNI entity resolver by setting the property
- * (http://apache.org/xml/properties/internal/entity-resolver).</p>
- *
- * <p>It is intended that this class may be used standalone to perform
- * catalog resolution outside of a parsing context. It may be shared
- * between several parsers and the application.</p>
- *
- * @deprecated This class and the JDK internal Catalog API in package
- * {@code com.sun.org.apache.xml.internal.resolver}
- * is encapsulated in JDK 9. The entire implementation under the package is now
- * deprecated and subject to removal in a future release. Users of the API should
- * migrate to the {@linkplain javax.xml.catalog new public API}.
- * <p>
- * The new Catalog API is supported throughout the JDK XML Processors, which allows
- * the use of Catalog by simply setting a path to a Catalog file as a property.
- *
- * @author Michael Glavassevich, IBM
- *
- */
-@Deprecated(since="9", forRemoval=true)
-public class XMLCatalogResolver
-    implements XMLEntityResolver, EntityResolver2, LSResourceResolver {
-
-    /** Internal catalog manager for Apache catalogs. **/
-    private CatalogManager fResolverCatalogManager = null;
-
-    /** Internal catalog structure. **/
-    private Catalog fCatalog = null;
-
-    /** An array of catalog URIs. **/
-    private String [] fCatalogsList = null;
-
-    /**
-     * Indicates whether the list of catalogs has
-     * changed since it was processed.
-     */
-    private boolean fCatalogsChanged = true;
-
-    /** Application specified prefer public setting. **/
-    private boolean fPreferPublic = true;
-
-    /**
-     * Indicates whether the application desires that
-     * the parser or some other component performing catalog
-     * resolution should use the literal system identifier
-     * instead of the expanded system identifier.
-     */
-    private boolean fUseLiteralSystemId = true;
-
-    /**
-     * <p>Constructs a catalog resolver with a default configuration.</p>
-     */
-    public XMLCatalogResolver () {
-        this(null, true);
-    }
-
-    /**
-     * <p>Constructs a catalog resolver with the given
-     * list of entry files.</p>
-     *
-     * @param catalogs an ordered array list of absolute URIs
-     */
-    public XMLCatalogResolver (String [] catalogs) {
-        this(catalogs, true);
-    }
-
-    /**
-     * <p>Constructs a catalog resolver with the given
-     * list of entry files and the preference for whether
-     * system or public matches are preferred.</p>
-     *
-     * @param catalogs an ordered array list of absolute URIs
-     * @param preferPublic the prefer public setting
-     */
-    public XMLCatalogResolver (String [] catalogs, boolean preferPublic) {
-        init(catalogs, preferPublic);
-    }
-
-    /**
-     * <p>Returns the initial list of catalog entry files.</p>
-     *
-     * @return the initial list of catalog entry files
-     */
-    public final synchronized String [] getCatalogList () {
-        return (fCatalogsList != null)
-            ? (String[]) fCatalogsList.clone() : null;
-    }
-
-    /**
-     * <p>Sets the initial list of catalog entry files.
-     * If there were any catalog mappings cached from
-     * the previous list they will be replaced by catalog
-     * mappings from the new list the next time the catalog
-     * is queried.</p>
-     *
-     * @param catalogs an ordered array list of absolute URIs
-     */
-    public final synchronized void setCatalogList (String [] catalogs) {
-        fCatalogsChanged = true;
-        fCatalogsList = (catalogs != null)
-            ? (String[]) catalogs.clone() : null;
-    }
-
-    /**
-     * <p>Forces the cache of catalog mappings to be cleared.</p>
-     */
-    public final synchronized void clear () {
-        fCatalog = null;
-    }
-
-    /**
-     * <p>Returns the preference for whether system or public
-     * matches are preferred. This is used in the absence
-     * of any occurence of the <code>prefer</code> attribute
-     * on the <code>catalog</code> entry of a catalog. If this
-     * property has not yet been explicitly set its value is
-     * <code>true</code>.</p>
-     *
-     * @return the prefer public setting
-     */
-    public final boolean getPreferPublic () {
-        return fPreferPublic;
-    }
-
-    /**
-     * <p>Sets the preference for whether system or public
-     * matches are preferred. This is used in the absence
-     * of any occurence of the <code>prefer</code> attribute
-     * on the <code>catalog</code> entry of a catalog.</p>
-     *
-     * @param preferPublic the prefer public setting
-     */
-    public final void setPreferPublic (boolean preferPublic) {
-        fPreferPublic = preferPublic;
-        fResolverCatalogManager.setPreferPublic(preferPublic);
-    }
-
-    /**
-     * <p>Returns the preference for whether the literal system
-     * identifier should be used when resolving system
-     * identifiers when both it and the expanded system
-     * identifier are available. If this property has not yet
-     * been explicitly set its value is <code>true</code>.</p>
-     *
-     * @return the preference for using literal system identifers
-     * for catalog resolution
-     *
-     * @see #setUseLiteralSystemId
-     */
-    public final boolean getUseLiteralSystemId () {
-        return fUseLiteralSystemId;
-    }
-
-    /**
-     * <p>Sets the preference for whether the literal system
-     * identifier should be used when resolving system
-     * identifiers when both it and the expanded system
-     * identifier are available.</p>
-     *
-     * <p>The literal system identifier is the URI as it was
-     * provided before absolutization. It may be embedded within
-     * an entity. It may be provided externally or it may be the
-     * result of redirection. For example, redirection may
-     * have come from the protocol level through HTTP or from
-     * an application's entity resolver.</p>
-     *
-     * <p>The expanded system identifier is an absolute URI
-     * which is the result of resolving the literal system
-     * identifier against a base URI.</p>
-     *
-     * @param useLiteralSystemId the preference for using
-     * literal system identifers for catalog resolution
-     */
-    public final void setUseLiteralSystemId (boolean useLiteralSystemId) {
-        fUseLiteralSystemId = useLiteralSystemId;
-    }
-
-    /**
-     * <p>Resolves an external entity. If the entity cannot be
-     * resolved, this method should return <code>null</code>. This
-     * method returns an input source if an entry was found in the
-     * catalog for the given external identifier. It should be
-     * overrided if other behaviour is required.</p>
-     *
-     * @param publicId the public identifier, or <code>null</code> if none was supplied
-     * @param systemId the system identifier
-     *
-     * @throws SAXException any SAX exception, possibly wrapping another exception
-     * @throws IOException thrown if some i/o error occurs
-     */
-    public InputSource resolveEntity(String publicId, String systemId)
-         throws SAXException, IOException {
-
-        String resolvedId = null;
-        if (publicId != null && systemId != null) {
-            resolvedId = resolvePublic(publicId, systemId);
-        }
-        else if (systemId != null) {
-            resolvedId = resolveSystem(systemId);
-        }
-
-        if (resolvedId != null) {
-            InputSource source = new InputSource(resolvedId);
-            source.setPublicId(publicId);
-            return source;
-        }
-        return null;
-    }
-
-     /**
-      * <p>Resolves an external entity. If the entity cannot be
-      * resolved, this method should return <code>null</code>. This
-      * method returns an input source if an entry was found in the
-      * catalog for the given external identifier. It should be
-      * overrided if other behaviour is required.</p>
-      *
-      * @param name the identifier of the external entity
-      * @param publicId the public identifier, or <code>null</code> if none was supplied
-      * @param baseURI the URI with respect to which relative systemIDs are interpreted.
-      * @param systemId the system identifier
-      *
-      * @throws SAXException any SAX exception, possibly wrapping another exception
-      * @throws IOException thrown if some i/o error occurs
-      */
-     public InputSource resolveEntity(String name, String publicId,
-         String baseURI, String systemId) throws SAXException, IOException {
-
-         String resolvedId = null;
-
-         if (!getUseLiteralSystemId() && baseURI != null) {
-             // Attempt to resolve the system identifier against the base URI.
-             try {
-                 URI uri = new URI(new URI(baseURI), systemId);
-                 systemId = uri.toString();
-             }
-             // Ignore the exception. Fallback to the literal system identifier.
-             catch (URI.MalformedURIException ex) {}
-         }
-
-         if (publicId != null && systemId != null) {
-             resolvedId = resolvePublic(publicId, systemId);
-         }
-         else if (systemId != null) {
-             resolvedId = resolveSystem(systemId);
-         }
-
-         if (resolvedId != null) {
-             InputSource source = new InputSource(resolvedId);
-             source.setPublicId(publicId);
-             return source;
-         }
-         return null;
-    }
-
-     /**
-      * <p>Locates an external subset for documents which do not explicitly
-      * provide one. This method always returns <code>null</code>. It
-      * should be overrided if other behaviour is required.</p>
-      *
-      * @param name the identifier of the document root element
-      * @param baseURI the document's base URI
-      *
-      * @throws SAXException any SAX exception, possibly wrapping another exception
-      * @throws IOException thrown if some i/o error occurs
-      */
-     public InputSource getExternalSubset(String name, String baseURI)
-         throws SAXException, IOException {
-         return null;
-     }
-
-    /**
-     * <p>Resolves a resource using the catalog. This method interprets that
-     * the namespace URI corresponds to uri entries in the catalog.
-     * Where both a namespace and an external identifier exist, the namespace
-     * takes precedence.</p>
-     *
-     * @param type the type of the resource being resolved
-     * @param namespaceURI the namespace of the resource being resolved,
-     * or <code>null</code> if none was supplied
-     * @param publicId the public identifier of the resource being resolved,
-     * or <code>null</code> if none was supplied
-     * @param systemId the system identifier of the resource being resolved,
-     * or <code>null</code> if none was supplied
-     * @param baseURI the absolute base URI of the resource being parsed,
-     * or <code>null</code> if there is no base URI
-     */
-    public LSInput resolveResource(String type, String namespaceURI,
-        String publicId, String systemId, String baseURI) {
-
-        String resolvedId = null;
-
-        try {
-            // The namespace is useful for resolving namespace aware
-            // grammars such as XML schema. Let it take precedence over
-            // the external identifier if one exists.
-            if (namespaceURI != null) {
-                resolvedId = resolveURI(namespaceURI);
-            }
-
-            if (!getUseLiteralSystemId() && baseURI != null) {
-                // Attempt to resolve the system identifier against the base URI.
-                try {
-                    URI uri = new URI(new URI(baseURI), systemId);
-                    systemId = uri.toString();
-                }
-                // Ignore the exception. Fallback to the literal system identifier.
-                catch (URI.MalformedURIException ex) {}
-            }
-
-            // Resolve against an external identifier if one exists. This
-            // is useful for resolving DTD external subsets and other
-            // external entities. For XML schemas if there was no namespace
-            // mapping we might be able to resolve a system identifier
-            // specified as a location hint.
-            if (resolvedId == null) {
-                if (publicId != null && systemId != null) {
-                    resolvedId = resolvePublic(publicId, systemId);
-                }
-                else if (systemId != null) {
-                    resolvedId = resolveSystem(systemId);
-                }
-            }
-        }
-        // Ignore IOException. It cannot be thrown from this method.
-        catch (IOException ex) {}
-
-        if (resolvedId != null) {
-            return new DOMInputImpl(publicId, resolvedId, baseURI);
-        }
-        return null;
-    }
-
-
-    /**
-     * <p>Resolves an external entity. If the entity cannot be
-     * resolved, this method should return <code>null</code>. This
-     * method only calls <code>resolveIdentifier</code> and returns
-     * an input source if an entry was found in the catalog. It
-     * should be overrided if other behaviour is required.</p>
-     *
-     * @param resourceIdentifier location of the XML resource to resolve
-     *
-     * @throws XNIException thrown on general error
-     * @throws IOException thrown if some i/o error occurs
-     */
-    public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
-        throws XNIException, IOException {
-
-        String resolvedId = resolveIdentifier(resourceIdentifier);
-        if (resolvedId != null) {
-            return new XMLInputSource(resourceIdentifier.getPublicId(),
-                    resolvedId, resourceIdentifier.getBaseSystemId(), false);
-        }
-        return null;
-    }
-
-    /**
-     * <p>Resolves an identifier using the catalog. This method interprets that
-     * the namespace of the identifier corresponds to uri entries in the catalog.
-     * Where both a namespace and an external identifier exist, the namespace
-     * takes precedence.</p>
-     *
-     * @param resourceIdentifier the identifier to resolve
-     *
-     * @throws XNIException thrown on general error
-     * @throws IOException thrown if some i/o error occurs
-     */
-    public String resolveIdentifier(XMLResourceIdentifier resourceIdentifier)
-        throws IOException, XNIException {
-
-        String resolvedId = null;
-
-        // The namespace is useful for resolving namespace aware
-        // grammars such as XML schema. Let it take precedence over
-        // the external identifier if one exists.
-        String namespace = resourceIdentifier.getNamespace();
-        if (namespace != null) {
-            resolvedId = resolveURI(namespace);
-        }
-
-        // Resolve against an external identifier if one exists. This
-        // is useful for resolving DTD external subsets and other
-        // external entities. For XML schemas if there was no namespace
-        // mapping we might be able to resolve a system identifier
-        // specified as a location hint.
-        if (resolvedId == null) {
-            String publicId = resourceIdentifier.getPublicId();
-            String systemId = getUseLiteralSystemId()
-                ? resourceIdentifier.getLiteralSystemId()
-                : resourceIdentifier.getExpandedSystemId();
-            if (publicId != null && systemId != null) {
-                resolvedId = resolvePublic(publicId, systemId);
-            }
-            else if (systemId != null) {
-                resolvedId = resolveSystem(systemId);
-            }
-        }
-        return resolvedId;
-    }
-
-    /**
-     * <p>Returns the URI mapping in the catalog for the given
-     * external identifier or <code>null</code> if no mapping
-     * exists. If the system identifier is an URN in the
-     * <code>publicid</code> namespace it is converted into
-     * a public identifier by URN "unwrapping" as specified
-     * in the XML Catalogs specification.</p>
-     *
-     * @param systemId the system identifier to locate in the catalog
-     *
-     * @return the mapped URI or <code>null</code> if no mapping
-     * was found in the catalog
-     *
-     * @throws IOException if an i/o error occurred while reading
-     * the catalog
-     */
-    public final synchronized String resolveSystem (String systemId)
-        throws IOException {
-
-        if (fCatalogsChanged) {
-            parseCatalogs();
-            fCatalogsChanged = false;
-        }
-        return (fCatalog != null)
-            ? fCatalog.resolveSystem(systemId) : null;
-    }
-
-    /**
-     * <p>Returns the URI mapping in the catalog for the given
-     * external identifier or <code>null</code> if no mapping
-     * exists. Public identifiers are normalized before
-     * comparison.</p>
-     *
-     * @param publicId the public identifier to locate in the catalog
-     * @param systemId the system identifier to locate in the catalog
-     *
-     * @return the mapped URI or <code>null</code> if no mapping
-     * was found in the catalog
-     *
-     * @throws IOException if an i/o error occurred while reading
-     * the catalog
-     */
-    public final synchronized String resolvePublic (String publicId, String systemId)
-        throws IOException {
-
-        if (fCatalogsChanged) {
-            parseCatalogs();
-            fCatalogsChanged = false;
-        }
-        return (fCatalog != null)
-            ? fCatalog.resolvePublic(publicId, systemId) : null;
-    }
-
-    /**
-     * <p>Returns the URI mapping in the catalog for the given URI
-     * reference or <code>null</code> if no mapping exists.
-     * URI comparison is case sensitive. If the URI reference
-     * is an URN in the <code>publicid</code> namespace
-     * it is converted into a public identifier by URN "unwrapping"
-     * as specified in the XML Catalogs specification and then
-     * resolution is performed following the semantics of
-     * external identifier resolution.</p>
-     *
-     * @param uri the URI to locate in the catalog
-     *
-     * @return the mapped URI or <code>null</code> if no mapping
-     * was found in the catalog
-     *
-     * @throws IOException if an i/o error occurred while reading
-     * the catalog
-     */
-    public final synchronized String resolveURI (String uri)
-        throws IOException {
-
-        if (fCatalogsChanged) {
-            parseCatalogs();
-            fCatalogsChanged = false;
-        }
-        return (fCatalog != null)
-            ? fCatalog.resolveURI(uri) : null;
-    }
-
-    /**
-     * Initialization. Create a CatalogManager and set all
-     * the properties upfront. This prevents JVM wide system properties
-     * or a property file somewhere in the environment from affecting
-     * the behaviour of this catalog resolver.
-     */
-    private void init (String [] catalogs, boolean preferPublic) {
-        fCatalogsList = (catalogs != null) ? (String[]) catalogs.clone() : null;
-        fPreferPublic = preferPublic;
-        fResolverCatalogManager = new CatalogManager();
-        fResolverCatalogManager.setAllowOasisXMLCatalogPI(false);
-        fResolverCatalogManager.setCatalogClassName("com.sun.org.apache.xml.internal.resolver.Catalog");
-        fResolverCatalogManager.setCatalogFiles("");
-        fResolverCatalogManager.setIgnoreMissingProperties(true);
-        fResolverCatalogManager.setPreferPublic(fPreferPublic);
-        fResolverCatalogManager.setRelativeCatalogs(false);
-        fResolverCatalogManager.setUseStaticCatalog(false);
-        fResolverCatalogManager.setVerbosity(0);
-    }
-
-    /**
-     * Instruct the <code>Catalog</code> to parse each of the
-     * catalogs in the list. Only the first catalog will actually be
-     * parsed immediately. The others will be queued and read if
-     * they are needed later.
-     */
-    private void parseCatalogs () throws IOException {
-        if (fCatalogsList != null) {
-            fCatalog = new Catalog(fResolverCatalogManager);
-            attachReaderToCatalog(fCatalog);
-            for (int i = 0; i < fCatalogsList.length; ++i) {
-                String catalog = fCatalogsList[i];
-                if (catalog != null && catalog.length() > 0) {
-                    fCatalog.parseCatalog(catalog);
-                }
-            }
-        }
-        else {
-            fCatalog = null;
-        }
-    }
-
-    /**
-     * Attaches the reader to the catalog.
-     */
-    private void attachReaderToCatalog (Catalog catalog) {
-
-        SAXParserFactory spf = new SAXParserFactoryImpl();
-        spf.setNamespaceAware(true);
-        spf.setValidating(false);
-
-        SAXCatalogReader saxReader = new SAXCatalogReader(spf);
-        saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, "catalog",
-            "com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader");
-        catalog.addReader("application/xml", saxReader);
-    }
-}
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java	Wed Jun 28 11:27:28 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2258 +0,0 @@
-/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
- */
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xml.internal.resolver;
-
-import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
-import com.sun.org.apache.xml.internal.resolver.helpers.FileURL;
-import com.sun.org.apache.xml.internal.resolver.helpers.PublicId;
-import com.sun.org.apache.xml.internal.resolver.readers.CatalogReader;
-import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader;
-import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader;
-import com.sun.org.apache.xml.internal.resolver.readers.TR9401CatalogReader;
-import java.io.DataInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Vector;
-import javax.xml.parsers.SAXParserFactory;
-
-/**
- * Represents OASIS Open Catalog files.
- *
- * <p>This class implements the semantics of OASIS Open Catalog files
- * (defined by
- * <a href="http://www.oasis-open.org/html/a401.htm">OASIS Technical
- * Resolution 9401:1997 (Amendment 2 to TR 9401)</a>).</p>
- *
- * <p>The primary purpose of the Catalog is to associate resources in the
- * document with local system identifiers. Some entities
- * (document types, XML entities, and notations) have names and all of them
- * can have either public or system identifiers or both. (In XML, only a
- * notation can have a public identifier without a system identifier, but
- * the methods implemented in this class obey the Catalog semantics
- * from the SGML
- * days when system identifiers were optional.)</p>
- *
- * <p>The system identifiers returned by the resolution methods in this
- * class are valid, i.e. usable by, and in fact constructed by, the
- * <tt>java.net.URL</tt> class. Unfortunately, this class seems to behave in
- * somewhat non-standard ways and the system identifiers returned may
- * not be directly usable in a browser or filesystem context.
- *
- * <p>This class recognizes all of the Catalog entries defined in
- * TR9401:1997:</p>
- *
- * <ul>
- * <li><b>BASE</b>
- * changes the base URI for resolving relative system identifiers. The
- * initial base URI is the URI of the location of the catalog (which is,
- * in turn, relative to the location of the current working directory
- * at startup, as returned by the <tt>user.dir</tt> system property).</li>
- * <li><b>CATALOG</b>
- * processes other catalog files. An included catalog occurs logically
- * at the end of the including catalog.</li>
- * <li><b>DELEGATE_PUBLIC</b>
- * specifies alternate catalogs for some public identifiers. The delegated
- * catalogs are not loaded until they are needed, but they are cached
- * once loaded.</li>
- * <li><b>DELEGATE_SYSTEM</b>
- * specifies alternate catalogs for some system identifiers. The delegated
- * catalogs are not loaded until they are needed, but they are cached
- * once loaded.</li>
- * <li><b>DELEGATE_URI</b>
- * specifies alternate catalogs for some URIs. The delegated
- * catalogs are not loaded until they are needed, but they are cached
- * once loaded.</li>
- * <li><b>REWRITE_SYSTEM</b>
- * specifies alternate prefix for a system identifier.</li>
- * <li><b>REWRITE_URI</b>
- * specifies alternate prefix for a URI.</li>
- * <li><b>SYSTEM_SUFFIX</b>
- * maps any system identifier that ends with a particular suffix to another
- * system identifier.</li>
- * <li><b>URI_SUFFIX</b>
- * maps any URI that ends with a particular suffix to another URI.</li>
- * <li><b>DOCTYPE</b>
- * associates the names of root elements with URIs. (In other words, an XML
- * processor might infer the doctype of an XML document that does not include
- * a doctype declaration by looking for the DOCTYPE entry in the
- * catalog which matches the name of the root element of the document.)</li>
- * <li><b>DOCUMENT</b>
- * provides a default document.</li>
- * <li><b>DTDDECL</b>
- * recognized and silently ignored. Not relevant for XML.</li>
- * <li><b>ENTITY</b>
- * associates entity names with URIs.</li>
- * <li><b>LINKTYPE</b>
- * recognized and silently ignored. Not relevant for XML.</li>
- * <li><b>NOTATION</b>
- * associates notation names with URIs.</li>
- * <li><b>OVERRIDE</b>
- * changes the override behavior. Initial behavior is set by the
- * system property <tt>xml.catalog.override</tt>. The default initial
- * behavior is 'YES', that is, entries in the catalog override
- * system identifiers specified in the document.</li>
- * <li><b>PUBLIC</b>
- * maps a public identifier to a system identifier.</li>
- * <li><b>SGMLDECL</b>
- * recognized and silently ignored. Not relevant for XML.</li>
- * <li><b>SYSTEM</b>
- * maps a system identifier to another system identifier.</li>
- * <li><b>URI</b>
- * maps a URI to another URI.</li>
- * </ul>
- *
- * <p>Note that BASE entries are treated as described by RFC2396. In
- * particular, this has the counter-intuitive property that after a BASE
- * entry identifing "http://example.com/a/b/c" as the base URI,
- * the relative URI "foo" is resolved to the absolute URI
- * "http://example.com/a/b/foo". You must provide the trailing slash if
- * you do not want the final component of the path to be discarded as a
- * filename would in a URI for a resource: "http://example.com/a/b/c/".
- * </p>
- *
- * <p>Note that subordinate catalogs (all catalogs except the first,
- * including CATALOG and DELEGATE* catalogs) are only loaded if and when
- * they are required.</p>
- *
- * <p>This class relies on classes which implement the CatalogReader
- * interface to actually load catalog files. This allows the catalog
- * semantics to be implemented for TR9401 text-based catalogs, XML
- * catalogs, or any number of other storage formats.</p>
- *
- * <p>Additional catalogs may also be loaded with the
- * {@link #parseCatalog} method.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>2.0</dt>
- * <dd><p>Rewrite to use CatalogReaders.</p></dd>
- * <dt>1.1</dt>
- * <dd><p>Allow quoted components in <tt>xml.catalog.files</tt>
- * so that URLs containing colons can be used on Unix.
- * The string passed to <tt>xml.catalog.files</tt> can now have the form:</p>
- * <pre>
- * unquoted-path-with-no-sep-chars:"double-quoted path with or without sep chars":'single-quoted path with or without sep chars'
- * </pre>
- * <p>(Where ":" is the separater character in this example.)</p>
- * <p>If an unquoted path contains an embedded double or single quote
- * character, no special processig is performed on that character. No
- * path can contain separater characters, double, and single quotes
- * simultaneously.</p>
- * <p>Fix bug in calculation of BASE entries: if
- * a catalog contains multiple BASE entries, each is relative to the preceding
- * base, not the default base URI of the catalog.</p>
- * </dd>
- * <dt>1.0.1</dt>
- * <dd><p>Fixed a bug in the calculation of the list of subordinate catalogs.
- * This bug caused an infinite loop where parsing would alternately process
- * two catalogs indefinitely.</p>
- * </dd>
- * </dl>
- *
- * @see CatalogReader
- * @see CatalogEntry
- * @deprecated The JDK internal Catalog API in package
- * {@code com.sun.org.apache.xml.internal.resolver}
- * is encapsulated in JDK 9. The entire implementation under the package is now
- * deprecated and subject to removal in a future release. Users of the API
- * should migrate to the {@linkplain javax.xml.catalog new public API}.
- * <p>
- * The new Catalog API is supported throughout the JDK XML Processors, which allows
- * the use of Catalog by simply setting a path to a Catalog file as a property.
- *
- * @author Norman Walsh
- * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
- *
- * @version 1.0
- *
- * <p>Derived from public domain code originally published by Arbortext,
- * Inc.</p>
- */
-@Deprecated(since="9", forRemoval=true)
-public class Catalog {
-  /** The BASE Catalog Entry type. */
-  public static final int BASE     = CatalogEntry.addEntryType("BASE", 1);
-
-  /** The CATALOG Catalog Entry type. */
-  public static final int CATALOG  = CatalogEntry.addEntryType("CATALOG", 1);
-
-  /** The DOCUMENT Catalog Entry type. */
-  public static final int DOCUMENT = CatalogEntry.addEntryType("DOCUMENT", 1);
-
-  /** The OVERRIDE Catalog Entry type. */
-  public static final int OVERRIDE = CatalogEntry.addEntryType("OVERRIDE", 1);
-
-  /** The SGMLDECL Catalog Entry type. */
-  public static final int SGMLDECL = CatalogEntry.addEntryType("SGMLDECL", 1);
-
-  /** The DELEGATE_PUBLIC Catalog Entry type. */
-  public static final int DELEGATE_PUBLIC = CatalogEntry.addEntryType("DELEGATE_PUBLIC", 2);
-
-  /** The DELEGATE_SYSTEM Catalog Entry type. */
-  public static final int DELEGATE_SYSTEM = CatalogEntry.addEntryType("DELEGATE_SYSTEM", 2);
-
-  /** The DELEGATE_URI Catalog Entry type. */
-  public static final int DELEGATE_URI = CatalogEntry.addEntryType("DELEGATE_URI", 2);
-
-  /** The DOCTYPE Catalog Entry type. */
-  public static final int DOCTYPE  = CatalogEntry.addEntryType("DOCTYPE", 2);
-
-  /** The DTDDECL Catalog Entry type. */
-  public static final int DTDDECL  = CatalogEntry.addEntryType("DTDDECL", 2);
-
-  /** The ENTITY Catalog Entry type. */
-  public static final int ENTITY   = CatalogEntry.addEntryType("ENTITY", 2);
-
-  /** The LINKTYPE Catalog Entry type. */
-  public static final int LINKTYPE = CatalogEntry.addEntryType("LINKTYPE", 2);
-
-  /** The NOTATION Catalog Entry type. */
-  public static final int NOTATION = CatalogEntry.addEntryType("NOTATION", 2);
-
-  /** The PUBLIC Catalog Entry type. */
-  public static final int PUBLIC   = CatalogEntry.addEntryType("PUBLIC", 2);
-
-  /** The SYSTEM Catalog Entry type. */
-  public static final int SYSTEM   = CatalogEntry.addEntryType("SYSTEM", 2);
-
-  /** The URI Catalog Entry type. */
-  public static final int URI      = CatalogEntry.addEntryType("URI", 2);
-
-  /** The REWRITE_SYSTEM Catalog Entry type. */
-  public static final int REWRITE_SYSTEM = CatalogEntry.addEntryType("REWRITE_SYSTEM", 2);
-
-  /** The REWRITE_URI Catalog Entry type. */
-  public static final int REWRITE_URI = CatalogEntry.addEntryType("REWRITE_URI", 2);
-  /** The SYSTEM_SUFFIX Catalog Entry type. */
-  public static final int SYSTEM_SUFFIX = CatalogEntry.addEntryType("SYSTEM_SUFFIX", 2);
-  /** The URI_SUFFIX Catalog Entry type. */
-  public static final int URI_SUFFIX = CatalogEntry.addEntryType("URI_SUFFIX", 2);
-
-  /**
-   * The base URI for relative system identifiers in the catalog.
-   * This may be changed by BASE entries in the catalog.
-   */
-  protected URL base;
-
-  /** The base URI of the Catalog file currently being parsed. */
-  protected URL catalogCwd;
-
-  /** The catalog entries currently known to the system. */
-  protected Vector catalogEntries = new Vector();
-
-  /** The default initial override setting. */
-  protected boolean default_override = true;
-
-  /** The catalog manager in use for this instance. */
-  protected CatalogManager catalogManager = CatalogManager.getStaticManager();
-
-  /**
-   * A vector of catalog files to be loaded.
-   *
-   * <p>This list is initially established by
-   * <code>loadSystemCatalogs</code> when
-   * it parses the system catalog list, but CATALOG entries may
-   * contribute to it during the course of parsing.</p>
-   *
-   * @see #loadSystemCatalogs
-   * @see #localCatalogFiles
-   */
-  protected Vector catalogFiles = new Vector();
-
-  /**
-   * A vector of catalog files constructed during processing of
-   * CATALOG entries in the current catalog.
-   *
-   * <p>This two-level system is actually necessary to correctly implement
-   * the semantics of the CATALOG entry. If one catalog file includes
-   * another with a CATALOG entry, the included catalog logically
-   * occurs <i>at the end</i> of the including catalog, and after any
-   * preceding CATALOG entries. In other words, the CATALOG entry
-   * cannot insert anything into the middle of a catalog file.</p>
-   *
-   * <p>When processing reaches the end of each catalog files, any
-   * elements on this vector are added to the front of the
-   * <code>catalogFiles</code> vector.</p>
-   *
-   * @see #catalogFiles
-   */
-  protected Vector localCatalogFiles = new Vector();
-
-  /**
-   * A vector of Catalogs.
-   *
-   * <p>The semantics of Catalog resolution are such that each
-   * catalog is effectively a list of Catalogs (in other words,
-   * a recursive list of Catalog instances).</p>
-   *
-   * <p>Catalogs that are processed as the result of CATALOG or
-   * DELEGATE* entries are subordinate to the catalog that contained
-   * them, but they may in turn have subordinate catalogs.</p>
-   *
-   * <p>Catalogs are only loaded when they are needed, so this vector
-   * initially contains a list of Catalog filenames (URLs). If, during
-   * processing, one of these catalogs has to be loaded, the resulting
-   * Catalog object is placed in the vector, effectively caching it
-   * for the next query.</p>
-   */
-  protected Vector catalogs = new Vector();
-
-  /**
-   * A vector of DELEGATE* Catalog entries constructed during
-   * processing of the Catalog.
-   *
-   * <p>This two-level system has two purposes; first, it allows
-   * us to sort the DELEGATE* entries by the length of the partial
-   * public identifier so that a linear search encounters them in
-   * the correct order and second, it puts them all at the end of
-   * the Catalog.</p>
-   *
-   * <p>When processing reaches the end of each catalog file, any
-   * elements on this vector are added to the end of the
-   * <code>catalogEntries</code> vector. This assures that matching
-   * PUBLIC keywords are encountered before DELEGATE* entries.</p>
-   */
-  protected Vector localDelegate = new Vector();
-
-  /**
-   * A hash of CatalogReaders.
-   *
-   * <p>This hash maps MIME types to elements in the readerArr
-   * vector. This allows the Catalog to quickly locate the reader
-   * for a particular MIME type.</p>
-   */
-  protected Map<String, Integer> readerMap = new HashMap<>();
-
-  /**
-   * A vector of CatalogReaders.
-   *
-   * <p>This vector contains all of the readers in the order that they
-   * were added. In the event that a catalog is read from a file, where
-   * the MIME type is unknown, each reader is attempted in turn until
-   * one succeeds.</p>
-   */
-  protected Vector readerArr = new Vector();
-
-  /**
-   * Constructs an empty Catalog.
-   *
-   * <p>The constructor interrogates the relevant system properties
-   * using the default (static) CatalogManager
-   * and initializes the catalog data structures.</p>
-   */
-  public Catalog() {
-    // nop;
-  }
-
-  /**
-   * Constructs an empty Catalog with a specific CatalogManager.
-   *
-   * <p>The constructor interrogates the relevant system properties
-   * using the specified Catalog Manager
-   * and initializes the catalog data structures.</p>
-   */
-  public Catalog(CatalogManager manager) {
-    catalogManager = manager;
-  }
-
-  /**
-   * Return the CatalogManager used by this catalog.
-   *
-   */
-  public CatalogManager getCatalogManager() {
-    return catalogManager;
-  }
-
-  /**
-   * Establish the CatalogManager used by this catalog.
-   *
-   */
-  public void setCatalogManager(CatalogManager manager) {
-    catalogManager = manager;
-  }
-
-  /**
-   * Setup readers.
-   */
-  public void setupReaders() {
-    SAXParserFactory spf = catalogManager.useServicesMechanism() ?
-                    SAXParserFactory.newInstance() : new SAXParserFactoryImpl();
-    spf.setNamespaceAware(true);
-    spf.setValidating(false);
-
-    SAXCatalogReader saxReader = new SAXCatalogReader(spf);
-
-    saxReader.setCatalogParser(null, "XMLCatalog",
-                               "com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader");
-
-    saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName,
-                               "catalog",
-                               "com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader");
-
-    addReader("application/xml", saxReader);
-
-    TR9401CatalogReader textReader = new TR9401CatalogReader();
-    addReader("text/plain", textReader);
-  }
-
-  /**
-   * Add a new CatalogReader to the Catalog.
-   *
-   * <p>This method allows you to add a new CatalogReader to the
-   * catalog. The reader will be associated with the specified mimeType.
-   * You can only have one reader per mimeType.</p>
-   *
-   * <p>In the absence of a mimeType (e.g., when reading a catalog
-   * directly from a file on the local system), the readers are attempted
-   * in the order that you add them to the Catalog.</p>
-   *
-   * <p>Note that subordinate catalogs (created by CATALOG or
-   * DELEGATE* entries) get a copy of the set of readers present in
-   * the primary catalog when they are created. Readers added subsequently
-   * will not be available. For this reason, it is best to add all
-   * of the readers before the first call to parse a catalog.</p>
-   *
-   * @param mimeType The MIME type associated with this reader.
-   * @param reader The CatalogReader to use.
-   */
-  public void addReader(String mimeType, CatalogReader reader) {
-    if (readerMap.containsKey(mimeType)) {
-      Integer pos = readerMap.get(mimeType);
-      readerArr.set(pos, reader);
-    } else {
-      readerArr.add(reader);
-      Integer pos = readerArr.size()-1;
-      readerMap.put(mimeType, pos);
-    }
-  }
-
-  /**
-   * Copies the reader list from the current Catalog to a new Catalog.
-   *
-   * <p>This method is used internally when constructing a new catalog.
-   * It copies the current reader associations over to the new catalog.
-   * </p>
-   *
-   * @param newCatalog The new Catalog.
-   */
-  protected void copyReaders(Catalog newCatalog) {
-    // Have to copy the readers in the right order...convert hash to arr
-    Vector mapArr = new Vector(readerMap.size());
-
-    // Pad the mapArr out to the right length
-    for (int count = 0; count < readerMap.size(); count++) {
-      mapArr.add(null);
-    }
-
-    for (Map.Entry<String, Integer> entry : readerMap.entrySet()) {
-        mapArr.set(entry.getValue().intValue(), entry.getKey());
-    }
-
-    for (int count = 0; count < mapArr.size(); count++) {
-      String mimeType = (String) mapArr.get(count);
-      Integer pos = readerMap.get(mimeType);
-      newCatalog.addReader(mimeType,
-                           (CatalogReader)
-                           readerArr.get(pos.intValue()));
-    }
-  }
-
-  /**
-   * Create a new Catalog object.
-   *
-   * <p>This method constructs a new instance of the running Catalog
-   * class (which might be a subtype of com.sun.org.apache.xml.internal.resolver.Catalog).
-   * All new catalogs are managed by the same CatalogManager.
-   * </p>
-   *
-   * <p>N.B. All Catalog subtypes should call newCatalog() to construct
-   * a new Catalog. Do not simply use "new Subclass()" since that will
-   * confuse future subclasses.</p>
-   */
-  protected Catalog newCatalog() {
-    String catalogClass = this.getClass().getName();
-
-    try {
-      Catalog c = (Catalog) (Class.forName(catalogClass).newInstance());
-      c.setCatalogManager(catalogManager);
-      copyReaders(c);
-      return c;
-    } catch (ClassNotFoundException cnfe) {
-      catalogManager.debug.message(1, "Class Not Found Exception: " + catalogClass);
-    } catch (IllegalAccessException iae) {
-      catalogManager.debug.message(1, "Illegal Access Exception: " + catalogClass);
-    } catch (InstantiationException ie) {
-      catalogManager.debug.message(1, "Instantiation Exception: " + catalogClass);
-    } catch (ClassCastException cce) {
-      catalogManager.debug.message(1, "Class Cast Exception: " + catalogClass);
-    } catch (Exception e) {
-      catalogManager.debug.message(1, "Other Exception: " + catalogClass);
-    }
-
-    Catalog c = new Catalog();
-    c.setCatalogManager(catalogManager);
-    copyReaders(c);
-    return c;
-  }
-
-  /**
-   * Returns the current base URI.
-   */
-  public String getCurrentBase() {
-    return base.toString();
-  }
-
-  /**
-   * Returns the default override setting associated with this
-   * catalog.
-   *
-   * <p>All catalog files loaded by this catalog will have the
-   * initial override setting specified by this default.</p>
-   */
-  public String getDefaultOverride() {
-    if (default_override) {
-      return "yes";
-    } else {
-      return "no";
-    }
-  }
-
-  /**
-   * Load the system catalog files.
-   *
-   * <p>The method adds all of the
-   * catalogs specified in the <tt>xml.catalog.files</tt> property
-   * to the Catalog list.</p>
-   *
-   * @throws MalformedURLException  One of the system catalogs is
-   * identified with a filename that is not a valid URL.
-   * @throws IOException One of the system catalogs cannot be read.
-   */
-  public void loadSystemCatalogs()
-    throws MalformedURLException, IOException {
-
-    Vector catalogs = catalogManager.getCatalogFiles();
-    if (catalogs != null) {
-      for (int count = 0; count < catalogs.size(); count++) {
-        catalogFiles.addElement(catalogs.elementAt(count));
-      }
-    }
-
-    if (catalogFiles.size() > 0) {
-      // This is a little odd. The parseCatalog() method expects
-      // a filename, but it adds that name to the end of the
-      // catalogFiles vector, and then processes that vector.
-      // This allows the system to handle CATALOG entries
-      // correctly.
-      //
-      // In this init case, we take the last element off the
-      // catalogFiles vector and pass it to parseCatalog. This
-      // will "do the right thing" in the init case, and allow
-      // parseCatalog() to do the right thing in the non-init
-      // case. Honest.
-      //
-      String catfile = (String) catalogFiles.lastElement();
-      catalogFiles.removeElement(catfile);
-      parseCatalog(catfile);
-    }
-  }
-
-  /**
-   * Parse a catalog file, augmenting internal data structures.
-   *
-   * @param fileName The filename of the catalog file to process
-   *
-   * @throws MalformedURLException The fileName cannot be turned into
-   * a valid URL.
-   * @throws IOException Error reading catalog file.
-   */
-  public synchronized void parseCatalog(String fileName)
-    throws MalformedURLException, IOException {
-
-    default_override = catalogManager.getPreferPublic();
-    catalogManager.debug.message(4, "Parse catalog: " + fileName);
-
-    // Put the file into the list of catalogs to process...
-    // In all cases except the case when initCatalog() is the
-    // caller, this will be the only catalog initially in the list...
-    catalogFiles.addElement(fileName);
-
-    // Now process all the pending catalogs...
-    parsePendingCatalogs();
-  }
-
-  /**
-   * Parse a catalog file, augmenting internal data structures.
-   *
-   * <p>Catalogs retrieved over the net may have an associated MIME type.
-   * The MIME type can be used to select an appropriate reader.</p>
-   *
-   * @param mimeType The MIME type of the catalog file.
-   * @param is The InputStream from which the catalog should be read
-   *
-   * @throws CatalogException Failed to load catalog
-   * mimeType.
-   * @throws IOException Error reading catalog file.
-   */
-  public synchronized void parseCatalog(String mimeType, InputStream is)
-    throws IOException, CatalogException {
-
-    default_override = catalogManager.getPreferPublic();
-    catalogManager.debug.message(4, "Parse " + mimeType + " catalog on input stream");
-
-    CatalogReader reader = null;
-
-    if (readerMap.containsKey(mimeType)) {
-      int arrayPos = ((Integer) readerMap.get(mimeType)).intValue();
-      reader = (CatalogReader) readerArr.get(arrayPos);
-    }
-
-    if (reader == null) {
-      String msg = "No CatalogReader for MIME type: " + mimeType;
-      catalogManager.debug.message(2, msg);
-      throw new CatalogException(CatalogException.UNPARSEABLE, msg);
-    }
-
-    reader.readCatalog(this, is);
-
-    // Now process all the pending catalogs...
-    parsePendingCatalogs();
-  }
-
-  /**
-   * Parse a catalog document, augmenting internal data structures.
-   *
-   * <p>This method supports catalog files stored in jar files: e.g.,
-   * jar:file:///path/to/filename.jar!/path/to/catalog.xml". That URI
-   * doesn't survive transmogrification through the URI processing that
-   * the parseCatalog(String) performs and passing it as an input stream
-   * doesn't set the base URI appropriately.</p>
-   *
-   * <p>Written by Stefan Wachter (2002-09-26)</p>
-   *
-   * @param aUrl The URL of the catalog document to process
-   *
-   * @throws IOException Error reading catalog file.
-   */
-  public synchronized void parseCatalog(URL aUrl) throws IOException {
-    catalogCwd = aUrl;
-    base = aUrl;
-
-    default_override = catalogManager.getPreferPublic();
-    catalogManager.debug.message(4, "Parse catalog: " + aUrl.toString());
-
-    DataInputStream inStream = null;
-    boolean parsed = false;
-
-    for (int count = 0; !parsed && count < readerArr.size(); count++) {
-      CatalogReader reader = (CatalogReader) readerArr.get(count);
-
-      try {
-        inStream = new DataInputStream(aUrl.openStream());
-      } catch (FileNotFoundException fnfe) {
-        // No catalog; give up!
-        break;
-      }
-
-      try {
-        reader.readCatalog(this, inStream);
-        parsed=true;
-      } catch (CatalogException ce) {
-        if (ce.getExceptionType() == CatalogException.PARSE_FAILED) {
-          // give up!
-          break;
-        } else {
-          // try again!
-        }
-      }
-
-      try {
-        inStream.close();
-      } catch (IOException e) {
-        //nop
-      }
-    }
-
-    if (parsed) parsePendingCatalogs();
-  }
-
-  /**
-   * Parse all of the pending catalogs.
-   *
-   * <p>Catalogs may refer to other catalogs, this method parses
-   * all of the currently pending catalog files.</p>
-   */
-  protected synchronized void parsePendingCatalogs()
-    throws MalformedURLException, IOException {
-
-    if (!localCatalogFiles.isEmpty()) {
-      // Move all the localCatalogFiles into the front of
-      // the catalogFiles queue
-      Vector newQueue = new Vector();
-      Enumeration q = localCatalogFiles.elements();
-      while (q.hasMoreElements()) {
-        newQueue.addElement(q.nextElement());
-      }
-
-      // Put the rest of the catalogs on the end of the new list
-      for (int curCat = 0; curCat < catalogFiles.size(); curCat++) {
-        String catfile = (String) catalogFiles.elementAt(curCat);
-        newQueue.addElement(catfile);
-      }
-
-      catalogFiles = newQueue;
-      localCatalogFiles.clear();
-    }
-
-    // Suppose there are no catalog files to process, but the
-    // single catalog already parsed included some delegate
-    // entries? Make sure they don't get lost.
-    if (catalogFiles.isEmpty() && !localDelegate.isEmpty()) {
-      Enumeration e = localDelegate.elements();
-      while (e.hasMoreElements()) {
-        catalogEntries.addElement(e.nextElement());
-      }
-      localDelegate.clear();
-    }
-
-    // Now process all the files on the catalogFiles vector. This
-    // vector can grow during processing if CATALOG entries are
-    // encountered in the catalog
-    while (!catalogFiles.isEmpty()) {
-      String catfile = (String) catalogFiles.elementAt(0);
-      try {
-        catalogFiles.remove(0);
-      } catch (ArrayIndexOutOfBoundsException e) {
-        // can't happen
-      }
-
-      if (catalogEntries.size() == 0 && catalogs.size() == 0) {
-        // We haven't parsed any catalogs yet, let this
-        // catalog be the first...
-        try {
-          parseCatalogFile(catfile);
-        } catch (CatalogException ce) {
-          System.out.println("FIXME: " + ce.toString());
-        }
-      } else {
-        // This is a subordinate catalog. We save its name,
-        // but don't bother to load it unless it's necessary.
-        catalogs.addElement(catfile);
-      }
-
-      if (!localCatalogFiles.isEmpty()) {
-        // Move all the localCatalogFiles into the front of
-        // the catalogFiles queue
-        Vector newQueue = new Vector();
-        Enumeration q = localCatalogFiles.elements();
-        while (q.hasMoreElements()) {
-          newQueue.addElement(q.nextElement());
-        }
-
-        // Put the rest of the catalogs on the end of the new list
-        for (int curCat = 0; curCat < catalogFiles.size(); curCat++) {
-          catfile = (String) catalogFiles.elementAt(curCat);
-          newQueue.addElement(catfile);
-        }
-
-        catalogFiles = newQueue;
-        localCatalogFiles.clear();
-      }
-
-      if (!localDelegate.isEmpty()) {
-        Enumeration e = localDelegate.elements();
-        while (e.hasMoreElements()) {
-          catalogEntries.addElement(e.nextElement());
-        }
-        localDelegate.clear();
-      }
-    }
-
-    // We've parsed them all, reinit the vector...
-    catalogFiles.clear();
-  }
-
-  /**
-   * Parse a single catalog file, augmenting internal data structures.
-   *
-   * @param fileName The filename of the catalog file to process
-   *
-   * @throws MalformedURLException The fileName cannot be turned into
-   * a valid URL.
-   * @throws IOException Error reading catalog file.
-   */
-  protected synchronized void parseCatalogFile(String fileName)
-    throws MalformedURLException, IOException, CatalogException {
-
-    CatalogEntry entry;
-
-    // The base-base is the cwd. If the catalog file is specified
-    // with a relative path, this assures that it gets resolved
-    // properly...
-    try {
-      // tack on a basename because URLs point to files not dirs
-      catalogCwd = FileURL.makeURL("basename");
-    } catch (MalformedURLException e) {
-      catalogManager.debug.message(1, "Malformed URL on cwd", "user.dir");
-      catalogCwd = null;
-    }
-
-    // The initial base URI is the location of the catalog file
-    try {
-      base = new URL(catalogCwd, fixSlashes(fileName));
-    } catch (MalformedURLException e) {
-      try {
-        base = new URL("file:" + fixSlashes(fileName));
-      } catch (MalformedURLException e2) {
-        catalogManager.debug.message(1, "Malformed URL on catalog filename",
-                      fixSlashes(fileName));
-        base = null;
-      }
-    }
-
-    catalogManager.debug.message(2, "Loading catalog", fileName);
-    catalogManager.debug.message(4, "Default BASE", base.toString());
-
-    fileName = base.toString();
-
-    DataInputStream inStream = null;
-    boolean parsed = false;
-    boolean notFound = false;
-
-    for (int count = 0; !parsed && count < readerArr.size(); count++) {
-      CatalogReader reader = (CatalogReader) readerArr.get(count);
-
-      try {
-        notFound = false;
-        inStream = new DataInputStream(base.openStream());
-      } catch (FileNotFoundException fnfe) {
-        // No catalog; give up!
-        notFound = true;
-        break;
-      }
-
-      try {
-        reader.readCatalog(this, inStream);
-        parsed = true;
-      } catch (CatalogException ce) {
-        if (ce.getExceptionType() == CatalogException.PARSE_FAILED) {
-          // give up!
-          break;
-        } else {
-          // try again!
-        }
-      }
-
-      try {
-        inStream.close();
-      } catch (IOException e) {
-        //nop
-      }
-    }
-
-    if (!parsed) {
-      if (notFound) {
-        catalogManager.debug.message(3, "Catalog does not exist", fileName);
-      } else {
-        catalogManager.debug.message(1, "Failed to parse catalog", fileName);
-      }
-    }
-  }
-
-  /**
-   * Cleanup and process a Catalog entry.
-   *
-   * <p>This method processes each Catalog entry, changing mapped
-   * relative system identifiers into absolute ones (based on the current
-   * base URI), and maintaining other information about the current
-   * catalog.</p>
-   *
-   * @param entry The CatalogEntry to process.
-   */
-  public void addEntry(CatalogEntry entry) {
-    int type = entry.getEntryType();
-
-    if (type == BASE) {
-      String value = entry.getEntryArg(0);
-      URL newbase = null;
-
-      if (base == null) {
-        catalogManager.debug.message(5, "BASE CUR", "null");
-      } else {
-        catalogManager.debug.message(5, "BASE CUR", base.toString());
-      }
-      catalogManager.debug.message(4, "BASE STR", value);
-
-      try {
-        value = fixSlashes(value);
-        newbase = new URL(base, value);
-      } catch (MalformedURLException e) {
-        try {
-          newbase = new URL("file:" + value);
-        } catch (MalformedURLException e2) {
-          catalogManager.debug.message(1, "Malformed URL on base", value);
-          newbase = null;
-        }
-      }
-
-      if (newbase != null) {
-        base = newbase;
-      }
-
-      catalogManager.debug.message(5, "BASE NEW", base.toString());
-    } else if (type == CATALOG) {
-      String fsi = makeAbsolute(entry.getEntryArg(0));
-
-      catalogManager.debug.message(4, "CATALOG", fsi);
-
-      localCatalogFiles.addElement(fsi);
-    } else if (type == PUBLIC) {
-      String publicid = PublicId.normalize(entry.getEntryArg(0));
-      String systemid = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(0, publicid);
-      entry.setEntryArg(1, systemid);
-
-      catalogManager.debug.message(4, "PUBLIC", publicid, systemid);
-
-      catalogEntries.addElement(entry);
-    } else if (type == SYSTEM) {
-      String systemid = normalizeURI(entry.getEntryArg(0));
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "SYSTEM", systemid, fsi);
-
-      catalogEntries.addElement(entry);
-    } else if (type == URI) {
-      String uri = normalizeURI(entry.getEntryArg(0));
-      String altURI = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(1, altURI);
-
-      catalogManager.debug.message(4, "URI", uri, altURI);
-
-      catalogEntries.addElement(entry);
-    } else if (type == DOCUMENT) {
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(0)));
-      entry.setEntryArg(0, fsi);
-
-      catalogManager.debug.message(4, "DOCUMENT", fsi);
-
-      catalogEntries.addElement(entry);
-    } else if (type == OVERRIDE) {
-      catalogManager.debug.message(4, "OVERRIDE", entry.getEntryArg(0));
-
-      catalogEntries.addElement(entry);
-    } else if (type == SGMLDECL) {
-      // meaningless in XML
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(0)));
-      entry.setEntryArg(0, fsi);
-
-      catalogManager.debug.message(4, "SGMLDECL", fsi);
-
-      catalogEntries.addElement(entry);
-    } else if (type == DELEGATE_PUBLIC) {
-      String ppi = PublicId.normalize(entry.getEntryArg(0));
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(0, ppi);
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "DELEGATE_PUBLIC", ppi, fsi);
-
-      addDelegate(entry);
-    } else if (type == DELEGATE_SYSTEM) {
-      String psi = normalizeURI(entry.getEntryArg(0));
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(0, psi);
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "DELEGATE_SYSTEM", psi, fsi);
-
-      addDelegate(entry);
-    } else if (type == DELEGATE_URI) {
-      String pui = normalizeURI(entry.getEntryArg(0));
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(0, pui);
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "DELEGATE_URI", pui, fsi);
-
-      addDelegate(entry);
-    } else if (type == REWRITE_SYSTEM) {
-      String psi = normalizeURI(entry.getEntryArg(0));
-      String rpx = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(0, psi);
-      entry.setEntryArg(1, rpx);
-
-      catalogManager.debug.message(4, "REWRITE_SYSTEM", psi, rpx);
-
-      catalogEntries.addElement(entry);
-    } else if (type == REWRITE_URI) {
-      String pui = normalizeURI(entry.getEntryArg(0));
-      String upx = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(0, pui);
-      entry.setEntryArg(1, upx);
-
-      catalogManager.debug.message(4, "REWRITE_URI", pui, upx);
-
-      catalogEntries.addElement(entry);
-    } else if (type == SYSTEM_SUFFIX) {
-      String pui = normalizeURI(entry.getEntryArg(0));
-      String upx = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(0, pui);
-      entry.setEntryArg(1, upx);
-
-      catalogManager.debug.message(4, "SYSTEM_SUFFIX", pui, upx);
-
-      catalogEntries.addElement(entry);
-    } else if (type == URI_SUFFIX) {
-      String pui = normalizeURI(entry.getEntryArg(0));
-      String upx = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(0, pui);
-      entry.setEntryArg(1, upx);
-
-      catalogManager.debug.message(4, "URI_SUFFIX", pui, upx);
-
-      catalogEntries.addElement(entry);
-    } else if (type == DOCTYPE) {
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "DOCTYPE", entry.getEntryArg(0), fsi);
-
-      catalogEntries.addElement(entry);
-    } else if (type == DTDDECL) {
-      // meaningless in XML
-      String fpi = PublicId.normalize(entry.getEntryArg(0));
-      entry.setEntryArg(0, fpi);
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "DTDDECL", fpi, fsi);
-
-      catalogEntries.addElement(entry);
-    } else if (type == ENTITY) {
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "ENTITY", entry.getEntryArg(0), fsi);
-
-      catalogEntries.addElement(entry);
-    } else if (type == LINKTYPE) {
-      // meaningless in XML
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "LINKTYPE", entry.getEntryArg(0), fsi);
-
-      catalogEntries.addElement(entry);
-    } else if (type == NOTATION) {
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "NOTATION", entry.getEntryArg(0), fsi);
-
-      catalogEntries.addElement(entry);
-    } else {
-      catalogEntries.addElement(entry);
-    }
-  }
-
-  /**
-   * Handle unknown CatalogEntry types.
-   *
-   * <p>This method exists to allow subclasses to deal with unknown
-   * entry types.</p>
-   */
-  public void unknownEntry(Vector strings) {
-    if (strings != null && strings.size() > 0) {
-      String keyword = (String) strings.elementAt(0);
-      catalogManager.debug.message(2, "Unrecognized token parsing catalog", keyword);
-    }
-  }
-
-  /**
-   * Parse all subordinate catalogs.
-   *
-   * <p>This method recursively parses all of the subordinate catalogs.
-   * If this method does not throw an exception, you can be confident that
-   * no subsequent call to any resolve*() method will either, with two
-   * possible exceptions:</p>
-   *
-   * <ol>
-   * <li><p>Delegated catalogs are re-parsed each time they are needed
-   * (because a variable list of them may be needed in each case,
-   * depending on the length of the matching partial public identifier).</p>
-   * <p>But they are parsed by this method, so as long as they don't
-   * change or disappear while the program is running, they shouldn't
-   * generate errors later if they don't generate errors now.</p>
-   * <li><p>If you add new catalogs with <code>parseCatalog</code>, they
-   * won't be loaded until they are needed or until you call
-   * <code>parseAllCatalogs</code> again.</p>
-   * </ol>
-   *
-   * <p>On the other hand, if you don't call this method, you may
-   * successfully parse documents without having to load all possible
-   * catalogs.</p>
-   *
-   * @throws MalformedURLException The filename (URL) for a
-   * subordinate or delegated catalog is not a valid URL.
-   * @throws IOException Error reading some subordinate or delegated
-   * catalog file.
-   */
-  public void parseAllCatalogs()
-    throws MalformedURLException, IOException {
-
-    // Parse all the subordinate catalogs
-    for (int catPos = 0; catPos < catalogs.size(); catPos++) {
-      Catalog c = null;
-
-      try {
-        c = (Catalog) catalogs.elementAt(catPos);
-      } catch (ClassCastException e) {
-        String catfile = (String) catalogs.elementAt(catPos);
-        c = newCatalog();
-
-        c.parseCatalog(catfile);
-        catalogs.setElementAt(c, catPos);
-        c.parseAllCatalogs();
-      }
-    }
-
-    // Parse all the DELEGATE catalogs
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == DELEGATE_PUBLIC
-          || e.getEntryType() == DELEGATE_SYSTEM
-          || e.getEntryType() == DELEGATE_URI) {
-        Catalog dcat = newCatalog();
-        dcat.parseCatalog(e.getEntryArg(1));
-      }
-    }
-  }
-
-
-  /**
-   * Return the applicable DOCTYPE system identifier.
-   *
-   * @param entityName The name of the entity (element) for which
-   * a doctype is required.
-   * @param publicId The nominal public identifier for the doctype
-   * (as provided in the source document).
-   * @param systemId The nominal system identifier for the doctype
-   * (as provided in the source document).
-   *
-   * @return The system identifier to use for the doctype.
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   */
-  public String resolveDoctype(String entityName,
-                               String publicId,
-                               String systemId)
-    throws MalformedURLException, IOException {
-    String resolved = null;
-
-    catalogManager.debug.message(3, "resolveDoctype("
-                  +entityName+","+publicId+","+systemId+")");
-
-    systemId = normalizeURI(systemId);
-
-    if (publicId != null && publicId.startsWith("urn:publicid:")) {
-      publicId = PublicId.decodeURN(publicId);
-    }
-
-    if (systemId != null && systemId.startsWith("urn:publicid:")) {
-      systemId = PublicId.decodeURN(systemId);
-      if (publicId != null && !publicId.equals(systemId)) {
-        catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier");
-        systemId = null;
-      } else {
-        publicId = systemId;
-        systemId = null;
-      }
-    }
-
-    if (systemId != null) {
-      // If there's a SYSTEM entry in this catalog, use it
-      resolved = resolveLocalSystem(systemId);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    if (publicId != null) {
-      // If there's a PUBLIC entry in this catalog, use it
-      resolved = resolveLocalPublic(DOCTYPE,
-                                    entityName,
-                                    publicId,
-                                    systemId);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    // If there's a DOCTYPE entry in this catalog, use it
-    boolean over = default_override;
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == OVERRIDE) {
-        over = e.getEntryArg(0).equalsIgnoreCase("YES");
-        continue;
-      }
-
-      if (e.getEntryType() == DOCTYPE
-          && e.getEntryArg(0).equals(entityName)) {
-        if (over || systemId == null) {
-          return e.getEntryArg(1);
-        }
-      }
-    }
-
-    // Otherwise, look in the subordinate catalogs
-    return resolveSubordinateCatalogs(DOCTYPE,
-                                      entityName,
-                                      publicId,
-                                      systemId);
-  }
-
-  /**
-   * Return the applicable DOCUMENT entry.
-   *
-   * @return The system identifier to use for the doctype.
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   */
-  public String resolveDocument()
-    throws MalformedURLException, IOException {
-    // If there's a DOCUMENT entry, return it
-
-    catalogManager.debug.message(3, "resolveDocument");
-
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == DOCUMENT) {
-        return e.getEntryArg(0);
-      }
-    }
-
-    return resolveSubordinateCatalogs(DOCUMENT,
-                                      null, null, null);
-  }
-
-  /**
-   * Return the applicable ENTITY system identifier.
-   *
-   * @param entityName The name of the entity for which
-   * a system identifier is required.
-   * @param publicId The nominal public identifier for the entity
-   * (as provided in the source document).
-   * @param systemId The nominal system identifier for the entity
-   * (as provided in the source document).
-   *
-   * @return The system identifier to use for the entity.
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   */
-  public String resolveEntity(String entityName,
-                              String publicId,
-                              String systemId)
-    throws MalformedURLException, IOException {
-    String resolved = null;
-
-    catalogManager.debug.message(3, "resolveEntity("
-                  +entityName+","+publicId+","+systemId+")");
-
-    systemId = normalizeURI(systemId);
-
-    if (publicId != null && publicId.startsWith("urn:publicid:")) {
-      publicId = PublicId.decodeURN(publicId);
-    }
-
-    if (systemId != null && systemId.startsWith("urn:publicid:")) {
-      systemId = PublicId.decodeURN(systemId);
-      if (publicId != null && !publicId.equals(systemId)) {
-        catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier");
-        systemId = null;
-      } else {
-        publicId = systemId;
-        systemId = null;
-      }
-    }
-
-    if (systemId != null) {
-      // If there's a SYSTEM entry in this catalog, use it
-      resolved = resolveLocalSystem(systemId);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    if (publicId != null) {
-      // If there's a PUBLIC entry in this catalog, use it
-      resolved = resolveLocalPublic(ENTITY,
-                                    entityName,
-                                    publicId,
-                                    systemId);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    // If there's a ENTITY entry in this catalog, use it
-    boolean over = default_override;
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == OVERRIDE) {
-        over = e.getEntryArg(0).equalsIgnoreCase("YES");
-        continue;
-      }
-
-      if (e.getEntryType() == ENTITY
-          && e.getEntryArg(0).equals(entityName)) {
-        if (over || systemId == null) {
-          return e.getEntryArg(1);
-        }
-      }
-    }
-
-    // Otherwise, look in the subordinate catalogs
-    return resolveSubordinateCatalogs(ENTITY,
-                                      entityName,
-                                      publicId,
-                                      systemId);
-  }
-
-  /**
-   * Return the applicable NOTATION system identifier.
-   *
-   * @param notationName The name of the notation for which
-   * a doctype is required.
-   * @param publicId The nominal public identifier for the notation
-   * (as provided in the source document).
-   * @param systemId The nominal system identifier for the notation
-   * (as provided in the source document).
-   *
-   * @return The system identifier to use for the notation.
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   */
-  public String resolveNotation(String notationName,
-                                String publicId,
-                                String systemId)
-    throws MalformedURLException, IOException {
-    String resolved = null;
-
-    catalogManager.debug.message(3, "resolveNotation("
-                  +notationName+","+publicId+","+systemId+")");
-
-    systemId = normalizeURI(systemId);
-
-    if (publicId != null && publicId.startsWith("urn:publicid:")) {
-      publicId = PublicId.decodeURN(publicId);
-    }
-
-    if (systemId != null && systemId.startsWith("urn:publicid:")) {
-      systemId = PublicId.decodeURN(systemId);
-      if (publicId != null && !publicId.equals(systemId)) {
-        catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier");
-        systemId = null;
-      } else {
-        publicId = systemId;
-        systemId = null;
-      }
-    }
-
-    if (systemId != null) {
-      // If there's a SYSTEM entry in this catalog, use it
-      resolved = resolveLocalSystem(systemId);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    if (publicId != null) {
-      // If there's a PUBLIC entry in this catalog, use it
-      resolved = resolveLocalPublic(NOTATION,
-                                    notationName,
-                                    publicId,
-                                    systemId);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    // If there's a NOTATION entry in this catalog, use it
-    boolean over = default_override;
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == OVERRIDE) {
-        over = e.getEntryArg(0).equalsIgnoreCase("YES");
-        continue;
-      }
-
-      if (e.getEntryType() == NOTATION
-          && e.getEntryArg(0).equals(notationName)) {
-        if (over || systemId == null) {
-          return e.getEntryArg(1);
-        }
-      }
-    }
-
-    // Otherwise, look in the subordinate catalogs
-    return resolveSubordinateCatalogs(NOTATION,
-                                      notationName,
-                                      publicId,
-                                      systemId);
-  }
-
-  /**
-   * Return the applicable PUBLIC or SYSTEM identifier.
-   *
-   * <p>This method searches the Catalog and returns the system
-   * identifier specified for the given system or
-   * public identifiers. If
-   * no appropriate PUBLIC or SYSTEM entry is found in the Catalog,
-   * null is returned.</p>
-   *
-   * @param publicId The public identifier to locate in the catalog.
-   * Public identifiers are normalized before comparison.
-   * @param systemId The nominal system identifier for the entity
-   * in question (as provided in the source document).
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   *
-   * @return The system identifier to use.
-   * Note that the nominal system identifier is not returned if a
-   * match is not found in the catalog, instead null is returned
-   * to indicate that no match was found.
-   */
-  public String resolvePublic(String publicId, String systemId)
-    throws MalformedURLException, IOException {
-
-    catalogManager.debug.message(3, "resolvePublic("+publicId+","+systemId+")");
-
-    systemId = normalizeURI(systemId);
-
-    if (publicId != null && publicId.startsWith("urn:publicid:")) {
-      publicId = PublicId.decodeURN(publicId);
-    }
-
-    if (systemId != null && systemId.startsWith("urn:publicid:")) {
-      systemId = PublicId.decodeURN(systemId);
-      if (publicId != null && !publicId.equals(systemId)) {
-        catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier");
-        systemId = null;
-      } else {
-        publicId = systemId;
-        systemId = null;
-      }
-    }
-
-    // If there's a SYSTEM entry in this catalog, use it
-    if (systemId != null) {
-      String resolved = resolveLocalSystem(systemId);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    // If there's a PUBLIC entry in this catalog, use it
-    String resolved = resolveLocalPublic(PUBLIC,
-                                         null,
-                                         publicId,
-                                         systemId);
-    if (resolved != null) {
-      return resolved;
-    }
-
-    // Otherwise, look in the subordinate catalogs
-    return resolveSubordinateCatalogs(PUBLIC,
-                                      null,
-                                      publicId,
-                                      systemId);
-  }
-
-  /**
-   * Return the applicable PUBLIC or SYSTEM identifier.
-   *
-   * <p>This method searches the Catalog and returns the system
-   * identifier specified for the given system or public identifiers.
-   * If no appropriate PUBLIC or SYSTEM entry is found in the Catalog,
-   * delegated Catalogs are interrogated.</p>
-   *
-   * <p>There are four possible cases:</p>
-   *
-   * <ul>
-   * <li>If the system identifier provided matches a SYSTEM entry
-   * in the current catalog, the SYSTEM entry is returned.
-   * <li>If the system identifier is not null, the PUBLIC entries
-   * that were encountered when OVERRIDE YES was in effect are
-   * interrogated and the first matching entry is returned.</li>
-   * <li>If the system identifier is null, then all of the PUBLIC
-   * entries are interrogated and the first matching entry
-   * is returned. This may not be the same as the preceding case, if
-   * some PUBLIC entries are encountered when OVERRIDE NO is in effect. In
-   * XML, the only place where a public identifier may occur without
-   * a system identifier is in a notation declaration.</li>
-   * <li>Finally, if the public identifier matches one of the partial
-   * public identifiers specified in a DELEGATE* entry in
-   * the Catalog, the delegated catalog is interrogated. The first
-   * time that the delegated catalog is required, it will be
-   * retrieved and parsed. It is subsequently cached.
-   * </li>
-   * </ul>
-   *
-   * @param entityType The CatalogEntry type for which this query is
-   * being conducted. This is necessary in order to do the approprate
-   * query on a delegated catalog.
-   * @param entityName The name of the entity being searched for, if
-   * appropriate.
-   * @param publicId The public identifier of the entity in question.
-   * @param systemId The nominal system identifier for the entity
-   * in question (as provided in the source document).
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * delegated catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading delegated catalog file.
-   *
-   * @return The system identifier to use.
-   * Note that the nominal system identifier is not returned if a
-   * match is not found in the catalog, instead null is returned
-   * to indicate that no match was found.
-   */
-  protected synchronized String resolveLocalPublic(int entityType,
-                                                   String entityName,
-                                                   String publicId,
-                                                   String systemId)
-    throws MalformedURLException, IOException {
-
-    // Always normalize the public identifier before attempting a match
-    publicId = PublicId.normalize(publicId);
-
-    // If there's a SYSTEM entry in this catalog, use it
-    if (systemId != null) {
-      String resolved = resolveLocalSystem(systemId);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    // If there's a PUBLIC entry in this catalog, use it
-    boolean over = default_override;
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == OVERRIDE) {
-        over = e.getEntryArg(0).equalsIgnoreCase("YES");
-        continue;
-      }
-
-      if (e.getEntryType() == PUBLIC
-          && e.getEntryArg(0).equals(publicId)) {
-        if (over || systemId == null) {
-          return e.getEntryArg(1);
-        }
-      }
-    }
-
-    // If there's a DELEGATE_PUBLIC entry in this catalog, use it
-    over = default_override;
-    en = catalogEntries.elements();
-    Vector delCats = new Vector();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == OVERRIDE) {
-        over = e.getEntryArg(0).equalsIgnoreCase("YES");
-        continue;
-      }
-
-      if (e.getEntryType() == DELEGATE_PUBLIC
-          && (over || systemId == null)) {
-        String p = (String) e.getEntryArg(0);
-        if (p.length() <= publicId.length()
-            && p.equals(publicId.substring(0, p.length()))) {
-          // delegate this match to the other catalog
-
-          delCats.addElement(e.getEntryArg(1));
-        }
-      }
-    }
-
-    if (delCats.size() > 0) {
-      Enumeration enCats = delCats.elements();
-
-      if (catalogManager.debug.getDebug() > 1) {
-        catalogManager.debug.message(2, "Switching to delegated catalog(s):");
-        while (enCats.hasMoreElements()) {
-          String delegatedCatalog = (String) enCats.nextElement();
-          catalogManager.debug.message(2, "\t" + delegatedCatalog);
-        }
-      }
-
-      Catalog dcat = newCatalog();
-
-      enCats = delCats.elements();
-      while (enCats.hasMoreElements()) {
-        String delegatedCatalog = (String) enCats.nextElement();
-        dcat.parseCatalog(delegatedCatalog);
-      }
-
-      return dcat.resolvePublic(publicId, null);
-    }
-
-    // Nada!
-    return null;
-  }
-
-  /**
-   * Return the applicable SYSTEM system identifier.
-   *
-   * <p>If a SYSTEM entry exists in the Catalog
-   * for the system ID specified, return the mapped value.</p>
-   *
-   * <p>On Windows-based operating systems, the comparison between
-   * the system identifier provided and the SYSTEM entries in the
-   * Catalog is case-insensitive.</p>
-   *
-   * @param systemId The system ID to locate in the catalog.
-   *
-   * @return The resolved system identifier.
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   */
-  public String resolveSystem(String systemId)
-    throws MalformedURLException, IOException {
-
-    catalogManager.debug.message(3, "resolveSystem("+systemId+")");
-
-    systemId = normalizeURI(systemId);
-
-    if (systemId != null && systemId.startsWith("urn:publicid:")) {
-      systemId = PublicId.decodeURN(systemId);
-      return resolvePublic(systemId, null);
-    }
-
-    // If there's a SYSTEM entry in this catalog, use it
-    if (systemId != null) {
-      String resolved = resolveLocalSystem(systemId);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    // Otherwise, look in the subordinate catalogs
-    return resolveSubordinateCatalogs(SYSTEM,
-                                      null,
-                                      null,
-                                      systemId);
-  }
-
-  /**
-   * Return the applicable SYSTEM system identifier in this
-   * catalog.
-   *
-   * <p>If a SYSTEM entry exists in the catalog file
-   * for the system ID specified, return the mapped value.</p>
-   *
-   * @param systemId The system ID to locate in the catalog
-   *
-   * @return The mapped system identifier or null
-   */
-  protected String resolveLocalSystem(String systemId)
-    throws MalformedURLException, IOException {
-
-    String osname = SecuritySupport.getSystemProperty("os.name");
-    boolean windows = (osname.indexOf("Windows") >= 0);
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == SYSTEM
-          && (e.getEntryArg(0).equals(systemId)
-              || (windows
-                  && e.getEntryArg(0).equalsIgnoreCase(systemId)))) {
-        return e.getEntryArg(1);
-      }
-    }
-
-    // If there's a REWRITE_SYSTEM entry in this catalog, use it
-    en = catalogEntries.elements();
-    String startString = null;
-    String prefix = null;
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-
-      if (e.getEntryType() == REWRITE_SYSTEM) {
-        String p = (String) e.getEntryArg(0);
-        if (p.length() <= systemId.length()
-            && p.equals(systemId.substring(0, p.length()))) {
-          // Is this the longest prefix?
-          if (startString == null
-              || p.length() > startString.length()) {
-            startString = p;
-            prefix = e.getEntryArg(1);
-          }
-        }
-      }
-    }
-
-    if (prefix != null) {
-      // return the systemId with the new prefix
-      return prefix + systemId.substring(startString.length());
-    }
-
-    // If there's a SYSTEM_SUFFIX entry in this catalog, use it
-    en = catalogEntries.elements();
-    String suffixString = null;
-    String suffixURI = null;
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-
-      if (e.getEntryType() == SYSTEM_SUFFIX) {
-        String p = (String) e.getEntryArg(0);
-        if (p.length() <= systemId.length()
-            && systemId.endsWith(p)) {
-          // Is this the longest prefix?
-          if (suffixString == null
-              || p.length() > suffixString.length()) {
-            suffixString = p;
-            suffixURI = e.getEntryArg(1);
-          }
-        }
-      }
-    }
-
-    if (suffixURI != null) {
-      // return the systemId for the suffix
-      return suffixURI;
-    }
-
-    // If there's a DELEGATE_SYSTEM entry in this catalog, use it
-    en = catalogEntries.elements();
-    Vector delCats = new Vector();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-
-      if (e.getEntryType() == DELEGATE_SYSTEM) {
-        String p = (String) e.getEntryArg(0);
-        if (p.length() <= systemId.length()
-            && p.equals(systemId.substring(0, p.length()))) {
-          // delegate this match to the other catalog
-
-          delCats.addElement(e.getEntryArg(1));
-        }
-      }
-    }
-
-    if (delCats.size() > 0) {
-      Enumeration enCats = delCats.elements();
-
-      if (catalogManager.debug.getDebug() > 1) {
-        catalogManager.debug.message(2, "Switching to delegated catalog(s):");
-        while (enCats.hasMoreElements()) {
-          String delegatedCatalog = (String) enCats.nextElement();
-          catalogManager.debug.message(2, "\t" + delegatedCatalog);
-        }
-      }
-
-      Catalog dcat = newCatalog();
-
-      enCats = delCats.elements();
-      while (enCats.hasMoreElements()) {
-        String delegatedCatalog = (String) enCats.nextElement();
-        dcat.parseCatalog(delegatedCatalog);
-      }
-
-      return dcat.resolveSystem(systemId);
-    }
-
-    return null;
-  }
-
-  /**
-   * Return the applicable URI.
-   *
-   * <p>If a URI entry exists in the Catalog
-   * for the URI specified, return the mapped value.</p>
-   *
-   * <p>URI comparison is case sensitive.</p>
-   *
-   * @param uri The URI to locate in the catalog.
-   *
-   * @return The resolved URI.
-   *
-   * @throws MalformedURLException The system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   */
-  public String resolveURI(String uri)
-    throws MalformedURLException, IOException {
-
-    catalogManager.debug.message(3, "resolveURI("+uri+")");
-
-    uri = normalizeURI(uri);
-
-    if (uri != null && uri.startsWith("urn:publicid:")) {
-      uri = PublicId.decodeURN(uri);
-      return resolvePublic(uri, null);
-    }
-
-    // If there's a URI entry in this catalog, use it
-    if (uri != null) {
-      String resolved = resolveLocalURI(uri);
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    // Otherwise, look in the subordinate catalogs
-    return resolveSubordinateCatalogs(URI,
-                                      null,
-                                      null,
-                                      uri);
-  }
-
-  /**
-   * Return the applicable URI in this catalog.
-   *
-   * <p>If a URI entry exists in the catalog file
-   * for the URI specified, return the mapped value.</p>
-   *
-   * @param uri The URI to locate in the catalog
-   *
-   * @return The mapped URI or null
-   */
-  protected String resolveLocalURI(String uri)
-    throws MalformedURLException, IOException {
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == URI
-          && (e.getEntryArg(0).equals(uri))) {
-        return e.getEntryArg(1);
-      }
-    }
-
-    // If there's a REWRITE_URI entry in this catalog, use it
-    en = catalogEntries.elements();
-    String startString = null;
-    String prefix = null;
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-
-      if (e.getEntryType() == REWRITE_URI) {
-        String p = (String) e.getEntryArg(0);
-        if (p.length() <= uri.length()
-            && p.equals(uri.substring(0, p.length()))) {
-          // Is this the longest prefix?
-          if (startString == null
-              || p.length() > startString.length()) {
-            startString = p;
-            prefix = e.getEntryArg(1);
-          }
-        }
-      }
-    }
-
-    if (prefix != null) {
-      // return the uri with the new prefix
-      return prefix + uri.substring(startString.length());
-    }
-
-    // If there's a URI_SUFFIX entry in this catalog, use it
-    en = catalogEntries.elements();
-    String suffixString = null;
-    String suffixURI = null;
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-
-      if (e.getEntryType() == URI_SUFFIX) {
-        String p = (String) e.getEntryArg(0);
-        if (p.length() <= uri.length()
-            && uri.endsWith(p)) {
-          // Is this the longest prefix?
-          if (suffixString == null
-              || p.length() > suffixString.length()) {
-            suffixString = p;
-            suffixURI = e.getEntryArg(1);
-          }
-        }
-      }
-    }
-
-    if (suffixURI != null) {
-      // return the uri for the suffix
-      return suffixURI;
-    }
-
-    // If there's a DELEGATE_URI entry in this catalog, use it
-    en = catalogEntries.elements();
-    Vector delCats = new Vector();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-
-      if (e.getEntryType() == DELEGATE_URI) {
-        String p = (String) e.getEntryArg(0);
-        if (p.length() <= uri.length()
-            && p.equals(uri.substring(0, p.length()))) {
-          // delegate this match to the other catalog
-
-          delCats.addElement(e.getEntryArg(1));
-        }
-      }
-    }
-
-    if (delCats.size() > 0) {
-      Enumeration enCats = delCats.elements();
-
-      if (catalogManager.debug.getDebug() > 1) {
-        catalogManager.debug.message(2, "Switching to delegated catalog(s):");
-        while (enCats.hasMoreElements()) {
-          String delegatedCatalog = (String) enCats.nextElement();
-          catalogManager.debug.message(2, "\t" + delegatedCatalog);
-        }
-      }
-
-      Catalog dcat = newCatalog();
-
-      enCats = delCats.elements();
-      while (enCats.hasMoreElements()) {
-        String delegatedCatalog = (String) enCats.nextElement();
-        dcat.parseCatalog(delegatedCatalog);
-      }
-
-      return dcat.resolveURI(uri);
-    }
-
-    return null;
-  }
-
-  /**
-   * Search the subordinate catalogs, in order, looking for a match.
-   *
-   * <p>This method searches the Catalog and returns the system
-   * identifier specified for the given entity type with the given
-   * name, public, and system identifiers. In some contexts, these
-   * may be null.</p>
-   *
-   * @param entityType The CatalogEntry type for which this query is
-   * being conducted. This is necessary in order to do the approprate
-   * query on a subordinate catalog.
-   * @param entityName The name of the entity being searched for, if
-   * appropriate.
-   * @param publicId The public identifier of the entity in question
-   * (as provided in the source document).
-   * @param systemId The nominal system identifier for the entity
-   * in question (as provided in the source document). This parameter is
-   * overloaded for the URI entry type.
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * delegated catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading delegated catalog file.
-   *
-   * @return The system identifier to use.
-   * Note that the nominal system identifier is not returned if a
-   * match is not found in the catalog, instead null is returned
-   * to indicate that no match was found.
-   */
-  protected synchronized String resolveSubordinateCatalogs(int entityType,
-                                                           String entityName,
-                                                           String publicId,
-                                                           String systemId)
-    throws MalformedURLException, IOException {
-
-    for (int catPos = 0; catPos < catalogs.size(); catPos++) {
-      Catalog c = null;
-
-      try {
-        c = (Catalog) catalogs.elementAt(catPos);
-      } catch (ClassCastException e) {
-        String catfile = (String) catalogs.elementAt(catPos);
-        c = newCatalog();
-
-        try {
-          c.parseCatalog(catfile);
-        } catch (MalformedURLException mue) {
-          catalogManager.debug.message(1, "Malformed Catalog URL", catfile);
-        } catch (FileNotFoundException fnfe) {
-          catalogManager.debug.message(1, "Failed to load catalog, file not found",
-                        catfile);
-        } catch (IOException ioe) {
-          catalogManager.debug.message(1, "Failed to load catalog, I/O error", catfile);
-        }
-
-        catalogs.setElementAt(c, catPos);
-      }
-
-      String resolved = null;
-
-      // Ok, now what are we supposed to call here?
-      if (entityType == DOCTYPE) {
-        resolved = c.resolveDoctype(entityName,
-                                    publicId,
-                                    systemId);
-      } else if (entityType == DOCUMENT) {
-        resolved = c.resolveDocument();
-      } else if (entityType == ENTITY) {
-        resolved = c.resolveEntity(entityName,
-                                   publicId,
-                                   systemId);
-      } else if (entityType == NOTATION) {
-        resolved = c.resolveNotation(entityName,
-                                     publicId,
-                                     systemId);
-      } else if (entityType == PUBLIC) {
-        resolved = c.resolvePublic(publicId, systemId);
-      } else if (entityType == SYSTEM) {
-        resolved = c.resolveSystem(systemId);
-      } else if (entityType == URI) {
-        resolved = c.resolveURI(systemId);
-      }
-
-      if (resolved != null) {
-        return resolved;
-      }
-    }
-
-    return null;
-  }
-
-  // -----------------------------------------------------------------
-
-  /**
-   * Replace backslashes with forward slashes. (URLs always use
-   * forward slashes.)
-   *
-   * @param sysid The input system identifier.
-   * @return The same system identifier with backslashes turned into
-   * forward slashes.
-   */
-  protected String fixSlashes (String sysid) {
-    return sysid.replace('\\', '/');
-  }
-
-  /**
-   * Construct an absolute URI from a relative one, using the current
-   * base URI.
-   *
-   * @param sysid The (possibly relative) system identifier
-   * @return The system identifier made absolute with respect to the
-   * current {@link #base}.
-   */
-  protected String makeAbsolute(String sysid) {
-    URL local = null;
-
-    sysid = fixSlashes(sysid);
-
-    try {
-      local = new URL(base, sysid);
-    } catch (MalformedURLException e) {
-      catalogManager.debug.message(1, "Malformed URL on system identifier", sysid);
-    }
-
-    if (local != null) {
-      return local.toString();
-    } else {
-      return sysid;
-    }
-  }
-
-
-    /**
-     * Perform character normalization on a URI reference.
-     *
-     * @param uriref The URI reference
-     * @return The normalized URI reference.
-     */
-    protected String normalizeURI(String uriref) {
-        if (uriref == null) {
-            return null;
-        }
-        final int length = uriref.length();
-        for (int i = 0; i < length; ++i) {
-            char c = uriref.charAt(i);
-            if ((c <= 0x20)    // ctrl
-                    || (c > 0x7F)  // high ascii
-                    || (c == 0x22) // "
-                    || (c == 0x3C) // <
-                    || (c == 0x3E) // >
-                    || (c == 0x5C) // \
-                    || (c == 0x5E) // ^
-                    || (c == 0x60) // `
-                    || (c == 0x7B) // {
-                    || (c == 0x7C) // |
-                    || (c == 0x7D) // }
-                    || (c == 0x7F)) {
-                return normalizeURI(uriref, i);
-            }
-        }
-        return uriref;
-    }
-
-    /**
-     * Perform character normalization on a URI reference.
-     *
-     * @param uriref The URI reference
-     * @param index The index of the first character which requires escaping.
-     * @return The normalized URI reference.
-     */
-    private String normalizeURI(String uriref, int index) {
-        final StringBuilder buffer = new StringBuilder();
-        for (int i = 0; i < index; ++i) {
-            buffer.append(uriref.charAt(i));
-        }
-        final byte[] bytes;
-        try {
-            bytes = uriref.substring(index).getBytes("UTF-8");
-        }
-        catch (UnsupportedEncodingException uee) {
-            // this can't happen
-            catalogManager.debug.message(1, "UTF-8 is an unsupported encoding!?");
-            return uriref;
-        }
-        for (int count = 0; count < bytes.length; ++count) {
-            int ch = bytes[count] & 0xFF;
-            if ((ch <= 0x20)    // ctrl
-                    || (ch > 0x7F)  // high ascii
-                    || (ch == 0x22) // "
-                    || (ch == 0x3C) // <
-                    || (ch == 0x3E) // >
-                    || (ch == 0x5C) // \
-                    || (ch == 0x5E) // ^
-                    || (ch == 0x60) // `
-                    || (ch == 0x7B) // {
-                    || (ch == 0x7C) // |
-                    || (ch == 0x7D) // }
-                    || (ch == 0x7F)) {
-                writeEncodedByte(ch, buffer);
-            }
-            else {
-                buffer.append((char) bytes[count]);
-            }
-        }
-        return buffer.toString();
-    }
-
-    /**
-     * Perform %-encoding on a single byte.
-     *
-     * @param b The 8-bit integer that represents the byte. (Bytes are signed
-     *          but encoding needs to look at the bytes unsigned.)
-     * @return The %-encoded string for the byte in question.
-     */
-    protected String encodedByte(int b) {
-        StringBuilder buffer = new StringBuilder(3);
-        writeEncodedByte(b, buffer);
-        return buffer.toString();
-    }
-
-    /**
-     * Perform %-encoding on a single byte.
-     *
-     * @param b The 8-bit integer that represents the byte. (Bytes are signed
-     *          but encoding needs to look at the bytes unsigned.)
-     * @param buffer The target for the %-encoded string for the byte in question.
-     */
-    private void writeEncodedByte(int b, StringBuilder buffer) {
-        String hex = Integer.toHexString(b).toUpperCase(Locale.ENGLISH);
-        if (hex.length() < 2) {
-            buffer.append("%0");
-            buffer.append(hex);
-        }
-        else {
-            buffer.append('%');
-            buffer.append(hex);
-        }
-    }
-
-  // -----------------------------------------------------------------
-
-  /**
-   * Add to the current list of delegated catalogs.
-   *
-   * <p>This method always constructs the {@link #localDelegate}
-   * vector so that it is ordered by length of partial
-   * public identifier.</p>
-   *
-   * @param entry The DELEGATE catalog entry
-   */
-  protected void addDelegate(CatalogEntry entry) {
-    int pos = 0;
-    String partial = entry.getEntryArg(0);
-
-    Enumeration local = localDelegate.elements();
-    while (local.hasMoreElements()) {
-      CatalogEntry dpe = (CatalogEntry) local.nextElement();
-      String dp = dpe.getEntryArg(0);
-      if (dp.equals(partial)) {
-        // we already have this prefix
-        return;
-      }
-      if (dp.length() > partial.length()) {
-        pos++;
-      }
-      if (dp.length() < partial.length()) {
-        break;
-      }
-    }
-
-    // now insert partial into the vector at [pos]
-    if (localDelegate.size() == 0) {
-      localDelegate.addElement(entry);
-    } else {
-      localDelegate.insertElementAt(entry, pos);
-    }
-  }
-}
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java	Wed Jun 28 11:27:28 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
- */
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xml.internal.resolver;
-
-import java.util.Map;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Represents a Catalog entry.
- *
- * <p>Instances of this class represent individual entries
- * in a Catalog.</p>
- *
- * <p>Each catalog entry has a unique name and is associated with
- * an arbitrary number of arguments (all strings). For example, the
- * TR9401 catalog entry "PUBLIC" has two arguments, a public identifier
- * and a system identifier. Each entry has a unique numeric type,
- * assigned automatically when the entry type is created.</p>
- *
- * <p>The number and type of catalog entries is maintained
- * <em>statically</em>. Catalog classes, or their subclasses, can add
- * new entry types, but all Catalog objects share the same global pool
- * of types.</p>
- *
- * <p>Initially there are no valid entries.</p>
- *
- * @see Catalog
- *
- * @author Norman Walsh
- * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
- *
- */
-public class CatalogEntry {
-  /** The nextEntry is the ordinal number of the next entry type. */
-  static AtomicInteger nextEntry = new AtomicInteger(0);
-
-  /**
-   * The entryTypes vector maps catalog entry names
-   * (e.g., 'BASE' or 'SYSTEM') to their type (1, 2, etc.).
-   * Names are case sensitive.
-   */
-  static final Map<String, Integer> entryTypes = new ConcurrentHashMap<>();
-
-  /** The entryTypes vector maps catalog entry types to the
-      number of arguments they're required to have. */
-  static final Vector entryArgs = new Vector();
-
-  /**
-   * Adds a new catalog entry type.
-   *
-   * @param name The name of the catalog entry type. This must be
-   * unique among all types and is case-sensitive. (Adding a duplicate
-   * name effectively replaces the old type with the new type.)
-   * @param numArgs The number of arguments that this entry type
-   * is required to have. There is no provision for variable numbers
-   * of arguments.
-   * @return The type for the new entry.
-   */
-  static int addEntryType(String name, int numArgs) {
-    final int index = nextEntry.getAndIncrement();
-    entryTypes.put(name, index);
-    entryArgs.add(index, numArgs);
-
-    return index;
-  }
-
-  /**
-   * Lookup an entry type
-   *
-   * @param name The name of the catalog entry type.
-   * @return The type of the catalog entry with the specified name.
-   * @throws InvalidCatalogEntryTypeException if no entry has the
-   * specified name.
-   */
-  public static int getEntryType(String name)
-    throws CatalogException {
-    if (!entryTypes.containsKey(name)) {
-      throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
-    }
-
-    Integer iType = entryTypes.get(name);
-
-    if (iType == null) {
-      throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
-    }
-
-    return iType;
-  }
-
-  /**
-   * Find out how many arguments an entry is required to have.
-   *
-   * @param name The name of the catalog entry type.
-   * @return The number of arguments that entry type is required to have.
-   * @throws InvalidCatalogEntryTypeException if no entry has the
-   * specified name.
-   */
-  public static int getEntryArgCount(String name)
-    throws CatalogException {
-    return getEntryArgCount(getEntryType(name));
-  }
-
-  /**
-   * Find out how many arguments an entry is required to have.
-   *
-   * @param type A valid catalog entry type.
-   * @return The number of arguments that entry type is required to have.
-   * @throws InvalidCatalogEntryTypeException if the type is invalid.
-   */
-  public static int getEntryArgCount(int type)
-    throws CatalogException {
-    try {
-      Integer iArgs = (Integer) entryArgs.get(type);
-      return iArgs.intValue();
-    } catch (ArrayIndexOutOfBoundsException e) {
-      throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
-    }
-  }
-
-  /** The entry type of this entry */
-  protected int entryType = 0;
-
-  /** The arguments associated with this entry */
-  protected Vector args = null;
-
-  /**
-   * Null constructor; something for subclasses to call.
-   */
-  public CatalogEntry() {}
-
-  /**
-   * Construct a catalog entry of the specified type.
-   *
-   * @param name The name of the entry type
-   * @param args A String Vector of arguments
-   * @throws InvalidCatalogEntryTypeException if no such entry type
-   * exists.
-   * @throws InvalidCatalogEntryException if the wrong number of arguments
-   * is passed.
-   */
-  public CatalogEntry(String name, Vector args)
-    throws CatalogException {
-    Integer iType = entryTypes.get(name);
-
-    if (iType == null) {
-      throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
-    }
-
-    int type = iType;
-
-    try {
-      Integer iArgs = (Integer) entryArgs.get(type);
-      if (iArgs.intValue() != args.size()) {
-        throw new CatalogException(CatalogException.INVALID_ENTRY);
-      }
-    } catch (ArrayIndexOutOfBoundsException e) {
-      throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
-    }
-
-    entryType = type;
-    this.args = args;
-  }
-
-  /**
-   * Construct a catalog entry of the specified type.
-   *
-   * @param type The entry type
-   * @param args A String Vector of arguments
-   * @throws InvalidCatalogEntryTypeException if no such entry type
-   * exists.
-   * @throws InvalidCatalogEntryException if the wrong number of arguments
-   * is passed.
-   */
-  public CatalogEntry(int type, Vector args)
-    throws CatalogException {
-    try {
-      Integer iArgs = (Integer) entryArgs.get(type);
-      if (iArgs.intValue() != args.size()) {
-        throw new CatalogException(CatalogException.INVALID_ENTRY);
-      }
-    } catch (ArrayIndexOutOfBoundsException e) {
-      throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
-    }
-
-    entryType = type;
-    this.args = args;
-  }
-
-  /**
-   * Get the entry type.
-   *
-   * @return The entry type of the CatalogEntry
-   */
-  public int getEntryType() {
-    return entryType;
-  }
-
-  /**
-   * Get an entry argument.
-   *
-   * @param argNum The argument number (arguments are numbered from 0).
-   * @return The specified argument or null if an invalid argNum is
-   * provided.
-   */
-  public String getEntryArg(int argNum) {
-    try {
-      String arg = (String) args.get(argNum);
-      return arg;
-    } catch (ArrayIndexOutOfBoundsException e) {
-      return null;
-    }
-  }
-
-  /**
-   * Set an entry argument.
-   *
-   * <p>Catalogs sometimes need to adjust the catlog entry parameters,
-   * for example to make a relative URI absolute with respect to the
-   * current base URI. But in general, this function should only be
-   * called shortly after object creation to do some sort of cleanup.
-   * Catalog entries should not mutate over time.</p>
-   *
-   * @param argNum The argument number (arguments are numbered from 0).
-   * @throws ArrayIndexOutOfBoundsException if an invalid argument
-   * number is provided.
-   */
-  public void setEntryArg(int argNum, String newspec)
-    throws ArrayIndexOutOfBoundsException {
-    args.set(argNum, newspec);
-  }
-}
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogException.java	Wed Jun 28 11:27:28 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xml.internal.resolver;
-
-/**
- * Signal Catalog exception.
- *
- * <p>This exception is thrown if an error occurs loading a
- * catalog file.</p>
- *
- * @see Catalog
- *
- * @author Norman Walsh
- * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
- *
- */
-public class CatalogException extends Exception {
-
-  private static final long serialVersionUID = 4007157171817798450L;
-
-  /** A wrapper around another exception */
-  public static final int WRAPPER = 1;
-  /** An invalid entry */
-  public static final int INVALID_ENTRY = 2;
-  /** An invalid entry type */
-  public static final int INVALID_ENTRY_TYPE = 3;
-  /** Could not instantiate an XML parser */
-  public static final int NO_XML_PARSER = 4;
-  /** Unknown XML format */
-  public static final int UNKNOWN_FORMAT = 5;
-  /** Unparseable XML catalog (not XML)*/
-  public static final int UNPARSEABLE = 6;
-  /** XML but parse failed */
-  public static final int PARSE_FAILED = 7;
-  /** Text catalog ended in mid-comment */
-  public static final int UNENDED_COMMENT = 8;
-
-  /**
-   * The embedded exception if tunnelling, or null.
-   */
-  private final Exception exception;
-  private final int exceptionType;
-
-  /**
-   * Create a new CatalogException.
-   *
-   * @param type The exception type
-   * @param message The error or warning message.
-   */
-  public CatalogException (int type, String message) {
-    super(message);
-    this.exceptionType = type;
-    this.exception = null;
-  }
-
-  /**
-   * Create a new CatalogException.
-   *
-   * @param type The exception type
-   */
-  public CatalogException (int type) {
-    super("Catalog Exception " + type);
-    this.exceptionType = type;
-    this.exception = null;
-  }
-
-  /**
-   * Create a new CatalogException wrapping an existing exception.
-   *
-   * <p>The existing exception will be embedded in the new
-   * one, and its message will become the default message for
-   * the CatalogException.</p>
-   *
-   * @param e The exception to be wrapped in a CatalogException.
-   */
-  public CatalogException (Exception e) {
-    super();
-    this.exceptionType = WRAPPER;
-    this.exception = e;
-  }
-
-  /**
-   * Create a new CatalogException from an existing exception.
-   *
-   * <p>The existing exception will be embedded in the new
-   * one, but the new exception will have its own message.</p>
-   *
-   * @param message The detail message.
-   * @param e The exception to be wrapped in a CatalogException.
-   */
-  public CatalogException (String message, Exception e) {
-    super(message);
-    this.exceptionType = WRAPPER;
-    this.exception = e;
-  }
-
-  /**
-   * Return a detail message for this exception.
-   *
-   * <p>If there is an embedded exception, and if the CatalogException
-   * has no detail message of its own, this method will return
-   * the detail message from the embedded exception.</p>
-   *
-   * @return The error or warning message.
-   */
-  public String getMessage ()
-  {
-    String message = super.getMessage();
-
-    if (message == null && exception != null) {
-      return exception.getMessage();
-    } else {
-      return message;
-    }
-  }
-
-  /**
-   * Return the embedded exception, if any.
-   *
-   * @return The embedded exception, or null if there is none.
-   */
-  public Exception getException ()
-  {
-    return exception;
-  }
-
-  /**
-   * Return the exception type
-   *
-   * @return The exception type
-   */
-  public int getExceptionType ()
-  {
-    return exceptionType;
-  }
-
-  /**
-   * Override toString to pick up any embedded exception.
-   *
-   * @return A string representation of this exception.
-   */
-  public String toString ()
-  {
-    if (exception != null) {
-      return exception.toString();
-    } else {
-      return super.toString();
-    }
-  }
-}
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java	Wed Jun 28 11:27:28 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,870 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xml.internal.resolver;
-
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
-import com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver;
-import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import sun.reflect.misc.ReflectUtil;
-
-/**
- * CatalogManager provides an interface to the catalog properties.
- *
- * <p>Properties can come from two places: from system properties or
- * from a <i>CatalogManager.properties</i> file. This class provides a transparent
- * interface to both, with system properties preferred over property file values.</p>
- *
- * <p>The following table summarizes the properties:</p>
- *
- * <table border="1">
- * <thead>
- * <tr>
- * <td>System Property</td>
- * <td>CatalogManager.properties<br/>Property</td>
- * <td>Description</td>
- * </tr>
- * </thead>
- * <tbody>
- * <tr>
- * <td>xml.catalog.ignoreMissing</td>
- * <td>&#160;</td>
- * <td>If true, a missing <i>CatalogManager.properties</i> file or missing properties
- * within that file will not generate warning messages. See also the
- * <i>ignoreMissingProperties</i> method.</td>
- * </tr>
- *
- * <tr>
- * <td>xml.catalog.files</td>
- * <td>catalogs</td>
- * <td>The <emph>semicolon-delimited</emph> list of catalog files.</td>
- * </tr>
- *
- * <tr>
- * <td>&#160;</td>
- * <td>relative-catalogs</td>
- * <td>If false, relative catalog URIs are made absolute with respect to the base URI of
- * the <i>CatalogManager.properties</i> file. This setting only applies to catalog
- * URIs obtained from the <i>catalogs</i> property <emph>in the</emph>
- * <i>CatalogManager.properties</i> file</td>
- * </tr>
- *
- * <tr>
- * <td>xml.catalog.verbosity</td>
- * <td>verbosity</td>
- * <td>If non-zero, the Catalog classes will print informative and debugging messages.
- * The higher the number, the more messages.</td>
- * </tr>
- *
- * <tr>
- * <td>xml.catalog.prefer</td>
- * <td>prefer</td>
- * <td>Which identifier is preferred, "public" or "system"?</td>
- * </tr>
- *
- * <tr>
- * <td>xml.catalog.staticCatalog</td>
- * <td>static-catalog</td>
- * <td>Should a single catalog be constructed for all parsing, or should a different
- * catalog be created for each parser?</td>
- * </tr>
- *
- * <tr>
- * <td>xml.catalog.allowPI</td>
- * <td>allow-oasis-xml-catalog-pi</td>
- * <td>If the source document contains "oasis-xml-catalog" processing instructions,
- * should they be used?</td>
- * </tr>
- *
- * <tr>
- * <td>xml.catalog.className</td>
- * <td>catalog-class-name</td>
- * <td>If you're using the convenience classes
- * <tt>com.sun.org.apache.xml.internal.resolver.tools.*</tt>), this setting
- * allows you to specify an alternate class name to use for the underlying
- * catalog.</td>
- * </tr>
- * </tbody>
- * </table>
- *
- * @see Catalog
- * @deprecated The JDK internal Catalog API in package
- * {@code com.sun.org.apache.xml.internal.resolver}
- * is encapsulated in JDK 9. The entire implementation under the package is now
- * deprecated and subject to removal in a future release. Users of the API
- * should migrate to the {@linkplain javax.xml.catalog new public API}.
- * <p>
- * The new Catalog API is supported throughout the JDK XML Processors, which allows
- * the use of Catalog by simply setting a path to a Catalog file as a property.
- *
- * @author Norman Walsh
- * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
- *
- * @version 1.0
- */
-@Deprecated(since="9", forRemoval=true)
-public class CatalogManager {
-    private static final String pFiles         = "xml.catalog.files";
-    private static final String pVerbosity     = "xml.catalog.verbosity";
-    private static final String pPrefer        = "xml.catalog.prefer";
-    private static final String pStatic        = "xml.catalog.staticCatalog";
-    private static final String pAllowPI       = "xml.catalog.allowPI";
-    private static final String pClassname     = "xml.catalog.className";
-    private static final String pIgnoreMissing = "xml.catalog.ignoreMissing";
-
-    /** A static CatalogManager instance for sharing */
-    private static final CatalogManager staticManager = new CatalogManager();
-
-    /** The bootstrap resolver to use when loading XML Catalogs. */
-    private BootstrapResolver bResolver = new BootstrapResolver();
-
-    /** Flag to ignore missing property files and/or properties */
-    private boolean ignoreMissingProperties
-    = (SecuritySupport.getSystemProperty(pIgnoreMissing) != null
-    || SecuritySupport.getSystemProperty(pFiles) != null);
-
-    /** Holds the resources after they are loaded from the file. */
-    private ResourceBundle resources;
-
-    /** The name of the CatalogManager properties file. */
-    private String propertyFile = "CatalogManager.properties";
-
-    /** The location of the propertyFile */
-    private URL propertyFileURI = null;
-
-    /** Default catalog files list. */
-    private String defaultCatalogFiles = "./xcatalog";
-
-    /** Current catalog files list. */
-    private String catalogFiles = null;
-
-    /** Did the catalogFiles come from the properties file? */
-    private boolean fromPropertiesFile = false;
-
-    /** Default verbosity level if there is no property setting for it. */
-    private int defaultVerbosity = 1;
-
-    /** Current verbosity level. */
-    private Integer verbosity = null;
-
-    /** Default preference setting. */
-    private boolean defaultPreferPublic = true;
-
-    /** Current preference setting. */
-    private Boolean preferPublic = null;
-
-    /** Default setting of the static catalog flag. */
-    private boolean defaultUseStaticCatalog = true;
-
-    /** Current setting of the static catalog flag. */
-    private Boolean useStaticCatalog = null;
-
-    /** The static catalog used by this manager. */
-    private static volatile Catalog staticCatalog = null;
-
-    /** Default setting of the oasisXMLCatalogPI flag. */
-    private boolean defaultOasisXMLCatalogPI = true;
-
-    /** Current setting of the oasisXMLCatalogPI flag. */
-    private Boolean oasisXMLCatalogPI = null;
-
-    /** Default setting of the relativeCatalogs flag. */
-    private boolean defaultRelativeCatalogs = true;
-
-    /** Current setting of the relativeCatalogs flag. */
-    private Boolean relativeCatalogs = null;
-
-    /** Current catalog class name. */
-    private String catalogClassName = null;
-    /**
-     * Indicates whether implementation parts should use
-     *   service loader (or similar).
-     * Note the default value (false) is the safe option..
-     */
-    private boolean useServicesMechanism;
-
-    /** The manager's debug object. Used for printing debugging messages.
-     *
-     * <p>This field is public so that objects that have access to this
-     * CatalogManager can use this debug object.</p>
-     */
-    public Debug debug = null;
-
-    /** Constructor. */
-    public CatalogManager() {
-        init();
-    }
-
-    /** Constructor that specifies an explicit property file. */
-    public CatalogManager(String propertyFile) {
-        this.propertyFile = propertyFile;
-        init();
-  }
-
-  private void init() {
-        debug = new Debug();
-    // Note that we don't setDebug() here; we do that lazily. Either the
-    // user will set it explicitly, or we'll do it automagically if they
-    // read from the propertyFile for some other reason. That way, there's
-    // no attempt to read from the file before the caller has had a chance
-    // to avoid it.
-    if (System.getSecurityManager() == null) {
-        useServicesMechanism = true;
-    }
-        // Make sure verbosity is set by xml.catalog.verbosity sysprop
-        // setting, if defined.
-        queryVerbosityFromSysProp();
-    }
-
-    /** Set the bootstrap resolver
-     * @param resolver the bootstrap resolver
-     */
-    public void setBootstrapResolver(BootstrapResolver resolver) {
-        bResolver = resolver;
-    }
-
-    /** Get the bootstrap resolver
-     * @return the bootstrap resolver
-     */
-    public BootstrapResolver getBootstrapResolver() {
-        return bResolver;
-    }
-
-    /** Query system property for verbosity level. */
-    private void queryVerbosityFromSysProp() {
-        String verbStr = SecuritySupport.getSystemProperty(pVerbosity);
-        if (verbStr != null) {
-            try {
-                int verb = Integer.parseInt(verbStr.trim());
-                verbosity = new Integer(verb);
-                debug.setDebug(verb);
-            } catch (Exception e) {
-                System.err.println("Cannot parse verbosity: \"" + verbStr + "\"");
-            }
-        }
-    }
-
-    /**
-     * Load the properties from the propertyFile and build the
-     * resources from it.
-     */
-    private synchronized void readProperties() {
-        try {
-            propertyFileURI = CatalogManager.class.getResource("/"+propertyFile);
-            InputStream in =
-                    CatalogManager.class.getResourceAsStream("/"+propertyFile);
-            if (in==null) {
-                if (!ignoreMissingProperties) {
-                    System.err.println("Cannot find "+propertyFile);
-                    // there's no reason to give this warning more than once
-                    ignoreMissingProperties = true;
-                }
-                return;
-            }
-            resources = new PropertyResourceBundle(in);
-        } catch (MissingResourceException mre) {
-            if (!ignoreMissingProperties) {
-                System.err.println("Cannot read "+propertyFile);
-            }
-        } catch (java.io.IOException e) {
-            if (!ignoreMissingProperties) {
-                System.err.println("Failure trying to read "+propertyFile);
-            }
-        }
-
-        // This is a bit of a hack. After we've successfully read the properties,
-        // use them to set the default debug level, if the user hasn't already set
-        // the default debug level.
-        if (verbosity == null) {
-            try {
-                String verbStr = resources.getString("verbosity");
-                int verb = Integer.parseInt(verbStr.trim());
-                debug.setDebug(verb);
-                verbosity = new Integer(verb);
-            } catch (Exception e) {
-                // nop
-            }
-        }
-    }
-
-    /**
-     * Allow access to the static CatalogManager
-     */
-    public static CatalogManager getStaticManager() {
-        return staticManager;
-    }
-
-    /**
-     * How are missing properties handled?
-     *
-     * <p>If true, missing or unreadable property files will
-     * not be reported. Otherwise, a message will be sent to System.err.
-     * </p>
-     */
-    public boolean getIgnoreMissingProperties() {
-        return ignoreMissingProperties;
-    }
-
-    /**
-     * How should missing properties be handled?
-     *
-     * <p>If ignore is true, missing or unreadable property files will
-     * not be reported. Otherwise, a message will be sent to System.err.
-     * </p>
-     */
-    public void setIgnoreMissingProperties(boolean ignore) {
-        ignoreMissingProperties = ignore;
-    }
-
-    /**
-     * How are missing properties handled?
-     *
-     * <p>If ignore is true, missing or unreadable property files will
-     * not be reported. Otherwise, a message will be sent to System.err.
-     * </p>
-     *
-     * @deprecated No longer static; use get/set methods.
-     */
-    public void ignoreMissingProperties(boolean ignore) {
-        setIgnoreMissingProperties(ignore);
-    }
-
-    /**
-     * Obtain the verbosity setting from the properties.
-     *
-     * @return The verbosity level from the propertyFile or the
-     * defaultVerbosity.
-     */
-    private int queryVerbosity () {
-        String defaultVerbStr = Integer.toString(defaultVerbosity);
-
-        String verbStr = SecuritySupport.getSystemProperty(pVerbosity);
-
-        if (verbStr == null) {
-            if (resources==null) readProperties();
-            if (resources != null) {
-                try {
-                    verbStr = resources.getString("verbosity");
-                } catch (MissingResourceException e) {
-                    verbStr = defaultVerbStr;
-                }
-            } else {
-                verbStr = defaultVerbStr;
-            }
-        }
-
-        int verb = defaultVerbosity;
-
-        try {
-            verb = Integer.parseInt(verbStr.trim());
-        } catch (Exception e) {
-            System.err.println("Cannot parse verbosity: \"" + verbStr + "\"");
-        }
-
-        // This is a bit of a hack. After we've successfully got the verbosity,
-        // we have to use it to set the default debug level,
-        // if the user hasn't already set the default debug level.
-        if (verbosity == null) {
-            debug.setDebug(verb);
-            verbosity = new Integer(verb);
-        }
-
-        return verb;
-    }
-
-    /**
-     * What is the current verbosity?
-     */
-    public int getVerbosity() {
-        if (verbosity == null) {
-            verbosity = new Integer(queryVerbosity());
-        }
-
-        return verbosity.intValue();
-    }
-
-    /**
-     * Set the current verbosity.
-     */
-    public void setVerbosity (int verbosity) {
-        this.verbosity = new Integer(verbosity);
-        debug.setDebug(verbosity);
-    }
-
-    /**
-     * What is the current verbosity?
-     *
-     * @deprecated No longer static; use get/set methods.
-     */
-    public int verbosity () {
-        return getVerbosity();
-    }
-
-    /**
-     * Obtain the relativeCatalogs setting from the properties.
-     *
-     * @return The relativeCatalogs setting from the propertyFile or the
-     * defaultRelativeCatalogs.
-     */
-    private boolean queryRelativeCatalogs () {
-        if (resources==null) readProperties();
-
-        if (resources==null) return defaultRelativeCatalogs;
-
-        try {
-            String allow = resources.getString("relative-catalogs");
-            return (allow.equalsIgnoreCase("true")
-                    || allow.equalsIgnoreCase("yes")
-                    || allow.equalsIgnoreCase("1"));
-        } catch (MissingResourceException e) {
-            return defaultRelativeCatalogs;
-        }
-    }
-
-    /**
-     * Get the relativeCatalogs setting.
-     *
-     * <p>This property is used when the catalogFiles property is
-     * interrogated. If true, then relative catalog entry file names
-     * are returned. If false, relative catalog entry file names are
-     * made absolute with respect to the properties file before returning
-     * them.</p>
-     *
-     * <p>This property <emph>only applies</emph> when the catalog files
-     * come from a properties file. If they come from a system property or
-     * the default list, they are never considered relative. (What would
-     * they be relative to?)</p>
-     *
-     * <p>In the properties, a value of 'yes', 'true', or '1' is considered
-     * true, anything else is false.</p>
-     *
-     * @return The relativeCatalogs setting from the propertyFile or the
-     * defaultRelativeCatalogs.
-     */
-    public boolean getRelativeCatalogs () {
-        if (relativeCatalogs == null) {
-            relativeCatalogs = queryRelativeCatalogs() ? Boolean.TRUE : Boolean.FALSE;
-        }
-
-        return relativeCatalogs.booleanValue();
-    }
-
-    /**
-     * Set the relativeCatalogs setting.
-     *
-     * @see #getRelativeCatalogs()
-     */
-    public void setRelativeCatalogs (boolean relative) {
-        relativeCatalogs = relative ? Boolean.TRUE : Boolean.FALSE;
-    }
-
-    /**
-     * Get the relativeCatalogs setting.
-     *
-     * @deprecated No longer static; use get/set methods.
-     */
-    public boolean relativeCatalogs () {
-        return getRelativeCatalogs();
-    }
-
-    /**
-     * Obtain the list of catalog files from the properties.
-     *
-     * @return A semicolon delimited list of catlog file URIs
-     */
-    private String queryCatalogFiles () {
-        String catalogList = SecuritySupport.getSystemProperty(pFiles);
-        fromPropertiesFile = false;
-
-        if (catalogList == null) {
-            if (resources == null) readProperties();
-            if (resources != null) {
-                try {
-                    catalogList = resources.getString("catalogs");
-                    fromPropertiesFile = true;
-                } catch (MissingResourceException e) {
-                    System.err.println(propertyFile + ": catalogs not found.");
-                    catalogList = null;
-                }
-            }
-        }
-
-        if (catalogList == null) {
-            catalogList = defaultCatalogFiles;
-        }
-
-        return catalogList;
-    }
-
-    /**
-     * Return the current list of catalog files.
-     *
-     * @return A vector of the catalog file names or null if no catalogs
-     * are available in the properties.
-     */
-    public Vector getCatalogFiles() {
-        if (catalogFiles == null) {
-            catalogFiles = queryCatalogFiles();
-        }
-
-        StringTokenizer files = new StringTokenizer(catalogFiles, ";");
-        Vector catalogs = new Vector();
-        while (files.hasMoreTokens()) {
-            String catalogFile = files.nextToken();
-            URL absURI = null;
-
-            if (fromPropertiesFile && !relativeCatalogs()) {
-                try {
-                    absURI = new URL(propertyFileURI, catalogFile);
-                    catalogFile = absURI.toString();
-                } catch (MalformedURLException mue) {
-                    absURI = null;
-                }
-            }
-
-            catalogs.add(catalogFile);
-        }
-
-        return catalogs;
-    }
-
-    /**
-     * Set the list of catalog files.
-     */
-    public void setCatalogFiles(String fileList) {
-        catalogFiles = fileList;
-        fromPropertiesFile = false;
-    }
-
-    /**
-     * Return the current list of catalog files.
-     *
-     * @return A vector of the catalog file names or null if no catalogs
-     * are available in the properties.
-     *
-     * @deprecated No longer static; use get/set methods.
-     */
-    public Vector catalogFiles() {
-        return getCatalogFiles();
-    }
-
-    /**
-     * Obtain the preferPublic setting from the properties.
-     *
-     * <p>In the properties, a value of 'public' is true,
-     * anything else is false.</p>
-     *
-     * @return True if prefer is public or the
-     * defaultPreferSetting.
-     */
-    private boolean queryPreferPublic () {
-        String prefer = SecuritySupport.getSystemProperty(pPrefer);
-
-        if (prefer == null) {
-            if (resources==null) readProperties();
-            if (resources==null) return defaultPreferPublic;
-            try {
-                prefer = resources.getString("prefer");
-            } catch (MissingResourceException e) {
-                return defaultPreferPublic;
-            }
-        }
-
-        if (prefer == null) {
-            return defaultPreferPublic;
-        }
-
-        return (prefer.equalsIgnoreCase("public"));
-    }
-
-    /**
-     * Return the current prefer public setting.
-     *
-     * @return True if public identifiers are preferred.
-     */
-    public boolean getPreferPublic () {
-        if (preferPublic == null) {
-            preferPublic = queryPreferPublic() ? Boolean.TRUE : Boolean.FALSE;
-        }
-        return preferPublic.booleanValue();
-    }
-
-    /**
-     * Set the prefer public setting.
-     */
-    public void setPreferPublic (boolean preferPublic) {
-        this.preferPublic = preferPublic ? Boolean.TRUE : Boolean.FALSE;
-    }
-
-    /**
-     * Return the current prefer public setting.
-     *
-     * @return True if public identifiers are preferred.
-     *
-     * @deprecated No longer static; use get/set methods.
-     */
-    public boolean preferPublic () {
-        return getPreferPublic();
-    }
-
-    /**
-     * Obtain the static-catalog setting from the properties.
-     *
-     * <p>In the properties, a value of 'yes', 'true', or '1' is considered
-     * true, anything else is false.</p>
-     *
-     * @return The static-catalog setting from the propertyFile or the
-     * defaultUseStaticCatalog.
-     */
-    private boolean queryUseStaticCatalog () {
-        String staticCatalog = SecuritySupport.getSystemProperty(pStatic);
-
-        if (staticCatalog == null) {
-            if (resources==null) readProperties();
-            if (resources==null) return defaultUseStaticCatalog;
-            try {
-                staticCatalog = resources.getString("static-catalog");
-            } catch (MissingResourceException e) {
-                return defaultUseStaticCatalog;
-            }
-        }
-
-        if (staticCatalog == null) {
-            return defaultUseStaticCatalog;
-        }
-
-        return (staticCatalog.equalsIgnoreCase("true")
-                || staticCatalog.equalsIgnoreCase("yes")
-                || staticCatalog.equalsIgnoreCase("1"));
-    }
-
-    /**
-     * Get the current use static catalog setting.
-     */
-    public boolean getUseStaticCatalog() {
-        if (useStaticCatalog == null) {
-            useStaticCatalog = queryUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE;
-        }
-
-        return useStaticCatalog.booleanValue();
-    }
-
-    /**
-     * Set the use static catalog setting.
-     */
-    public void setUseStaticCatalog(boolean useStatic) {
-        useStaticCatalog = useStatic ? Boolean.TRUE : Boolean.FALSE;
-    }
-
-    /**
-     * Get the current use static catalog setting.
-     *
-     * @deprecated No longer static; use get/set methods.
-     */
-    public boolean staticCatalog() {
-        return getUseStaticCatalog();
-    }
-
-    /**
-     * Get a new catalog instance.
-     *
-     * This method always returns a new instance of the underlying catalog class.
-     */
-    public Catalog getPrivateCatalog() {
-        Catalog catalog = staticCatalog;
-
-        if (useStaticCatalog == null) {
-            useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE;
-        }
-
-        if (catalog == null || !useStaticCatalog.booleanValue()) {
-
-            try {
-                String catalogClassName = getCatalogClassName();
-
-                if (catalogClassName == null) {
-                    catalog = new Catalog();
-                } else {
-                    try {
-                        catalog = (Catalog) ReflectUtil.forName(catalogClassName).newInstance();
-                    } catch (ClassNotFoundException cnfe) {
-                        debug.message(1,"Catalog class named '"
-                                + catalogClassName
-                                + "' could not be found. Using default.");
-                        catalog = new Catalog();
-                    } catch (ClassCastException cnfe) {
-                        debug.message(1,"Class named '"
-                                + catalogClassName
-                                + "' is not a Catalog. Using default.");
-                        catalog = new Catalog();
-                    }
-                }
-
-                catalog.setCatalogManager(this);
-                catalog.setupReaders();
-                catalog.loadSystemCatalogs();
-            } catch (Exception ex) {
-                ex.printStackTrace();
-            }
-
-            if (useStaticCatalog.booleanValue()) {
-                staticCatalog = catalog;
-            }
-        }
-
-        return catalog;
-    }
-
-    /**
-     * Get a catalog instance.
-     *
-     * If this manager uses static catalogs, the same static catalog will
-     * always be returned. Otherwise a new catalog will be returned.
-     */
-    public Catalog getCatalog() {
-        Catalog catalog = staticCatalog;
-
-        if (useStaticCatalog == null) {
-            useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE;
-        }
-
-        if (catalog == null || !useStaticCatalog.booleanValue()) {
-            catalog = getPrivateCatalog();
-            if (useStaticCatalog.booleanValue()) {
-                staticCatalog = catalog;
-            }
-        }
-
-        return catalog;
-    }
-
-    /**
-     * <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
-     *
-     * <p>In the properties, a value of 'yes', 'true', or '1' is considered
-     * true, anything else is false.</p>
-     *
-     * @return The oasisXMLCatalogPI setting from the propertyFile or the
-     * defaultOasisXMLCatalogPI.
-     */
-    public boolean queryAllowOasisXMLCatalogPI () {
-        String allow = SecuritySupport.getSystemProperty(pAllowPI);
-
-        if (allow == null) {
-            if (resources==null) readProperties();
-            if (resources==null) return defaultOasisXMLCatalogPI;
-            try {
-                allow = resources.getString("allow-oasis-xml-catalog-pi");
-            } catch (MissingResourceException e) {
-                return defaultOasisXMLCatalogPI;
-            }
-        }
-
-        if (allow == null) {
-            return defaultOasisXMLCatalogPI;
-        }
-
-        return (allow.equalsIgnoreCase("true")
-                || allow.equalsIgnoreCase("yes")
-                || allow.equalsIgnoreCase("1"));
-    }
-
-    /**
-     * Get the current XML Catalog PI setting.
-     */
-    public boolean getAllowOasisXMLCatalogPI () {
-        if (oasisXMLCatalogPI == null) {
-            oasisXMLCatalogPI = queryAllowOasisXMLCatalogPI() ? Boolean.TRUE : Boolean.FALSE;
-        }
-
-        return oasisXMLCatalogPI.booleanValue();
-    }
-
-    public boolean useServicesMechanism() {
-        return useServicesMechanism;
-    }
-    /**
-     * Set the XML Catalog PI setting
-     */
-    public void setAllowOasisXMLCatalogPI(boolean allowPI) {
-        oasisXMLCatalogPI = allowPI ? Boolean.TRUE : Boolean.FALSE;
-    }
-
-    /**
-     * Get the current XML Catalog PI setting.
-     *
-     * @deprecated No longer static; use get/set methods.
-     */
-    public boolean allowOasisXMLCatalogPI() {
-        return getAllowOasisXMLCatalogPI();
-    }
-
-    /**
-     * Obtain the Catalog class name setting from the properties.
-     *
-     */
-    public String queryCatalogClassName () {
-        String className = SecuritySupport.getSystemProperty(pClassname);
-
-        if (className == null) {
-            if (resources==null) readProperties();
-            if (resources==null) return null;
-            try {
-                return resources.getString("catalog-class-name");
-            } catch (MissingResourceException e) {
-                return null;
-            }
-        }
-
-        return className;
-    }
-
-    /**
-     * Get the current Catalog class name.
-     */
-    public String getCatalogClassName() {
-        if (catalogClassName == null) {
-            catalogClassName = queryCatalogClassName();
-        }
-
-        return catalogClassName;
-    }
-
-    /**
-     * Set the Catalog class name.
-     */
-    public void setCatalogClassName(String className) {
-        catalogClassName = className;
-    }
-
-    /**
-     * Get the current Catalog class name.
-     *
-     * @deprecated No longer static; use get/set methods.
-     */
-    public String catalogClassName() {
-        return getCatalogClassName();
-    }
-}
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java	Wed Jun 28 11:27:28 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,697 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xml.internal.resolver;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.FileNotFoundException;
-import java.util.Enumeration;
-import java.util.Vector;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.MalformedURLException;
-import javax.xml.parsers.SAXParserFactory;
-import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
-import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader;
-import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader;
-import com.sun.org.apache.xml.internal.resolver.readers.TR9401CatalogReader;
-
-/**
- * An extension to OASIS Open Catalog files, this class supports
- * suffix-based matching and an external RFC2483 resolver.
- *
- * @see Catalog
- * @deprecated The JDK internal Catalog API in package
- * {@code com.sun.org.apache.xml.internal.resolver}
- * is encapsulated in JDK 9. The entire implementation under the package is now
- * deprecated and subject to removal in a future release. Users of the API
- * should migrate to the {@linkplain javax.xml.catalog new public API}.
- * <p>
- * The new Catalog API is supported throughout the JDK XML Processors, which allows
- * the use of Catalog by simply setting a path to a Catalog file as a property.
- *
- * @author Norman Walsh
- * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
- *
- * @version 1.0
- */
-@Deprecated(since="9", forRemoval=true)
-public class Resolver extends Catalog {
-  /**
-   * The URISUFFIX Catalog Entry type.
-   *
-   * <p>URI suffix entries match URIs that end in a specified suffix.</p>
-   */
-  public static final int URISUFFIX = CatalogEntry.addEntryType("URISUFFIX", 2);
-
-  /**
-   * The SYSTEMSUFFIX Catalog Entry type.
-   *
-   * <p>System suffix entries match system identifiers that end in a
-   * specified suffix.</p>
-   */
-  public static final int SYSTEMSUFFIX = CatalogEntry.addEntryType("SYSTEMSUFFIX", 2);
-
-  /**
-   * The RESOLVER Catalog Entry type.
-   *
-   * <p>A hook for providing support for web-based backup resolvers.</p>
-   */
-  public static final int RESOLVER = CatalogEntry.addEntryType("RESOLVER", 1);
-
-  /**
-   * The SYSTEMREVERSE Catalog Entry type.
-   *
-   * <p>This is a bit of a hack. There's no actual SYSTEMREVERSE entry,
-   * but this entry type is used to indicate that a reverse lookup is
-   * being performed. (This allows the Resolver to implement
-   * RFC2483 I2N and I2NS.)
-   */
-  public static final int SYSTEMREVERSE
-    = CatalogEntry.addEntryType("SYSTEMREVERSE", 1);
-
-  /**
-   * Setup readers.
-   */
-  public void setupReaders() {
-    SAXParserFactory spf = catalogManager.useServicesMechanism() ?
-                    SAXParserFactory.newInstance() : new SAXParserFactoryImpl();
-    spf.setNamespaceAware(true);
-    spf.setValidating(false);
-
-    SAXCatalogReader saxReader = new SAXCatalogReader(spf);
-
-    saxReader.setCatalogParser(null, "XCatalog",
-                               "com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader");
-
-    saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName,
-                               "catalog",
-                               "com.sun.org.apache.xml.internal.resolver.readers.ExtendedXMLCatalogReader");
-
-    addReader("application/xml", saxReader);
-
-    TR9401CatalogReader textReader = new TR9401CatalogReader();
-    addReader("text/plain", textReader);
-  }
-
-  /**
-   * Cleanup and process a Catalog entry.
-   *
-   * <p>This method processes each Catalog entry, changing mapped
-   * relative system identifiers into absolute ones (based on the current
-   * base URI), and maintaining other information about the current
-   * catalog.</p>
-   *
-   * @param entry The CatalogEntry to process.
-   */
-  public void addEntry(CatalogEntry entry) {
-    int type = entry.getEntryType();
-
-    if (type == URISUFFIX) {
-      String suffix = normalizeURI(entry.getEntryArg(0));
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "URISUFFIX", suffix, fsi);
-    } else if (type == SYSTEMSUFFIX) {
-      String suffix = normalizeURI(entry.getEntryArg(0));
-      String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
-
-      entry.setEntryArg(1, fsi);
-
-      catalogManager.debug.message(4, "SYSTEMSUFFIX", suffix, fsi);
-    }
-
-    super.addEntry(entry);
-  }
-
-  /**
-   * Return the applicable URI.
-   *
-   * <p>If a URI entry exists in the Catalog
-   * for the URI specified, return the mapped value.</p>
-   *
-   * <p>In the Resolver (as opposed to the Catalog) class, if the
-   * URI isn't found by the usual algorithm, URISUFFIX entries are
-   * considered.</p>
-   *
-   * <p>URI comparison is case sensitive.</p>
-   *
-   * @param uri The URI to locate in the catalog.
-   *
-   * @return The resolved URI.
-   *
-   * @throws MalformedURLException The system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   */
-  public String resolveURI(String uri)
-    throws MalformedURLException, IOException {
-
-    String resolved = super.resolveURI(uri);
-    if (resolved != null) {
-      return resolved;
-    }
-
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == RESOLVER) {
-        resolved = resolveExternalSystem(uri, e.getEntryArg(0));
-        if (resolved != null) {
-          return resolved;
-        }
-      } else if (e.getEntryType() == URISUFFIX) {
-        String suffix = e.getEntryArg(0);
-        String result = e.getEntryArg(1);
-
-        if (suffix.length() <= uri.length()
-            && uri.substring(uri.length()-suffix.length()).equals(suffix)) {
-          return result;
-        }
-      }
-    }
-
-    // Otherwise, look in the subordinate catalogs
-    return resolveSubordinateCatalogs(Catalog.URI,
-                                      null,
-                                      null,
-                                      uri);
-  }
-
-  /**
-   * Return the applicable SYSTEM system identifier, resorting
-   * to external RESOLVERs if necessary.
-   *
-   * <p>If a SYSTEM entry exists in the Catalog
-   * for the system ID specified, return the mapped value.</p>
-   *
-   * <p>In the Resolver (as opposed to the Catalog) class, if the
-   * URI isn't found by the usual algorithm, SYSTEMSUFFIX entries are
-   * considered.</p>
-   *
-   * <p>On Windows-based operating systems, the comparison between
-   * the system identifier provided and the SYSTEM entries in the
-   * Catalog is case-insensitive.</p>
-   *
-   * @param systemId The system ID to locate in the catalog.
-   *
-   * @return The system identifier to use for systemId.
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   */
-  public String resolveSystem(String systemId)
-    throws MalformedURLException, IOException {
-
-    String resolved = super.resolveSystem(systemId);
-    if (resolved != null) {
-      return resolved;
-    }
-
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == RESOLVER) {
-        resolved = resolveExternalSystem(systemId, e.getEntryArg(0));
-        if (resolved != null) {
-          return resolved;
-        }
-      } else if (e.getEntryType() == SYSTEMSUFFIX) {
-        String suffix = e.getEntryArg(0);
-        String result = e.getEntryArg(1);
-
-        if (suffix.length() <= systemId.length()
-            && systemId.substring(systemId.length()-suffix.length()).equals(suffix)) {
-          return result;
-        }
-      }
-    }
-
-    return resolveSubordinateCatalogs(Catalog.SYSTEM,
-                                      null,
-                                      null,
-                                      systemId);
-  }
-
-  /**
-   * Return the applicable PUBLIC or SYSTEM identifier, resorting
-   * to external resolvers if necessary.
-   *
-   * <p>This method searches the Catalog and returns the system
-   * identifier specified for the given system or
-   * public identifiers. If
-   * no appropriate PUBLIC or SYSTEM entry is found in the Catalog,
-   * null is returned.</p>
-   *
-   * <p>Note that a system or public identifier in the current catalog
-   * (or subordinate catalogs) will be used in preference to an
-   * external resolver. Further, if a systemId is present, the external
-   * resolver(s) will be queried for that before the publicId.</p>
-   *
-   * @param publicId The public identifier to locate in the catalog.
-   * Public identifiers are normalized before comparison.
-   * @param systemId The nominal system identifier for the entity
-   * in question (as provided in the source document).
-   *
-   * @throws MalformedURLException The formal system identifier of a
-   * subordinate catalog cannot be turned into a valid URL.
-   * @throws IOException Error reading subordinate catalog file.
-   *
-   * @return The system identifier to use.
-   * Note that the nominal system identifier is not returned if a
-   * match is not found in the catalog, instead null is returned
-   * to indicate that no match was found.
-   */
-  public String resolvePublic(String publicId, String systemId)
-    throws MalformedURLException, IOException {
-
-    String resolved = super.resolvePublic(publicId, systemId);
-    if (resolved != null) {
-      return resolved;
-    }
-
-    Enumeration en = catalogEntries.elements();
-    while (en.hasMoreElements()) {
-      CatalogEntry e = (CatalogEntry) en.nextElement();
-      if (e.getEntryType() == RESOLVER) {
-        if (systemId != null) {
-          resolved = resolveExternalSystem(systemId,
-                                           e.getEntryArg(0));
-          if (resolved != null) {
-            return resolved;
-          }
-        }
-        resolved = resolveExternalPublic(publicId, e.getEntryArg(0));
-        if (resolved != null) {
-          return resolved;
-        }
-      }
-    }
-
-    return resolveSubordinateCatalogs(Catalog.PUBLIC,
-                                      null,
-                                      publicId,
-                                      systemId);
-  }
-
-    /**
-     * Query an external RFC2483 resolver for a system identifier.
-     *
-     * @param systemId The system ID to locate.
-     * @param resolver The name of the resolver to use.
-     *
-     * @return The system identifier to use for the systemId.
-     */
-    protected String resolveExternalSystem(String systemId, String resolver)
-        throws MalformedURLException, IOException {
-        Resolver r = queryResolver(resolver, "i2l", systemId, null);
-        if (r != null) {
-            return r.resolveSystem(systemId);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Query an external RFC2483 resolver for a public identifier.
-     *
-     * @param publicId The system ID to locate.
-     * @param resolver The name of the resolver to use.
-     *
-     * @return The system identifier to use for the systemId.
-     */
-    protected String resolveExternalPublic(String publicId, String resolver)
-        throws MalformedURLException, IOException {
-        Resolver r = queryResolver(resolver, "fpi2l", publicId, null);
-        if (r != null) {
-            return r.resolvePublic(publicId, null);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Query an external RFC2483 resolver.
-     *
-     * @param resolver The URL of the RFC2483 resolver.
-     * @param command The command to send the resolver.
-     * @param arg1 The first argument to the resolver.
-     * @param arg2 The second argument to the resolver, usually null.
-     *
-     * @return The Resolver constructed.
-     */
-    protected Resolver queryResolver(String resolver,
-                                     String command,
-                                     String arg1,
-                                     String arg2) {
-        InputStream iStream = null;
-        String RFC2483 = resolver + "?command=" + command
-            + "&format=tr9401&uri=" + arg1
-            + "&uri2=" + arg2;
-        String line = null;
-
-        try {
-            URL url = new URL(RFC2483);
-
-            URLConnection urlCon = url.openConnection();
-
-            urlCon.setUseCaches(false);
-
-            Resolver r = (Resolver) newCatalog();
-
-            String cType = urlCon.getContentType();
-
-            // I don't care about the character set or subtype
-            if (cType.indexOf(";") > 0) {
-                cType = cType.substring(0, cType.indexOf(";"));
-            }
-
-            r.parseCatalog(cType, urlCon.getInputStream());
-
-            return r;
-        } catch (CatalogException cex) {
-          if (cex.getExceptionType() == CatalogException.UNPARSEABLE) {
-            catalogManager.debug.message(1, "Unparseable catalog: " + RFC2483);
-          } else if (cex.getExceptionType()
-                     == CatalogException.UNKNOWN_FORMAT) {
-            catalogManager.debug.message(1, "Unknown catalog format: " + RFC2483);
-          }
-          return null;
-        } catch (MalformedURLException mue) {
-            catalogManager.debug.message(1, "Malformed resolver URL: " + RFC2483);
-            return null;
-        } catch (IOException ie) {
-            catalogManager.debug.message(1, "I/O Exception opening resolver: " + RFC2483);
-            return null;
-        }
-    }
-
-    /**
-     * Append two vectors, returning the result.
-     *
-     * @param vec The first vector
-     * @param appvec The vector to be appended
-     * @return The vector vec, with appvec's elements appended to it
-     */
-    private Vector appendVector(Vector vec, Vector appvec) {
-        if (appvec != null) {
-            for (int count = 0; count < appvec.size(); count++) {
-                vec.addElement(appvec.elementAt(count));
-            }
-        }
-        return vec;
-    }
-
-    /**
-     * Find the URNs for a given system identifier in all catalogs.
-     *
-     * @param systemId The system ID to locate.
-     *
-     * @return A vector of URNs that map to the systemId.
-     */
-    public Vector resolveAllSystemReverse(String systemId)
-        throws MalformedURLException, IOException {
-        Vector resolved = new Vector();
-
-        // If there's a SYSTEM entry in this catalog, use it
-        if (systemId != null) {
-            Vector localResolved = resolveLocalSystemReverse(systemId);
-            resolved = appendVector(resolved, localResolved);
-        }
-
-        // Otherwise, look in the subordinate catalogs
-        Vector subResolved = resolveAllSubordinateCatalogs(SYSTEMREVERSE,
-                                                           null,
-                                                           null,
-                                                           systemId);
-
-        return appendVector(resolved, subResolved);
-    }
-
-    /**
-     * Find the URN for a given system identifier.
-     *
-     * @param systemId The system ID to locate.
-     *
-     * @return A (single) URN that maps to the systemId.
-     */
-    public String resolveSystemReverse(String systemId)
-        throws MalformedURLException, IOException {
-        Vector resolved = resolveAllSystemReverse(systemId);
-        if (resolved != null && resolved.size() > 0) {
-            return (String) resolved.elementAt(0);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Return the applicable SYSTEM system identifiers.
-     *
-     * <p>If one or more SYSTEM entries exists in the Catalog
-     * for the system ID specified, return the mapped values.</p>
-     *
-     * <p>The caller is responsible for doing any necessary
-     * normalization of the system identifier before calling
-     * this met