8193256: Configuration and ModuleLayer findModule cleanup
authoralanb
Fri, 08 Dec 2017 14:28:51 +0000
changeset 48222 37d3e1a80c3b
parent 48221 0ba2a82e4755
child 48223 962b4324320c
8193256: Configuration and ModuleLayer findModule cleanup Reviewed-by: redestad, alanb Contributed-by: andrej.golovnin@gmail.com
src/java.base/share/classes/java/lang/ModuleLayer.java
src/java.base/share/classes/java/lang/module/Configuration.java
--- a/src/java.base/share/classes/java/lang/ModuleLayer.java	Fri Dec 08 11:50:39 2017 +0000
+++ b/src/java.base/share/classes/java/lang/ModuleLayer.java	Fri Dec 08 14:28:51 2017 +0000
@@ -845,9 +845,8 @@
 
         return layers()
                 .skip(1)  // skip this layer
-                .map(l -> l.nameToModule)
-                .filter(map -> map.containsKey(name))
-                .map(map -> map.get(name))
+                .map(l -> l.nameToModule.get(name))
+                .filter(Objects::nonNull)
                 .findAny();
     }
 
--- a/src/java.base/share/classes/java/lang/module/Configuration.java	Fri Dec 08 11:50:39 2017 +0000
+++ b/src/java.base/share/classes/java/lang/module/Configuration.java	Fri Dec 08 14:28:51 2017 +0000
@@ -543,9 +543,8 @@
         if (!parents.isEmpty()) {
             return configurations()
                     .skip(1)  // skip this configuration
-                    .map(cf -> cf.nameToModule)
-                    .filter(map -> map.containsKey(name))
-                    .map(map -> map.get(name))
+                    .map(cf -> cf.nameToModule.get(name))
+                    .filter(Objects::nonNull)
                     .findFirst();
         }