langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
changeset 40308 274367a99f98
parent 40302 8c0d8d2c3519
child 40513 39b67170b045
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Wed Aug 10 13:52:02 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Wed Aug 10 15:47:46 2016 -0700
@@ -84,7 +84,7 @@
 
 import static javax.tools.StandardLocation.PLATFORM_CLASS_PATH;
 
-import static com.sun.tools.javac.main.Option.BOOTCLASSPATH;
+import static com.sun.tools.javac.main.Option.BOOT_CLASS_PATH;
 import static com.sun.tools.javac.main.Option.DJAVA_ENDORSED_DIRS;
 import static com.sun.tools.javac.main.Option.DJAVA_EXT_DIRS;
 import static com.sun.tools.javac.main.Option.ENDORSEDDIRS;
@@ -580,8 +580,7 @@
     private class ClassPathLocationHandler extends SimpleLocationHandler {
 
         ClassPathLocationHandler() {
-            super(StandardLocation.CLASS_PATH,
-                    Option.CLASSPATH, Option.CP);
+            super(StandardLocation.CLASS_PATH, Option.CLASS_PATH);
         }
 
         @Override
@@ -649,7 +648,7 @@
 
         BootClassPathLocationHandler() {
             super(StandardLocation.PLATFORM_CLASS_PATH,
-                    Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
+                    Option.BOOT_CLASS_PATH, Option.XBOOTCLASSPATH,
                     Option.XBOOTCLASSPATH_PREPEND,
                     Option.XBOOTCLASSPATH_APPEND,
                     Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
@@ -669,7 +668,7 @@
 
             option = canonicalize(option);
             optionValues.put(option, value);
-            if (option == BOOTCLASSPATH) {
+            if (option == BOOT_CLASS_PATH) {
                 optionValues.remove(XBOOTCLASSPATH_PREPEND);
                 optionValues.remove(XBOOTCLASSPATH_APPEND);
             }
@@ -682,7 +681,7 @@
         private Option canonicalize(Option option) {
             switch (option) {
                 case XBOOTCLASSPATH:
-                    return Option.BOOTCLASSPATH;
+                    return Option.BOOT_CLASS_PATH;
                 case DJAVA_ENDORSED_DIRS:
                     return Option.ENDORSEDDIRS;
                 case DJAVA_EXT_DIRS:
@@ -713,7 +712,7 @@
         SearchPath computePath() throws IOException {
             SearchPath path = new SearchPath();
 
-            String bootclasspathOpt = optionValues.get(BOOTCLASSPATH);
+            String bootclasspathOpt = optionValues.get(BOOT_CLASS_PATH);
             String endorseddirsOpt = optionValues.get(ENDORSEDDIRS);
             String extdirsOpt = optionValues.get(EXTDIRS);
             String xbootclasspathPrependOpt = optionValues.get(XBOOTCLASSPATH_PREPEND);
@@ -1141,7 +1140,7 @@
 
         ModuleSourcePathLocationHandler() {
             super(StandardLocation.MODULE_SOURCE_PATH,
-                    Option.MODULESOURCEPATH);
+                    Option.MODULE_SOURCE_PATH);
         }
 
         @Override
@@ -1473,16 +1472,16 @@
         BasicLocationHandler[] handlers = {
             new BootClassPathLocationHandler(),
             new ClassPathLocationHandler(),
-            new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCEPATH),
-            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSORPATH),
-            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, Option.PROCESSORMODULEPATH),
+            new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCE_PATH),
+            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSOR_PATH),
+            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, Option.PROCESSOR_MODULE_PATH),
             new OutputLocationHandler(StandardLocation.CLASS_OUTPUT, Option.D),
             new OutputLocationHandler(StandardLocation.SOURCE_OUTPUT, Option.S),
             new OutputLocationHandler(StandardLocation.NATIVE_HEADER_OUTPUT, Option.H),
             new ModuleSourcePathLocationHandler(),
             // TODO: should UPGRADE_MODULE_PATH be merged with SYSTEM_MODULES?
-            new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADEMODULEPATH),
-            new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULEPATH, Option.MP),
+            new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADE_MODULE_PATH),
+            new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULE_PATH),
             new SystemModulesLocationHandler(),
         };
 
@@ -1498,29 +1497,42 @@
 
     boolean handleOption(Option option, String value) {
         switch (option) {
-            case XPATCH:
-                Map<String, SearchPath> map = new LinkedHashMap<>();
-                int eq = value.indexOf('=');
-                if (eq > 0) {
-                    String mName = value.substring(0, eq);
-                    SearchPath mPatchPath = new SearchPath()
-                            .addFiles(value.substring(eq + 1));
-                    boolean ok = true;
-                    for (Path p: mPatchPath) {
-                        Path mi = p.resolve("module-info.class");
-                        if (Files.exists(mi)) {
-                            log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(mi));
-                            ok = false;
+            case PATCH_MODULE:
+                if (value == null) {
+                    patchMap = null;
+                } else {
+                    // Allow an extended syntax for --patch-module consisting of a series
+                    // of values separated by NULL characters. This is to facilitate
+                    // supporting deferred file manager options on the command line.
+                    // See Option.PATCH_MODULE for the code that composes these multiple
+                    // values.
+                    for (String v : value.split("\0")) {
+                        int eq = v.indexOf('=');
+                        if (eq > 0) {
+                            String mName = v.substring(0, eq);
+                            SearchPath mPatchPath = new SearchPath()
+                                    .addFiles(v.substring(eq + 1));
+                            boolean ok = true;
+                            for (Path p : mPatchPath) {
+                                Path mi = p.resolve("module-info.class");
+                                if (Files.exists(mi)) {
+                                    log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(mi));
+                                    ok = false;
+                                }
+                            }
+                            if (ok) {
+                                if (patchMap == null) {
+                                    patchMap = new LinkedHashMap<>();
+                                }
+                                patchMap.put(mName, mPatchPath);
+                            }
+                        } else {
+                            // Should not be able to get here;
+                            // this should be caught and handled in Option.PATCH_MODULE
+                            log.error(Errors.LocnInvalidArgForXpatch(value));
                         }
                     }
-                    if (ok && !mPatchPath.isEmpty()) {
-                        map.computeIfAbsent(mName, (_x) -> new SearchPath())
-                                .addAll(mPatchPath);
-                    }
-                } else {
-                    log.error(Errors.LocnInvalidArgForXpatch(value));
                 }
-                patchMap = map;
                 return true;
             default:
                 LocationHandler h = handlersForOption.get(option);