langtools/test/tools/javac/6589361/T6589361.java
changeset 10 06bc494ca11e
child 657 99cc2b9325f2
equal deleted inserted replaced
0:fd16c54261b3 10:06bc494ca11e
       
     1 /**
       
     2  * @test
       
     3  * @bug     6589361
       
     4  * @summary 6589361:Failing building ct.sym file as part of the control build
       
     5  */
       
     6 
       
     7 import com.sun.tools.javac.util.Context;
       
     8 import com.sun.tools.javac.util.JavacFileManager;
       
     9 import java.io.File;
       
    10 import javax.tools.FileObject;
       
    11 import javax.tools.JavaFileObject;
       
    12 import javax.tools.JavaFileObject.Kind;
       
    13 import javax.tools.StandardLocation;
       
    14 import java.util.Set;
       
    15 import java.util.HashSet;
       
    16 
       
    17 public class T6589361 {
       
    18     public static void main(String [] args) throws Exception {
       
    19         JavacFileManager fm = null;
       
    20         try {
       
    21             fm = new JavacFileManager(new Context(), false, null);
       
    22             Set<JavaFileObject.Kind> set = new HashSet<JavaFileObject.Kind>();
       
    23             set.add(JavaFileObject.Kind.CLASS);
       
    24             Iterable<JavaFileObject> files = fm.list(StandardLocation.PLATFORM_CLASS_PATH, "java.lang", set, false);
       
    25             for (JavaFileObject file : files) {
       
    26 
       
    27                 if (file.toString().startsWith("java" + File.separator + "lang" + File.separator + "Object.class")) {
       
    28                     String str = fm.inferBinaryName(StandardLocation.CLASS_PATH, file);
       
    29                     if (!str.equals("java.lang.Object")) {
       
    30                         throw new AssertionError("Error in JavacFileManager.inferBinaryName method!");
       
    31                     }
       
    32                     else {
       
    33                         return;
       
    34                     }
       
    35                 }
       
    36             }
       
    37         }
       
    38         finally {
       
    39             if (fm != null) {
       
    40                 fm.close();
       
    41             }
       
    42         }
       
    43         throw new AssertionError("Could not fing java/lang/Object.class while compiling");
       
    44     }
       
    45 
       
    46 }