Skip to content

Commit 0101824

Browse files
committed
Just have module finder tell us the damn module name, if it fails then proceed to do our fallback of checking the manifest...
1 parent 9a794c5 commit 0101824

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/main/java/org/mangorage/bootstrap/internal/JarHandler.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,20 @@ private static void deleteDirectory(Path dir) throws IOException {
106106
private static Result resolveModuleName(Path jarPath) {
107107
try (JarFile jarFile = new JarFile(jarPath.toFile())) {
108108

109+
String moduleName = null;
110+
111+
try {
112+
moduleName = ModuleFinder.of(jarPath)
113+
.findAll()
114+
.iterator()
115+
.next()
116+
.descriptor()
117+
.name();
118+
} catch (Exception ignore) {}
119+
109120
// 1. Proper JPMS module
110-
if (jarFile.getEntry("module-info.class") != null) {
111-
return new Result(
112-
ModuleFinder.of(jarPath)
113-
.findAll()
114-
.iterator()
115-
.next()
116-
.descriptor()
117-
.name(),
118-
ModuleNameOrigin.MODULE_INFO,
119-
jarPath
120-
);
121+
if (moduleName != null) {
122+
return new Result(moduleName, ModuleNameOrigin.MODULE_INFO, jarPath);
121123
}
122124

123125
// 2. Check MANIFEST.MF for Automatic-Module-Name

0 commit comments

Comments
 (0)