Wed, 26 Jan 2011 13:45:25 -0800
7013272: Automatically generate info about how compiler resource keys are used
Reviewed-by: mcimadamore
duke@1 | 1 | /** |
duke@1 | 2 | * @test |
duke@1 | 3 | * @bug 6589361 |
duke@1 | 4 | * @summary 6589361:Failing building ct.sym file as part of the control build |
duke@1 | 5 | */ |
duke@1 | 6 | |
jjg@50 | 7 | import com.sun.tools.javac.file.JavacFileManager; |
duke@1 | 8 | import com.sun.tools.javac.util.Context; |
duke@1 | 9 | import java.io.File; |
duke@1 | 10 | import javax.tools.FileObject; |
duke@1 | 11 | import javax.tools.JavaFileObject; |
duke@1 | 12 | import javax.tools.JavaFileObject.Kind; |
duke@1 | 13 | import javax.tools.StandardLocation; |
duke@1 | 14 | import java.util.Set; |
duke@1 | 15 | import java.util.HashSet; |
duke@1 | 16 | |
duke@1 | 17 | public class T6589361 { |
duke@1 | 18 | public static void main(String [] args) throws Exception { |
duke@1 | 19 | JavacFileManager fm = null; |
duke@1 | 20 | try { |
duke@1 | 21 | fm = new JavacFileManager(new Context(), false, null); |
duke@1 | 22 | Set<JavaFileObject.Kind> set = new HashSet<JavaFileObject.Kind>(); |
duke@1 | 23 | set.add(JavaFileObject.Kind.CLASS); |
duke@1 | 24 | Iterable<JavaFileObject> files = fm.list(StandardLocation.PLATFORM_CLASS_PATH, "java.lang", set, false); |
duke@1 | 25 | for (JavaFileObject file : files) { |
jjg@392 | 26 | // Note: Zip/Jar entry names use '/', not File.separator, but just to be sure, |
jjg@392 | 27 | // we normalize the filename as well. |
jjg@415 | 28 | if (file.getName().replace(File.separatorChar, '/').contains("java/lang/Object.class")) { |
duke@1 | 29 | String str = fm.inferBinaryName(StandardLocation.CLASS_PATH, file); |
duke@1 | 30 | if (!str.equals("java.lang.Object")) { |
duke@1 | 31 | throw new AssertionError("Error in JavacFileManager.inferBinaryName method!"); |
duke@1 | 32 | } |
duke@1 | 33 | else { |
duke@1 | 34 | return; |
duke@1 | 35 | } |
duke@1 | 36 | } |
duke@1 | 37 | } |
duke@1 | 38 | } |
duke@1 | 39 | finally { |
duke@1 | 40 | if (fm != null) { |
duke@1 | 41 | fm.close(); |
duke@1 | 42 | } |
duke@1 | 43 | } |
jjg@392 | 44 | throw new AssertionError("Could not find java/lang/Object.class while compiling"); |
duke@1 | 45 | } |
duke@1 | 46 | |
duke@1 | 47 | } |