changeset 48264:37d3e1a80c3b

8193256: Configuration and ModuleLayer findModule cleanup Reviewed-by: redestad, alanb Contributed-by: andrej.golovnin@gmail.com
author alanb
date Fri, 08 Dec 2017 14:28:51 +0000
parents 0ba2a82e4755
children 962b4324320c
files src/java.base/share/classes/java/lang/ModuleLayer.java src/java.base/share/classes/java/lang/module/Configuration.java
diffstat 2 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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();
         }