< prev index next >

src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


 587         Map<String, List<String>> map = decode("jdk.module.patch.",
 588                                                File.pathSeparator,
 589                                                false);
 590         return new ModulePatcher(map);
 591     }
 592 
 593     /**
 594      * Returns the set of module names specified by --add-module options.
 595      */
 596     private static Set<String> addModules() {
 597         String prefix = "jdk.module.addmods.";
 598         int index = 0;
 599         // the system property is removed after decoding
 600         String value = getAndRemoveProperty(prefix + index);
 601         if (value == null) {
 602             return Set.of();
 603         } else {
 604             Set<String> modules = new HashSet<>();
 605             while (value != null) {
 606                 for (String s : value.split(",")) {
 607                     if (s.length() > 0) modules.add(s);

 608                 }
 609                 index++;
 610                 value = getAndRemoveProperty(prefix + index);
 611             }
 612             return modules;
 613         }
 614     }
 615 
 616     /**
 617      * Returns the set of module names specified by --limit-modules.
 618      */
 619     private static Set<String> limitModules() {
 620         String value = getAndRemoveProperty("jdk.module.limitmods");
 621         if (value == null) {
 622             return Set.of();
 623         } else {
 624             Set<String> names = new HashSet<>();
 625             for (String name : value.split(",")) {
 626                 if (name.length() > 0) names.add(name);
 627             }


 878 
 879             int pos = value.indexOf('=');
 880             if (pos == -1)
 881                 fail(unableToParse(option(prefix), "<module>=<value>", value));
 882             if (pos == 0)
 883                 fail(unableToParse(option(prefix), "<module>=<value>", value));
 884 
 885             // key is <module> or <module>/<package>
 886             String key = value.substring(0, pos);
 887 
 888             String rhs = value.substring(pos+1);
 889             if (rhs.isEmpty())
 890                 fail(unableToParse(option(prefix), "<module>=<value>", value));
 891 
 892             // value is <module>(,<module>)* or <file>(<pathsep><file>)*
 893             if (!allowDuplicates && map.containsKey(key))
 894                 fail(key + " specified more than once to " + option(prefix));
 895             List<String> values = map.computeIfAbsent(key, k -> new ArrayList<>());
 896             int ntargets = 0;
 897             for (String s : rhs.split(regex)) {
 898                 if (s.length() > 0) {
 899                     values.add(s);
 900                     ntargets++;
 901                 }
 902             }
 903             if (ntargets == 0)
 904                 fail("Target must be specified: " + option(prefix) + " " + value);
 905 
 906             index++;
 907             value = getAndRemoveProperty(prefix + index);
 908         }
 909 
 910         return map;
 911     }
 912 
 913     /**
 914      * Decodes the values of --add-reads, -add-exports or --add-opens
 915      * which use the "," to separate the RHS of the option value.
 916      */
 917     private static Map<String, List<String>> decode(String prefix) {
 918         return decode(prefix, ",", true);




 587         Map<String, List<String>> map = decode("jdk.module.patch.",
 588                                                File.pathSeparator,
 589                                                false);
 590         return new ModulePatcher(map);
 591     }
 592 
 593     /**
 594      * Returns the set of module names specified by --add-module options.
 595      */
 596     private static Set<String> addModules() {
 597         String prefix = "jdk.module.addmods.";
 598         int index = 0;
 599         // the system property is removed after decoding
 600         String value = getAndRemoveProperty(prefix + index);
 601         if (value == null) {
 602             return Set.of();
 603         } else {
 604             Set<String> modules = new HashSet<>();
 605             while (value != null) {
 606                 for (String s : value.split(",")) {
 607                     if (!s.isEmpty())
 608                         modules.add(s);
 609                 }
 610                 index++;
 611                 value = getAndRemoveProperty(prefix + index);
 612             }
 613             return modules;
 614         }
 615     }
 616 
 617     /**
 618      * Returns the set of module names specified by --limit-modules.
 619      */
 620     private static Set<String> limitModules() {
 621         String value = getAndRemoveProperty("jdk.module.limitmods");
 622         if (value == null) {
 623             return Set.of();
 624         } else {
 625             Set<String> names = new HashSet<>();
 626             for (String name : value.split(",")) {
 627                 if (name.length() > 0) names.add(name);
 628             }


 879 
 880             int pos = value.indexOf('=');
 881             if (pos == -1)
 882                 fail(unableToParse(option(prefix), "<module>=<value>", value));
 883             if (pos == 0)
 884                 fail(unableToParse(option(prefix), "<module>=<value>", value));
 885 
 886             // key is <module> or <module>/<package>
 887             String key = value.substring(0, pos);
 888 
 889             String rhs = value.substring(pos+1);
 890             if (rhs.isEmpty())
 891                 fail(unableToParse(option(prefix), "<module>=<value>", value));
 892 
 893             // value is <module>(,<module>)* or <file>(<pathsep><file>)*
 894             if (!allowDuplicates && map.containsKey(key))
 895                 fail(key + " specified more than once to " + option(prefix));
 896             List<String> values = map.computeIfAbsent(key, k -> new ArrayList<>());
 897             int ntargets = 0;
 898             for (String s : rhs.split(regex)) {
 899                 if (!s.isEmpty()) {
 900                     values.add(s);
 901                     ntargets++;
 902                 }
 903             }
 904             if (ntargets == 0)
 905                 fail("Target must be specified: " + option(prefix) + " " + value);
 906 
 907             index++;
 908             value = getAndRemoveProperty(prefix + index);
 909         }
 910 
 911         return map;
 912     }
 913 
 914     /**
 915      * Decodes the values of --add-reads, -add-exports or --add-opens
 916      * which use the "," to separate the RHS of the option value.
 917      */
 918     private static Map<String, List<String>> decode(String prefix) {
 919         return decode(prefix, ",", true);


< prev index next >