ModuleHelper { public static Optional<String> pathToClassName(Path p) { if (p.startsWith(File.separator + "modules" + File.separator)) { Path subpath = p.subpath(2, p.getNameCount()); String s = ClassNameUtils.replaceSlash(subpath.toString()); if (s.endsWith(".class")) { s = s.substring(0, s.length() - 6); return Optional.of(s); } } return Optional.empty(); } private  ModuleHelper(); static File getJrtFsFile(); static boolean isJrtFsFile(File f); static void walkModule(ModuleConsumer c); static Optional<T> searchModule(ModuleSupplier<T> ms); static void walkModule(String mod, ModuleConsumer c); static InputStream getInputStream(String path); static Optional<String> pathToClassName(Path p); static Optional<String> pathToModule(Path p); @SuppressWarnings("try") static Optional<ClassData> pathToClassData(Path p);  }
@Test public void moduleToClass() throws IOException { Optional<String> s = ModuleHelper.pathToClassName(Paths.get("/modules/java.base/a/b/c/d/e/F.class")); Assert.assertEquals("a.b.c.d.e.F", s.get()); }