< prev index next >

src/java.base/share/classes/java/lang/reflect/Module.java

Print this page
rev 14279 : [mq]: 8140281-deprecation-optional.get


 879             // replace with new set
 880             this.extraPackages = extraPackages; // volatile write
 881         }
 882     }
 883 
 884 
 885     // -- creating Module objects --
 886 
 887     /**
 888      * Find the runtime Module corresponding to the given ReadDependence
 889      * in the given parent Layer (or its parents).
 890      */
 891     private static Module find(ResolvedModule resolvedModule, Layer layer) {
 892         Configuration cf = resolvedModule.configuration();
 893         String dn = resolvedModule.name();
 894 
 895         Module m = null;
 896         while (layer != null) {
 897             if (layer.configuration() == cf) {
 898                 Optional<Module> om = layer.findModule(dn);
 899                 m = om.get();
 900                 assert m.getLayer() == layer;
 901                 break;
 902             }
 903             layer = layer.parent().orElse(null);
 904         }
 905         return m;
 906     }
 907 
 908     /**
 909      * Defines each of the module in the given configuration to the runtime.
 910      *
 911      * @return a map of module name to runtime {@code Module}
 912      *
 913      * @throws IllegalArgumentException
 914      *         If defining any of the modules to the VM fails
 915      */
 916     static Map<String, Module> defineModules(Configuration cf,
 917                                              Function<String, ClassLoader> clf,
 918                                              Layer layer)
 919     {




 879             // replace with new set
 880             this.extraPackages = extraPackages; // volatile write
 881         }
 882     }
 883 
 884 
 885     // -- creating Module objects --
 886 
 887     /**
 888      * Find the runtime Module corresponding to the given ReadDependence
 889      * in the given parent Layer (or its parents).
 890      */
 891     private static Module find(ResolvedModule resolvedModule, Layer layer) {
 892         Configuration cf = resolvedModule.configuration();
 893         String dn = resolvedModule.name();
 894 
 895         Module m = null;
 896         while (layer != null) {
 897             if (layer.configuration() == cf) {
 898                 Optional<Module> om = layer.findModule(dn);
 899                 m = om.getWhenPresent();
 900                 assert m.getLayer() == layer;
 901                 break;
 902             }
 903             layer = layer.parent().orElse(null);
 904         }
 905         return m;
 906     }
 907 
 908     /**
 909      * Defines each of the module in the given configuration to the runtime.
 910      *
 911      * @return a map of module name to runtime {@code Module}
 912      *
 913      * @throws IllegalArgumentException
 914      *         If defining any of the modules to the VM fails
 915      */
 916     static Map<String, Module> defineModules(Configuration cf,
 917                                              Function<String, ClassLoader> clf,
 918                                              Layer layer)
 919     {


< prev index next >