1 /* |
1 /* |
2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
43 File java_home = new File(System.getProperty("java.home")); |
43 File java_home = new File(System.getProperty("java.home")); |
44 if (java_home.getName().equals("jre")) |
44 if (java_home.getName().equals("jre")) |
45 java_home = java_home.getParentFile(); |
45 java_home = java_home.getParentFile(); |
46 |
46 |
47 JavaCompiler c = ToolProvider.getSystemJavaCompiler(); |
47 JavaCompiler c = ToolProvider.getSystemJavaCompiler(); |
48 StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); |
48 try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) { |
49 //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH))); |
49 //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH))); |
50 |
50 |
51 for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH, |
51 for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH, |
52 "java.lang", |
52 "java.lang", |
53 Collections.singleton(JavaFileObject.Kind.CLASS), |
53 Collections.singleton(JavaFileObject.Kind.CLASS), |
54 false)) { |
54 false)) { |
55 test++; |
55 test++; |
56 |
56 |
57 if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) { |
57 if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) { |
58 System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName()); |
58 System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName()); |
59 skip++; |
59 skip++; |
60 continue; |
60 continue; |
|
61 } |
|
62 |
|
63 //System.err.println(fo.getName()); |
|
64 String p = fo.getName(); |
|
65 int bra = p.indexOf("("); |
|
66 int ket = p.indexOf(")"); |
|
67 //System.err.println(bra + "," + ket + "," + p.length()); |
|
68 if (bra == -1 || ket != p.length() -1) |
|
69 throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length()); |
|
70 String part1 = p.substring(0, bra); |
|
71 String part2 = p.substring(bra + 1, ket); |
|
72 //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home); |
|
73 if (part1.equals(part2) || !part1.startsWith(java_home.getPath())) |
|
74 throw new Exception("bad path: " + p); |
|
75 |
61 } |
76 } |
62 |
77 |
63 //System.err.println(fo.getName()); |
78 if (test == 0) |
64 String p = fo.getName(); |
79 throw new Exception("no files found"); |
65 int bra = p.indexOf("("); |
|
66 int ket = p.indexOf(")"); |
|
67 //System.err.println(bra + "," + ket + "," + p.length()); |
|
68 if (bra == -1 || ket != p.length() -1) |
|
69 throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length()); |
|
70 String part1 = p.substring(0, bra); |
|
71 String part2 = p.substring(bra + 1, ket); |
|
72 //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home); |
|
73 if (part1.equals(part2) || !part1.startsWith(java_home.getPath())) |
|
74 throw new Exception("bad path: " + p); |
|
75 |
80 |
|
81 if (skip == 0) |
|
82 System.out.println(test + " files found"); |
|
83 else |
|
84 System.out.println(test + " files found, " + skip + " files skipped"); |
|
85 |
|
86 if (test == skip) |
|
87 System.out.println("Warning: all files skipped; no platform classes found in zip files."); |
76 } |
88 } |
77 |
|
78 if (test == 0) |
|
79 throw new Exception("no files found"); |
|
80 |
|
81 if (skip == 0) |
|
82 System.out.println(test + " files found"); |
|
83 else |
|
84 System.out.println(test + " files found, " + skip + " files skipped"); |
|
85 |
|
86 if (test == skip) |
|
87 System.out.println("Warning: all files skipped; no platform classes found in zip files."); |
|
88 } |
89 } |
89 |
90 |
90 private <T> List<T> asList(Iterable<? extends T> items) { |
91 private <T> List<T> asList(Iterable<? extends T> items) { |
91 List<T> list = new ArrayList<T>(); |
92 List<T> list = new ArrayList<T>(); |
92 for (T item: items) |
93 for (T item: items) |