langtools/test/tools/javac/6589361/T6589361.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 10 06bc494ca11e
child 657 99cc2b9325f2
permissions -rw-r--r--
Initial load
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
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
import com.sun.tools.javac.util.Context;
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
import com.sun.tools.javac.util.JavacFileManager;
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) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
                if (file.toString().startsWith("java" + File.separator + "lang" + File.separator + "Object.class")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
                    String str = fm.inferBinaryName(StandardLocation.CLASS_PATH, file);
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
                    if (!str.equals("java.lang.Object")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
                        throw new AssertionError("Error in JavacFileManager.inferBinaryName method!");
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
                    else {
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
                        return;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
                    }
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
        finally {
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
            if (fm != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
                fm.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
        throw new AssertionError("Could not fing java/lang/Object.class while compiling");
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
}