52 public abstract class Profiles { |
52 public abstract class Profiles { |
53 // for debugging |
53 // for debugging |
54 public static void main(String[] args) throws IOException { |
54 public static void main(String[] args) throws IOException { |
55 Profiles p = Profiles.read(new File(args[0])); |
55 Profiles p = Profiles.read(new File(args[0])); |
56 if (args.length >= 2) { |
56 if (args.length >= 2) { |
57 Map<Integer,Set<String>> lists = new TreeMap<Integer,Set<String>>(); |
57 Map<Integer,Set<String>> lists = new TreeMap<>(); |
58 for (int i = 1; i <= 4; i++) |
58 for (int i = 1; i <= 4; i++) |
59 lists.put(i, new TreeSet<String>()); |
59 lists.put(i, new TreeSet<>()); |
60 |
60 |
61 File rt_jar_lst = new File(args[1]); |
61 File rt_jar_lst = new File(args[1]); |
62 for (String line: Files.readAllLines(rt_jar_lst.toPath(), Charset.defaultCharset())) { |
62 for (String line: Files.readAllLines(rt_jar_lst.toPath(), Charset.defaultCharset())) { |
63 if (line.endsWith(".class")) { |
63 if (line.endsWith(".class")) { |
64 String type = line.substring(0, line.length() - 6); |
64 String type = line.substring(0, line.length() - 6); |
99 private static class MakefileProfiles extends Profiles { |
99 private static class MakefileProfiles extends Profiles { |
100 static class Package { |
100 static class Package { |
101 final Package parent; |
101 final Package parent; |
102 final String name; |
102 final String name; |
103 |
103 |
104 Map<String, Package> subpackages = new TreeMap<String, Package>(); |
104 Map<String, Package> subpackages = new TreeMap<>(); |
105 |
105 |
106 int profile; |
106 int profile; |
107 Map<String, Integer> includedTypes = new TreeMap<String,Integer>(); |
107 Map<String, Integer> includedTypes = new TreeMap<>(); |
108 Map<String, Integer> excludedTypes = new TreeMap<String,Integer>(); |
108 Map<String, Integer> excludedTypes = new TreeMap<>(); |
109 |
109 |
110 Package(Package parent, String name) { |
110 Package(Package parent, String name) { |
111 this.parent = parent; |
111 this.parent = parent; |
112 this.name = name; |
112 this.name = name; |
113 } |
113 } |
140 for (Package pkg: subpackages.values()) |
140 for (Package pkg: subpackages.values()) |
141 pkg.getPackages(profile, results); |
141 pkg.getPackages(profile, results); |
142 } |
142 } |
143 } |
143 } |
144 |
144 |
145 final Map<String, Package> packages = new TreeMap<String, Package>(); |
145 final Map<String, Package> packages = new TreeMap<>(); |
146 |
146 |
147 final int maxProfile = 4; // Three compact profiles plus full JRE |
147 final int maxProfile = 4; // Three compact profiles plus full JRE |
148 |
148 |
149 MakefileProfiles(Properties p) { |
149 MakefileProfiles(Properties p) { |
150 for (int profile = 1; profile <= maxProfile; profile++) { |
150 for (int profile = 1; profile <= maxProfile; profile++) { |
189 return p.getProfile(simpleName); |
189 return p.getProfile(simpleName); |
190 } |
190 } |
191 |
191 |
192 @Override |
192 @Override |
193 public Set<String> getPackages(int profile) { |
193 public Set<String> getPackages(int profile) { |
194 Set<String> results = new TreeSet<String>(); |
194 Set<String> results = new TreeSet<>(); |
195 for (Package p: packages.values()) |
195 for (Package p: packages.values()) |
196 p.getPackages(profile, results); |
196 p.getPackages(profile, results); |
197 return results; |
197 return results; |
198 } |
198 } |
199 |
199 |
253 private final Map<String, Integer> map; |
253 private final Map<String, Integer> map; |
254 private final int profileCount; |
254 private final int profileCount; |
255 |
255 |
256 SimpleProfiles(Properties p) { |
256 SimpleProfiles(Properties p) { |
257 int max = 0; |
257 int max = 0; |
258 map = new HashMap<String, Integer>(); |
258 map = new HashMap<>(); |
259 for (Map.Entry<Object,Object> e: p.entrySet()) { |
259 for (Map.Entry<Object,Object> e: p.entrySet()) { |
260 String typeName = (String) e.getKey(); |
260 String typeName = (String) e.getKey(); |
261 int profile = Integer.valueOf((String) e.getValue()); |
261 int profile = Integer.valueOf((String) e.getValue()); |
262 map.put(typeName, profile); |
262 map.put(typeName, profile); |
263 max = Math.max(max, profile); |
263 max = Math.max(max, profile); |
275 return map.get(typeName); |
275 return map.get(typeName); |
276 } |
276 } |
277 |
277 |
278 @Override |
278 @Override |
279 public Set<String> getPackages(int profile) { |
279 public Set<String> getPackages(int profile) { |
280 Set<String> results = new TreeSet<String>(); |
280 Set<String> results = new TreeSet<>(); |
281 for (Map.Entry<String,Integer> e: map.entrySet()) { |
281 for (Map.Entry<String,Integer> e: map.entrySet()) { |
282 String tn = e.getKey(); |
282 String tn = e.getKey(); |
283 int prf = e.getValue(); |
283 int prf = e.getValue(); |
284 int sep = tn.lastIndexOf("/"); |
284 int sep = tn.lastIndexOf("/"); |
285 if (sep > 0 && profile >= prf) |
285 if (sep > 0 && profile >= prf) |