langtools/test/tools/javac/6589361/T6589361.java
author jjg
Wed, 23 Sep 2009 18:48:13 -0700
changeset 3995 73af8b6fb8bc
parent 3774 33a6953bed15
child 30730 d3ce7619db2c
permissions -rw-r--r--
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject. 6747645: ZipFileObject.getName is incorrectly deprecated 6885123: JavaFileObject getName issues Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * @test
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @bug     6589361
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary 6589361:Failing building ct.sym file as part of the control build
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
731
1dd22bdb9ca5 6714364: refactor javac File handling code into new javac.file package
jjg
parents: 657
diff changeset
     7
import com.sun.tools.javac.file.JavacFileManager;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
import com.sun.tools.javac.util.Context;
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
import java.io.File;
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
import javax.tools.FileObject;
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
import javax.tools.JavaFileObject;
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
import javax.tools.JavaFileObject.Kind;
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
import javax.tools.StandardLocation;
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
import java.util.HashSet;
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
public class T6589361 {
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
    public static void main(String [] args) throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
        JavacFileManager fm = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
            fm = new JavacFileManager(new Context(), false, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
            Set<JavaFileObject.Kind> set = new HashSet<JavaFileObject.Kind>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
            set.add(JavaFileObject.Kind.CLASS);
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
            Iterable<JavaFileObject> files = fm.list(StandardLocation.PLATFORM_CLASS_PATH, "java.lang", set, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
            for (JavaFileObject file : files) {
3774
33a6953bed15 6877229: more javac tests fail on Windows
jjg
parents: 731
diff changeset
    26
                // Note: Zip/Jar entry names use '/', not File.separator, but just to be sure,
33a6953bed15 6877229: more javac tests fail on Windows
jjg
parents: 731
diff changeset
    27
                // we normalize the filename as well.
3995
73af8b6fb8bc 6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents: 3774
diff changeset
    28
                if (file.getName().replace(File.separatorChar, '/').contains("java/lang/Object.class")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
                    String str = fm.inferBinaryName(StandardLocation.CLASS_PATH, file);
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
                    if (!str.equals("java.lang.Object")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
                        throw new AssertionError("Error in JavacFileManager.inferBinaryName method!");
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
                    else {
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
                        return;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
        finally {
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
            if (fm != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
                fm.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
        }
3774
33a6953bed15 6877229: more javac tests fail on Windows
jjg
parents: 731
diff changeset
    44
        throw new AssertionError("Could not find java/lang/Object.class while compiling");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
}