8017248: Compiler Diacritics Issue

Thu, 19 Sep 2013 17:05:32 +0400

author
kizune
date
Thu, 19 Sep 2013 17:05:32 +0400
changeset 2037
36e342dd57e2
parent 2036
8df12c315ea3
child 2038
8d1c48de706d

8017248: Compiler Diacritics Issue
Reviewed-by: naoto

src/share/classes/com/sun/tools/javac/file/RegularFileObject.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Wed Sep 18 22:47:06 2013 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Thu Sep 19 17:05:32 2013 +0400
     1.3 @@ -40,6 +40,7 @@
     1.4  import java.nio.CharBuffer;
     1.5  import java.nio.charset.CharsetDecoder;
     1.6  import javax.tools.JavaFileObject;
     1.7 +import java.text.Normalizer;
     1.8  
     1.9  /**
    1.10   * A subclass of JavaFileObject representing regular files.
    1.11 @@ -57,6 +58,7 @@
    1.12      private String name;
    1.13      final File file;
    1.14      private Reference<File> absFileRef;
    1.15 +    final static boolean isMacOS = System.getProperty("os.name", "").contains("OS X");
    1.16  
    1.17      public RegularFileObject(JavacFileManager fileManager, File f) {
    1.18          this(fileManager, f.getName(), f);
    1.19 @@ -180,7 +182,19 @@
    1.20          if (name.equals(n)) {
    1.21              return true;
    1.22          }
    1.23 -        if (name.equalsIgnoreCase(n)) {
    1.24 +        if (isMacOS && Normalizer.isNormalized(name, Normalizer.Form.NFD)
    1.25 +            && Normalizer.isNormalized(n, Normalizer.Form.NFC)) {
    1.26 +            // On Mac OS X it is quite possible to file name and class
    1.27 +            // name normalized in a different way - in that case we have to normalize file name
    1.28 +            // to the Normal Form Compised (NFC)
    1.29 +            String normName = Normalizer.normalize(name, Normalizer.Form.NFC);
    1.30 +            if (normName.equals(n)) {
    1.31 +                this.name = normName;
    1.32 +                return true;
    1.33 +            }
    1.34 +        }
    1.35 +
    1.36 +            if (name.equalsIgnoreCase(n)) {
    1.37              try {
    1.38                  // allow for Windows
    1.39                  return file.getCanonicalFile().getName().equals(n);

mercurial