--- old/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java 2016-08-08 16:30:33.000000000 -0700 +++ new/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java 2016-08-08 16:30:32.000000000 -0700 @@ -58,7 +58,7 @@ /** - * Provides support for patching modules in the boot layer with -Xpatch. + * Provides support for patching modules in the boot layer with --patch-module. */ public final class ModulePatcher { @@ -66,28 +66,27 @@ private static final JavaLangModuleAccess JLMA = SharedSecrets.getJavaLangModuleAccess(); - // the prefix of the system properties that encode the value of -Xpatch - private static final String PATCH_PROPERTY_PREFIX = "jdk.launcher.patch."; + // the prefix of the system properties that encode the value of --patch-module + private static final String PATCH_PROPERTY_PREFIX = "jdk.module.patch."; // module name -> sequence of patches (directories or JAR files) private static final Map> PATCH_MAP = decodeProperties(); private ModulePatcher() { } - /** - * Decodes the values of -Xpatch options, returning a Map of module name to - * list of file paths. + * Decodes the values of --patch-module options, returning a Map of module + * name to list of file paths. * * @throws IllegalArgumentException if the the module name is missing or - * -Xpatch is used more than once to patch the same module + * --patch-module is used more than once to patch the same module */ private static Map> decodeProperties() { int index = 0; - String value = System.getProperty(PATCH_PROPERTY_PREFIX + index); + String value = getAndRemoveProperty(PATCH_PROPERTY_PREFIX + index); if (value == null) - return Collections.emptyMap(); // -Xpatch not specified + return Collections.emptyMap(); // --patch-module not specified Map> map = new HashMap<>(); while (value != null) { @@ -115,7 +114,7 @@ } index++; - value = System.getProperty(PATCH_PROPERTY_PREFIX + index); + value = getAndRemoveProperty(PATCH_PROPERTY_PREFIX + index); } return map; @@ -123,6 +122,14 @@ /** + * Returns {@code true} is --patch-module is specified to patch modules + * in the boot layer. + */ + static boolean isBootLayerPatched() { + return !PATCH_MAP.isEmpty(); + } + + /** * Returns a module reference that interposes on the given module if * needed. If there are no patches for the given module then the module * reference is simply returned. Otherwise the patches for the module @@ -537,6 +544,13 @@ } /** + * Gets and remove the named system property + */ + private static String getAndRemoveProperty(String key) { + return (String)System.getProperties().remove(key); + } + + /** * Derives a package name from the name of an entry in a JAR file. */ private static String toPackageName(Path file, JarEntry entry) {