@Test public void testCreationInvalidInput() throws IOException { try { ClassDumper.create(ImmutableList.of(new ClassPathEntry(Paths.get("no_such_file")))); Assert.fail("Empty path should generate IOException"); } catch (IllegalArgumentException ex) { Truth.assertThat(ex) .hasMessageThat() .isEqualTo("Some jar files are not readable: [no_such_file]"); } }
static ClassDumper create(List<ClassPathEntry> entries) throws IOException { ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); ClassLoader extensionClassLoader = systemClassLoader.getParent(); ImmutableList<Path> unreadableFiles = entries.stream() .map(ClassPathEntry::getJar) .filter(jar -> !Files.isRegularFile(jar) || !Files.isReadable(jar)) .collect(toImmutableList()); checkArgument( unreadableFiles.isEmpty(), "Some jar files are not readable: %s", unreadableFiles); Map<String, ClassPathEntry> map = new HashMap<>(); for (ClassPathEntry entry : entries) { for (String className : entry.getFileNames()) { if (!map.containsKey(className)) { map.put(className, entry); } } } return new ClassDumper(entries, extensionClassLoader, map); }
ClassDumper { static ClassDumper create(List<ClassPathEntry> entries) throws IOException { ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); ClassLoader extensionClassLoader = systemClassLoader.getParent(); ImmutableList<Path> unreadableFiles = entries.stream() .map(ClassPathEntry::getJar) .filter(jar -> !Files.isRegularFile(jar) || !Files.isReadable(jar)) .collect(toImmutableList()); checkArgument( unreadableFiles.isEmpty(), "Some jar files are not readable: %s", unreadableFiles); Map<String, ClassPathEntry> map = new HashMap<>(); for (ClassPathEntry entry : entries) { for (String className : entry.getFileNames()) { if (!map.containsKey(className)) { map.put(className, entry); } } } return new ClassDumper(entries, extensionClassLoader, map); } }
ClassDumper { static ClassDumper create(List<ClassPathEntry> entries) throws IOException { ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); ClassLoader extensionClassLoader = systemClassLoader.getParent(); ImmutableList<Path> unreadableFiles = entries.stream() .map(ClassPathEntry::getJar) .filter(jar -> !Files.isRegularFile(jar) || !Files.isReadable(jar)) .collect(toImmutableList()); checkArgument( unreadableFiles.isEmpty(), "Some jar files are not readable: %s", unreadableFiles); Map<String, ClassPathEntry> map = new HashMap<>(); for (ClassPathEntry entry : entries) { for (String className : entry.getFileNames()) { if (!map.containsKey(className)) { map.put(className, entry); } } } return new ClassDumper(entries, extensionClassLoader, map); } private  ClassDumper(
      List<ClassPathEntry> inputClassPath,
      ClassLoader extensionClassLoader,
      Map<String, ClassPathEntry> fileNameToClassPathEntry); }
ClassDumper { static ClassDumper create(List<ClassPathEntry> entries) throws IOException { ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); ClassLoader extensionClassLoader = systemClassLoader.getParent(); ImmutableList<Path> unreadableFiles = entries.stream() .map(ClassPathEntry::getJar) .filter(jar -> !Files.isRegularFile(jar) || !Files.isReadable(jar)) .collect(toImmutableList()); checkArgument( unreadableFiles.isEmpty(), "Some jar files are not readable: %s", unreadableFiles); Map<String, ClassPathEntry> map = new HashMap<>(); for (ClassPathEntry entry : entries) { for (String className : entry.getFileNames()) { if (!map.containsKey(className)) { map.put(className, entry); } } } return new ClassDumper(entries, extensionClassLoader, map); } private  ClassDumper(
      List<ClassPathEntry> inputClassPath,
      ClassLoader extensionClassLoader,
      Map<String, ClassPathEntry> fileNameToClassPathEntry);  }
ClassDumper { static ClassDumper create(List<ClassPathEntry> entries) throws IOException { ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); ClassLoader extensionClassLoader = systemClassLoader.getParent(); ImmutableList<Path> unreadableFiles = entries.stream() .map(ClassPathEntry::getJar) .filter(jar -> !Files.isRegularFile(jar) || !Files.isReadable(jar)) .collect(toImmutableList()); checkArgument( unreadableFiles.isEmpty(), "Some jar files are not readable: %s", unreadableFiles); Map<String, ClassPathEntry> map = new HashMap<>(); for (ClassPathEntry entry : entries) { for (String className : entry.getFileNames()) { if (!map.containsKey(className)) { map.put(className, entry); } } } return new ClassDumper(entries, extensionClassLoader, map); } private  ClassDumper(
      List<ClassPathEntry> inputClassPath,
      ClassLoader extensionClassLoader,
      Map<String, ClassPathEntry> fileNameToClassPathEntry);   }