String (File dir) { if (dir.isDirectory()) { try (BufferedInputStream is = new BufferedInputStream(new FileInputStream(new File(dir, "META-INF/MANIFEST.MF")))) { final String name = new Manifest(is).getMainAttributes().getValue(AUTOMATIC_MODULE_NAME); return name != null ? name : normalizeModuleName(myModuleNameSearch.apply(dir)); } catch (FileNotFoundException e) { return normalizeModuleName(myModuleNameSearch.apply(dir)); // inferring the module name from the dir } catch (Throwable ignored) { } } return null; }