Proposal for New Functionality: Allow module-info merging in GenModuleInfoSource.java (original) (raw)

Adam Farley8 adam.farley at uk.ibm.com
Wed Dec 6 16:38:19 UTC 2017


Hi All,

Currently, GenModuleInfoSource.java does not allow you to merge extra module-info files into the primary module-info file (for a given module) at build time.

Put simply; I think it should have this functionality. Can committers please review and opine?

You can already see this code change in action while compiling OpenJDK with OpenJ9, so we know it works.

I've included the "diff -u" output for the proposed code change in this email's P.S.

Best Regards

Adam Farley

P.S. Code diff:

--- original_GenModuleInfoSource.java 2017-12-06 15:46:43.000000000 +0000 +++ improved_GenModuleInfoSource.java 2017-12-06 15:49:04.000000000 +0000 @@ -1,4 +1,10 @@ /* + *

@@ -171,12 +177,13 @@

 class ModuleInfo {

name) { switch (directive) { case "exports": if (moduleInfo.exports.containsKey(name) && @@ -205,6 +212,10 @@ return uses.computeIfAbsent(name, _n -> new Statement("uses", "", name));

name)); + case "provides": return provides.computeIfAbsent(name, _n -> new Statement("provides", "with", name, true)); @@ -233,7 +244,7 @@ .stream() .filter(e -> !exports.containsKey(e.getKey()) && e.getValue().filter(modules))

e.getKey()),

e.getKey()), e.getValue(), modules));

@@ -251,7 +262,7 @@ .stream() .filter(e -> !opens.containsKey(e.getKey()) && e.getValue().filter(modules))

e.getKey()),

e.getKey()), e.getValue(), modules));

@@ -272,6 +283,12 @@ .stream() .filter(service -> !uses.containsKey(service)) .forEach(service -> uses.put(service, extraFiles.uses.get(service))); +

extraFiles.requires.get(require))); }

     // add qualified exports or opens to known modules only

@@ -324,6 +341,11 @@

     void print(PrintWriter writer) {

@@ -418,27 +440,45 @@ String keyword = s[0].trim();

                 String name = s.length > 1 ? s[1].trim() : null;

s[2].trim() : null;

s[3].trim() : null; trace("%d: %s index=%d len=%d%n", lineNumber, l, index, l.length()); switch (keyword) { case "module":

opens, provides, uses

modifiers specified

name.equals("static")) &&

transitive";

{ // 1 modifier specified

name.equals("static")) {

requiresQualifier, name); hasTargets = false;

                         int i = l.indexOf(name, keyword.length()+1) + 

name.length() + 1; l = i < l.length() ? l.substring(i, l.length()).trim() : ""; index = 0;

= 3) { if (!s[2].trim().equals(statement.qualifier)) { throw new RuntimeException(sourcefile

s[2]); @@ -594,17 +634,25 @@ @Override public String toString() { StringBuilder sb = new StringBuilder(" ");

";")));

").append(qualifier).append(" ").append(name).append(";");

").append(name).append(";");

";")));

target))

@@ -620,4 +668,4 @@ System.out.format(fmt, params); } } -} +} \ No newline at end of file

Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU



More information about the core-libs-dev mailing list