204 } catch (NoClassDefFoundError e) { 205 e.printStackTrace(System.err); 206 failed.add(s); 207 } 208 return false; 209 } 210 211 static class ClassNameJrtStreamBuilder implements Iterable<String>{ 212 213 final FileSystem jrt; 214 final List<Path> roots = new ArrayList<>(); 215 ClassNameJrtStreamBuilder() { 216 jrt = FileSystems.getFileSystem(URI.create("jrt:/")); 217 for (Path root : jrt.getRootDirectories()) { 218 roots.add(root); 219 } 220 } 221 222 Stream<String> build() { 223 return roots.stream().flatMap(this::toStream) 224 .filter(x -> x.getNameCount() > 1) 225 .map( x-> x.subpath(1, x.getNameCount())) 226 .map( x -> x.toString()) 227 .filter(s -> s.endsWith(".class")); 228 } 229 230 @Override 231 public Iterator<String> iterator() { 232 return build().iterator(); 233 } 234 235 private Stream<Path> toStream(Path root) { 236 try { 237 return Files.walk(root); 238 } catch(IOException x) { 239 x.printStackTrace(System.err); 240 skipped.add(root.toString()); 241 } 242 return Collections.<Path>emptyList().stream(); 243 } 244 245 } | 204 } catch (NoClassDefFoundError e) { 205 e.printStackTrace(System.err); 206 failed.add(s); 207 } 208 return false; 209 } 210 211 static class ClassNameJrtStreamBuilder implements Iterable<String>{ 212 213 final FileSystem jrt; 214 final List<Path> roots = new ArrayList<>(); 215 ClassNameJrtStreamBuilder() { 216 jrt = FileSystems.getFileSystem(URI.create("jrt:/")); 217 for (Path root : jrt.getRootDirectories()) { 218 roots.add(root); 219 } 220 } 221 222 Stream<String> build() { 223 return roots.stream().flatMap(this::toStream) 224 .filter(x -> x.getNameCount() > 2) 225 .map( x-> x.subpath(2, x.getNameCount())) 226 .map( x -> x.toString()) 227 .filter(s -> s.endsWith(".class")); 228 } 229 230 @Override 231 public Iterator<String> iterator() { 232 return build().iterator(); 233 } 234 235 private Stream<Path> toStream(Path root) { 236 try { 237 return Files.walk(root); 238 } catch(IOException x) { 239 x.printStackTrace(System.err); 240 skipped.add(root.toString()); 241 } 242 return Collections.<Path>emptyList().stream(); 243 } 244 245 } |