src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
changeset 47702 cf8310446245
parent 47363 77c792d06646
child 47703 dbfac941197a
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Mon Oct 30 21:23:10 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Mon Nov 06 13:10:43 2017 +0100
@@ -452,6 +452,8 @@
             return (getPaths() != null);
         }
 
+        abstract boolean isExplicit();
+
         /**
          * @see StandardJavaFileManager#getLocation
          */
@@ -510,6 +512,8 @@
         final Location location;
         final Set<Option> options;
 
+        boolean explicit;
+
         /**
          * Create a handler. The location and options provide a way to map from a location or an
          * option to the corresponding handler.
@@ -554,6 +558,12 @@
             }
             return path;
         }
+
+        @Override
+        boolean isExplicit() {
+            return explicit;
+        }
+
     }
 
     /**
@@ -576,6 +586,8 @@
                 return false;
             }
 
+            explicit = true;
+
             // TODO: could/should validate outputDir exists and is a directory
             // need to decide how best to report issue for benefit of
             // direct API call on JavaFileManager.handleOption(specifies IAE)
@@ -594,6 +606,7 @@
             if (paths == null) {
                 outputDir = null;
             } else {
+                explicit = true;
                 outputDir = checkSingletonDirectory(paths);
             }
             moduleTable = null;
@@ -626,10 +639,11 @@
                 l = new ModuleLocationHandler(this, location.getName() + "[" + name + "]",
                         name, Collections.singletonList(out), true);
                 moduleTable.add(l);
-           } else {
+            } else {
                 l.searchPath = Collections.singletonList(out);
                 moduleTable.updatePaths(l);
             }
+            explicit = true;
         }
 
         @Override
@@ -685,6 +699,9 @@
             if (!options.contains(option)) {
                 return false;
             }
+
+            explicit = true;
+
             searchPath = value == null ? null
                     : Collections.unmodifiableCollection(createPath().addFiles(value));
             return true;
@@ -701,6 +718,7 @@
             if (files == null) {
                 p = computePath(null);
             } else {
+                explicit = true;
                 p = createPath().addFiles(files);
             }
             searchPath = Collections.unmodifiableCollection(p);
@@ -813,6 +831,8 @@
                 return false;
             }
 
+            explicit = true;
+
             option = canonicalize(option);
             optionValues.put(option, value);
             if (option == BOOT_CLASS_PATH) {
@@ -850,6 +870,7 @@
                 searchPath = null;  // reset to "uninitialized"
             } else {
                 isDefault = false;
+                explicit = true;
                 SearchPath p = new SearchPath().addFiles(files, false);
                 searchPath = Collections.unmodifiableCollection(p);
                 optionValues.clear();
@@ -996,6 +1017,11 @@
             return Collections.unmodifiableCollection(searchPath);
         }
 
+        @Override
+        boolean isExplicit() {
+            return true;
+        }
+
         @Override // defined by LocationHandler
         void setPaths(Iterable<? extends Path> paths) throws IOException {
             // defer to the parent to determine if this is acceptable
@@ -1179,6 +1205,7 @@
                 moduleTable.updatePaths(l);
             }
             l.explicit = true;
+            explicit = true;
         }
 
         private List<Path> checkPaths(Iterable<? extends Path> paths) throws IOException {
@@ -1498,6 +1525,7 @@
 
         @Override
         boolean handleOption(Option option, String value) {
+            explicit = true;
             init(value);
             return true;
         }
@@ -1681,6 +1709,7 @@
             }
 
             initModuleTable(map);
+            explicit = true;
             paths = Collections.unmodifiableList(newPaths);
         }
 
@@ -1703,6 +1732,7 @@
                 l.searchPath = validPaths;
                 moduleTable.updatePaths(l);
             }
+            explicit = true;
         }
 
         private List<Path> checkPaths(Iterable<? extends Path> paths) throws IOException {
@@ -1755,6 +1785,8 @@
                 return false;
             }
 
+            explicit = true;
+
             if (value == null) {
                 systemJavaHome = Locations.javaHome;
             } else if (value.equals("none")) {
@@ -1777,6 +1809,8 @@
             if (files == null) {
                 systemJavaHome = null;
             } else {
+                explicit = true;
+
                 Path dir = checkSingletonDirectory(files);
                 update(dir);
             }
@@ -1798,6 +1832,7 @@
                 l.searchPath = checkedPaths;
                 moduleTable.updatePaths(l);
             }
+            explicit = true;
         }
 
         private List<Path> checkPaths(Iterable<? extends Path> paths) throws IOException {
@@ -1918,6 +1953,8 @@
                 return false;
             }
 
+            explicit = true;
+
             moduleTable.clear();
 
             // Allow an extended syntax for --patch-module consisting of a series
@@ -2027,6 +2064,11 @@
         return (h == null ? false : h.isSet());
     }
 
+    boolean hasExplicitLocation(Location location) {
+        LocationHandler h = getHandler(location);
+        return (h == null ? false : h.isExplicit());
+    }
+
     Collection<Path> getLocation(Location location) {
         LocationHandler h = getHandler(location);
         return (h == null ? null : h.getPaths());