Tue, 12 Oct 2010 14:47:51 -0700
6908476: test/tools/javac/T6705935.java fails if non-zip files found on platform class path
Reviewed-by: darcy
test/tools/javac/T6705935.java | file | annotate | diff | comparison | revisions |
1.1 --- a/test/tools/javac/T6705935.java Tue Oct 12 14:22:55 2010 -0700 1.2 +++ b/test/tools/javac/T6705935.java Tue Oct 12 14:47:51 2010 -0700 1.3 @@ -31,6 +31,8 @@ 1.4 import java.util.*; 1.5 import javax.tools.*; 1.6 import com.sun.tools.javac.file.*; 1.7 +import com.sun.tools.javac.file.ZipArchive.ZipFileObject; 1.8 +import com.sun.tools.javac.file.ZipFileIndexArchive.ZipFileIndexFileObject; 1.9 1.10 public class T6705935 { 1.11 public static void main(String... args) throws Exception { 1.12 @@ -43,11 +45,22 @@ 1.13 java_home = java_home.getParentFile(); 1.14 1.15 JavaCompiler c = ToolProvider.getSystemJavaCompiler(); 1.16 - JavaFileManager fm = c.getStandardFileManager(null, null, null); 1.17 + StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); 1.18 + //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH))); 1.19 + 1.20 for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH, 1.21 "java.lang", 1.22 Collections.singleton(JavaFileObject.Kind.CLASS), 1.23 false)) { 1.24 + test++; 1.25 + 1.26 + if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) { 1.27 + System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName()); 1.28 + skip++; 1.29 + continue; 1.30 + } 1.31 + 1.32 + //System.err.println(fo.getName()); 1.33 String p = fo.getName(); 1.34 int bra = p.indexOf("("); 1.35 int ket = p.indexOf(")"); 1.36 @@ -61,5 +74,26 @@ 1.37 throw new Exception("bad path: " + p); 1.38 1.39 } 1.40 + 1.41 + if (test == 0) 1.42 + throw new Exception("no files found"); 1.43 + 1.44 + if (skip == 0) 1.45 + System.out.println(test + " files found"); 1.46 + else 1.47 + System.out.println(test + " files found, " + skip + " files skipped"); 1.48 + 1.49 + if (test == skip) 1.50 + System.out.println("Warning: all files skipped; no platform classes found in zip files."); 1.51 } 1.52 + 1.53 + private <T> List<T> asList(Iterable<? extends T> items) { 1.54 + List<T> list = new ArrayList<T>(); 1.55 + for (T item: items) 1.56 + list.add(item); 1.57 + return list; 1.58 + } 1.59 + 1.60 + private int skip; 1.61 + private int test; 1.62 }