src/share/classes/com/sun/tools/javac/file/Paths.java

changeset 757
c44234f680da
parent 612
d1bd93028447
child 758
bcbc86cc5b31
     1.1 --- a/src/share/classes/com/sun/tools/javac/file/Paths.java	Mon Nov 29 10:09:48 2010 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/file/Paths.java	Mon Nov 29 14:15:36 2010 -0800
     1.3 @@ -114,6 +114,11 @@
     1.4       */
     1.5      private File bootClassPathRtJar = null;
     1.6  
     1.7 +    /**
     1.8 +     *  Is bootclasspath the default?
     1.9 +     */
    1.10 +    private boolean isDefaultBootClassPath;
    1.11 +
    1.12      Path getPathForLocation(Location location) {
    1.13          Path path = pathsForLocation.get(location);
    1.14          if (path == null)
    1.15 @@ -129,7 +134,7 @@
    1.16              if (location == CLASS_PATH)
    1.17                  p = computeUserClassPath();
    1.18              else if (location == PLATFORM_CLASS_PATH)
    1.19 -                p = computeBootClassPath();
    1.20 +                p = computeBootClassPath(); // sets isDefaultBootClassPath
    1.21              else if (location == ANNOTATION_PROCESSOR_PATH)
    1.22                  p = computeAnnotationProcessorPath();
    1.23              else if (location == SOURCE_PATH)
    1.24 @@ -138,6 +143,8 @@
    1.25                  // no defaults for other paths
    1.26                  p = null;
    1.27          } else {
    1.28 +            if (location == PLATFORM_CLASS_PATH)
    1.29 +                isDefaultBootClassPath = false;
    1.30              p = new Path();
    1.31              for (File f: path)
    1.32                  p.addFile(f, warn); // TODO: is use of warn appropriate?
    1.33 @@ -145,6 +152,11 @@
    1.34          pathsForLocation.put(location, p);
    1.35      }
    1.36  
    1.37 +    boolean isDefaultBootClassPath() {
    1.38 +        lazy();
    1.39 +        return isDefaultBootClassPath;
    1.40 +    }
    1.41 +
    1.42      protected void lazy() {
    1.43          if (!inited) {
    1.44              warn = lint.isEnabled(Lint.LintCategory.PATH);
    1.45 @@ -262,9 +274,10 @@
    1.46          }
    1.47  
    1.48          public Path addFiles(String files, boolean warn) {
    1.49 -            if (files != null)
    1.50 +            if (files != null) {
    1.51                  for (File file : getPathEntries(files, emptyPathDefault))
    1.52                      addFile(file, warn);
    1.53 +            }
    1.54              return this;
    1.55          }
    1.56  
    1.57 @@ -334,18 +347,23 @@
    1.58  
    1.59      private Path computeBootClassPath() {
    1.60          bootClassPathRtJar = null;
    1.61 -        String optionValue;
    1.62          Path path = new Path();
    1.63  
    1.64 -        path.addFiles(options.get(XBOOTCLASSPATH_PREPEND));
    1.65 +        String bootclasspathOpt = options.get(BOOTCLASSPATH);
    1.66 +        String endorseddirsOpt = options.get(ENDORSEDDIRS);
    1.67 +        String extdirsOpt = options.get(EXTDIRS);
    1.68 +        String xbootclasspathPrependOpt = options.get(XBOOTCLASSPATH_PREPEND);
    1.69 +        String xbootclasspathAppendOpt = options.get(XBOOTCLASSPATH_APPEND);
    1.70  
    1.71 -        if ((optionValue = options.get(ENDORSEDDIRS)) != null)
    1.72 -            path.addDirectories(optionValue);
    1.73 +        path.addFiles(xbootclasspathPrependOpt);
    1.74 +
    1.75 +        if (endorseddirsOpt != null)
    1.76 +            path.addDirectories(endorseddirsOpt);
    1.77          else
    1.78              path.addDirectories(System.getProperty("java.endorsed.dirs"), false);
    1.79  
    1.80 -        if ((optionValue = options.get(BOOTCLASSPATH)) != null) {
    1.81 -            path.addFiles(optionValue);
    1.82 +        if (bootclasspathOpt != null) {
    1.83 +            path.addFiles(bootclasspathOpt);
    1.84          } else {
    1.85              // Standard system classes for this compiler's release.
    1.86              String files = System.getProperty("sun.boot.class.path");
    1.87 @@ -357,16 +375,21 @@
    1.88              }
    1.89          }
    1.90  
    1.91 -        path.addFiles(options.get(XBOOTCLASSPATH_APPEND));
    1.92 +        path.addFiles(xbootclasspathAppendOpt);
    1.93  
    1.94          // Strictly speaking, standard extensions are not bootstrap
    1.95          // classes, but we treat them identically, so we'll pretend
    1.96          // that they are.
    1.97 -        if ((optionValue = options.get(EXTDIRS)) != null)
    1.98 -            path.addDirectories(optionValue);
    1.99 +        if (extdirsOpt != null)
   1.100 +            path.addDirectories(extdirsOpt);
   1.101          else
   1.102              path.addDirectories(System.getProperty("java.ext.dirs"), false);
   1.103  
   1.104 +        isDefaultBootClassPath =
   1.105 +                (xbootclasspathPrependOpt == null) &&
   1.106 +                (bootclasspathOpt == null) &&
   1.107 +                (xbootclasspathAppendOpt == null);
   1.108 +
   1.109          return path;
   1.110      }
   1.111  

mercurial