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

changeset 400
35e29f51a7c3
parent 372
7dbb79875a63
child 404
14735c7932d7
child 415
49359d0e6a9c
     1.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Sep 03 18:34:17 2009 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Tue Sep 08 11:12:13 2009 -0700
     1.3 @@ -26,6 +26,7 @@
     1.4  package com.sun.tools.javac.file;
     1.5  
     1.6  import java.io.ByteArrayOutputStream;
     1.7 +import java.io.Closeable;
     1.8  import java.io.File;
     1.9  import java.io.FileInputStream;
    1.10  import java.io.FileNotFoundException;
    1.11 @@ -36,6 +37,7 @@
    1.12  import java.lang.reflect.Constructor;
    1.13  import java.net.MalformedURLException;
    1.14  import java.net.URI;
    1.15 +import java.net.URISyntaxException;
    1.16  import java.net.URL;
    1.17  import java.net.URLClassLoader;
    1.18  import java.nio.ByteBuffer;
    1.19 @@ -77,7 +79,6 @@
    1.20  import com.sun.tools.javac.util.Log;
    1.21  import com.sun.tools.javac.util.Options;
    1.22  
    1.23 -import java.io.Closeable;
    1.24  import static javax.tools.StandardLocation.*;
    1.25  import static com.sun.tools.javac.main.OptionName.*;
    1.26  
    1.27 @@ -437,6 +438,7 @@
    1.28              return Collections.emptySet();
    1.29          }
    1.30  
    1.31 +        @Override
    1.32          public String toString() {
    1.33              return "MissingArchive[" + zipFileName + "]";
    1.34          }
    1.35 @@ -654,10 +656,10 @@
    1.36      private final ByteBufferCache byteBufferCache;
    1.37  
    1.38      CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
    1.39 -        Charset charset = (this.charset == null)
    1.40 +        Charset cs = (this.charset == null)
    1.41              ? Charset.forName(encodingName)
    1.42              : this.charset;
    1.43 -        CharsetDecoder decoder = charset.newDecoder();
    1.44 +        CharsetDecoder decoder = cs.newDecoder();
    1.45  
    1.46          CodingErrorAction action;
    1.47          if (ignoreEncodingErrors)
    1.48 @@ -892,7 +894,7 @@
    1.49          nullCheck(location);
    1.50          // validatePackageName(packageName);
    1.51          nullCheck(packageName);
    1.52 -        if (!isRelativeUri(URI.create(relativeName))) // FIXME 6419701
    1.53 +        if (!isRelativeUri(relativeName))
    1.54              throw new IllegalArgumentException("Invalid relative name: " + relativeName);
    1.55          RelativeFile name = packageName.length() == 0
    1.56              ? new RelativeFile(relativeName)
    1.57 @@ -946,7 +948,7 @@
    1.58          nullCheck(location);
    1.59          // validatePackageName(packageName);
    1.60          nullCheck(packageName);
    1.61 -        if (!isRelativeUri(URI.create(relativeName))) // FIXME 6419701
    1.62 +        if (!isRelativeUri(relativeName))
    1.63              throw new IllegalArgumentException("relativeName is invalid");
    1.64          RelativeFile name = packageName.length() == 0
    1.65              ? new RelativeFile(relativeName)
    1.66 @@ -1085,6 +1087,15 @@
    1.67          return first != '.' && first != '/';
    1.68      }
    1.69  
    1.70 +    // Convenience method
    1.71 +    protected static boolean isRelativeUri(String u) {
    1.72 +        try {
    1.73 +            return isRelativeUri(new URI(u));
    1.74 +        } catch (URISyntaxException e) {
    1.75 +            return false;
    1.76 +        }
    1.77 +    }
    1.78 +
    1.79      /**
    1.80       * Converts a relative file name to a relative URI.  This is
    1.81       * different from File.toURI as this method does not canonicalize
    1.82 @@ -1099,7 +1110,7 @@
    1.83      public static String getRelativeName(File file) {
    1.84          if (!file.isAbsolute()) {
    1.85              String result = file.getPath().replace(File.separatorChar, '/');
    1.86 -            if (JavacFileManager.isRelativeUri(URI.create(result))) // FIXME 6419701
    1.87 +            if (isRelativeUri(result))
    1.88                  return result;
    1.89          }
    1.90          throw new IllegalArgumentException("Invalid relative path: " + file);

mercurial