langtools/src/share/classes/com/sun/tools/javac/file/Locations.java
changeset 14360 2a8304e421ed
parent 14259 fb94a1df0d53
child 22153 f9f06fcca59d
equal deleted inserted replaced
14359:d4099818ab70 14360:2a8304e421ed
   418         @Override
   418         @Override
   419         boolean handleOption(Option option, String value) {
   419         boolean handleOption(Option option, String value) {
   420             if (!options.contains(option))
   420             if (!options.contains(option))
   421                 return false;
   421                 return false;
   422             searchPath = value == null ? null :
   422             searchPath = value == null ? null :
   423                     Collections.unmodifiableCollection(computePath(value));
   423                     Collections.unmodifiableCollection(createPath().addFiles(value));
   424             return true;
   424             return true;
   425         }
       
   426 
       
   427         protected Path computePath(String value) {
       
   428             return new Path().addFiles(value);
       
   429         }
   425         }
   430 
   426 
   431         @Override
   427         @Override
   432         Collection<File> getLocation() {
   428         Collection<File> getLocation() {
   433             return searchPath;
   429             return searchPath;
   437         void setLocation(Iterable<? extends File> files) {
   433         void setLocation(Iterable<? extends File> files) {
   438             Path p;
   434             Path p;
   439             if (files == null) {
   435             if (files == null) {
   440                 p = computePath(null);
   436                 p = computePath(null);
   441             } else {
   437             } else {
   442                 p = new Path().addFiles(files);
   438                 p = createPath().addFiles(files);
   443             }
   439             }
   444             searchPath = Collections.unmodifiableCollection(p);
   440             searchPath = Collections.unmodifiableCollection(p);
       
   441         }
       
   442 
       
   443         protected Path computePath(String value) {
       
   444             return createPath().addFiles(value);
       
   445         }
       
   446 
       
   447         protected Path createPath() {
       
   448             return new Path();
   445         }
   449         }
   446     }
   450     }
   447 
   451 
   448     /**
   452     /**
   449      * Subtype of SimpleLocationHandler for -classpath/CLASS_PATH.
   453      * Subtype of SimpleLocationHandler for -classpath/CLASS_PATH.
   475                 cp = System.getProperty("java.class.path");
   479                 cp = System.getProperty("java.class.path");
   476 
   480 
   477             // Default to current working directory.
   481             // Default to current working directory.
   478             if (cp == null) cp = ".";
   482             if (cp == null) cp = ".";
   479 
   483 
       
   484             return createPath().addFiles(cp);
       
   485         }
       
   486 
       
   487         @Override
       
   488         protected Path createPath() {
   480             return new Path()
   489             return new Path()
   481                 .expandJarClassPaths(true)        // Only search user jars for Class-Paths
   490                 .expandJarClassPaths(true)         // Only search user jars for Class-Paths
   482                 .emptyPathDefault(new File("."))  // Empty path elt ==> current directory
   491                 .emptyPathDefault(new File("."));  // Empty path elt ==> current directory
   483                 .addFiles(cp);
   492         }
   484             }
       
   485 
   493 
   486         private void lazy() {
   494         private void lazy() {
   487             if (searchPath == null)
   495             if (searchPath == null)
   488                 setLocation(null);
   496                 setLocation(null);
   489         }
   497         }
   589             String bootclasspathOpt = optionValues.get(BOOTCLASSPATH);
   597             String bootclasspathOpt = optionValues.get(BOOTCLASSPATH);
   590             String endorseddirsOpt = optionValues.get(ENDORSEDDIRS);
   598             String endorseddirsOpt = optionValues.get(ENDORSEDDIRS);
   591             String extdirsOpt = optionValues.get(EXTDIRS);
   599             String extdirsOpt = optionValues.get(EXTDIRS);
   592             String xbootclasspathPrependOpt = optionValues.get(XBOOTCLASSPATH_PREPEND);
   600             String xbootclasspathPrependOpt = optionValues.get(XBOOTCLASSPATH_PREPEND);
   593             String xbootclasspathAppendOpt = optionValues.get(XBOOTCLASSPATH_APPEND);
   601             String xbootclasspathAppendOpt = optionValues.get(XBOOTCLASSPATH_APPEND);
   594 
       
   595             path.addFiles(xbootclasspathPrependOpt);
   602             path.addFiles(xbootclasspathPrependOpt);
   596 
   603 
   597             if (endorseddirsOpt != null)
   604             if (endorseddirsOpt != null)
   598                 path.addDirectories(endorseddirsOpt);
   605                 path.addDirectories(endorseddirsOpt);
   599             else
   606             else