Thu, 30 Jul 2009 10:29:53 +0100
6827648: Extremely slow compilation time for visitor pattern code + generics
Summary: Javac unnecessarily recomputates type-substitutions multiple times
Reviewed-by: jjg
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) { |
duke@1 | 26 | |
jjg@38 | 27 | if (file.toString().contains("java" + File.separator + "lang" + File.separator + "Object.class")) { |
duke@1 | 28 | String str = fm.inferBinaryName(StandardLocation.CLASS_PATH, file); |
duke@1 | 29 | if (!str.equals("java.lang.Object")) { |
duke@1 | 30 | throw new AssertionError("Error in JavacFileManager.inferBinaryName method!"); |
duke@1 | 31 | } |
duke@1 | 32 | else { |
duke@1 | 33 | return; |
duke@1 | 34 | } |
duke@1 | 35 | } |
duke@1 | 36 | } |
duke@1 | 37 | } |
duke@1 | 38 | finally { |
duke@1 | 39 | if (fm != null) { |
duke@1 | 40 | fm.close(); |
duke@1 | 41 | } |
duke@1 | 42 | } |
duke@1 | 43 | throw new AssertionError("Could not fing java/lang/Object.class while compiling"); |
duke@1 | 44 | } |
duke@1 | 45 | |
duke@1 | 46 | } |