changeset 4923:822101a1a31d

Automatic-Module-Name
author alanb
date Fri, 05 May 2017 21:06:32 +0100
parents 3ed3d69a8cc5
children 69ae34a97515
files src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Thu May 04 19:02:21 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Fri May 05 21:06:32 2017 +0100
@@ -29,6 +29,7 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.UncheckedIOException;
 import java.net.URI;
 import java.net.URL;
@@ -65,6 +66,8 @@
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
 
 import javax.lang.model.SourceVersion;
 import javax.tools.JavaFileManager;
@@ -1341,6 +1344,17 @@
                             String moduleName = readModuleName(moduleInfoClass);
                             return new Pair<>(moduleName, p);
                         }
+                        Path mf = fs.getPath("META-INF/MANIFEST.MF");
+                        if (Files.exists(mf)) {
+                            try (InputStream in = Files.newInputStream(mf)) {
+                                Manifest man = new Manifest(in);
+                                Attributes attrs = man.getMainAttributes();
+                                if (attrs != null) {
+                                    String moduleName = attrs.getValue(new Attributes.Name("Automatic-Module-Name"));
+                                    if (moduleName != null) return new Pair<>(moduleName, p);
+                                }
+                            }
+                        }
                     } catch (ModuleNameReader.BadClassFile e) {
                         log.error(Errors.LocnBadModuleInfo(p));
                         return null;