test/tools/javac/6589361/T6589361.java

Thu, 25 Aug 2011 17:18:25 -0700

author
schien
date
Thu, 25 Aug 2011 17:18:25 -0700
changeset 1067
f497fac86cf9
parent 415
49359d0e6a9c
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8-b02 for changeset b3c059de2a61

     1 /**
     2  * @test
     3  * @bug     6589361
     4  * @summary 6589361:Failing building ct.sym file as part of the control build
     5  */
     7 import com.sun.tools.javac.file.JavacFileManager;
     8 import com.sun.tools.javac.util.Context;
     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;
    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                 // Note: Zip/Jar entry names use '/', not File.separator, but just to be sure,
    27                 // we normalize the filename as well.
    28                 if (file.getName().replace(File.separatorChar, '/').contains("java/lang/Object.class")) {
    29                     String str = fm.inferBinaryName(StandardLocation.CLASS_PATH, file);
    30                     if (!str.equals("java.lang.Object")) {
    31                         throw new AssertionError("Error in JavacFileManager.inferBinaryName method!");
    32                     }
    33                     else {
    34                         return;
    35                     }
    36                 }
    37             }
    38         }
    39         finally {
    40             if (fm != null) {
    41                 fm.close();
    42             }
    43         }
    44         throw new AssertionError("Could not find java/lang/Object.class while compiling");
    45     }
    47 }

mercurial