< prev index next >

src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java

Print this page




  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.jdeps;
  27 
  28 import java.io.IOException;
  29 import java.lang.module.ModuleDescriptor;
  30 import java.util.Arrays;
  31 import java.util.Comparator;
  32 import java.util.HashMap;
  33 import java.util.HashSet;
  34 import java.util.Map;
  35 import java.util.Optional;
  36 import java.util.Set;
  37 
  38 /**
  39  * Build the profile information.
  40  */
  41 enum Profile {
  42     COMPACT1("compact1", 1, "java.logging",
  43                             "java.scripting"),
  44     COMPACT2("compact2", 2, "java.rmi",
  45                             "java.sql",
  46                             "java.xml",
  47                             "jdk.xml.dom",
  48                             "jdk.httpserver"),
  49     COMPACT3("compact3", 3, "java.smartcardio",
  50                             "java.compiler",
  51                             "java.instrument",
  52                             "java.management",
  53                             "java.naming",
  54                             "java.prefs",
  55                             "java.security.jgss",


 121                   .map(systemModules::get)
 122                   .forEach(m -> p.addModule(systemModules, m)));
 123 
 124         // JDK modules should include full JRE plus other jdk.* modules
 125         // Just include all installed modules.  Assume jdeps is running
 126         // in JDK image
 127         JDK.addAll(systemModules.values());
 128     }
 129 
 130     private void addModule(Map<String, Module> systemModules, Module module) {
 131         modules.put(module.name(), module);
 132         module.descriptor().requires().stream()
 133               .map(ModuleDescriptor.Requires::name)
 134               .map(systemModules::get)
 135               .forEach(m -> modules.put(m.name(), m));
 136     }
 137 
 138     // for debugging
 139     public static void main(String[] args) throws IOException {
 140         // initialize Profiles
 141         new JdepsConfiguration.Builder().allModules().build();
 142 
 143         // find platform modules
 144         if (Profile.getProfileCount() == 0) {
 145             System.err.println("No profile is present in this JDK");
 146         }
 147         for (Profile p : Profile.values()) {
 148             String profileName = p.name;
 149             System.out.format("%2d: %-10s  %s%n", p.profile, profileName, p.modules);
 150         }
 151         System.out.println("All JDK modules:-");
 152         JDK.stream().sorted(Comparator.comparing(Module::name))
 153            .forEach(System.out::println);
 154     }
 155 }


  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.jdeps;
  27 
  28 import java.io.IOException;
  29 import java.lang.module.ModuleDescriptor;
  30 import java.util.Arrays;
  31 import java.util.Comparator;
  32 import java.util.HashMap;
  33 import java.util.HashSet;
  34 import java.util.Map;

  35 import java.util.Set;
  36 
  37 /**
  38  * Build the profile information.
  39  */
  40 enum Profile {
  41     COMPACT1("compact1", 1, "java.logging",
  42                             "java.scripting"),
  43     COMPACT2("compact2", 2, "java.rmi",
  44                             "java.sql",
  45                             "java.xml",
  46                             "jdk.xml.dom",
  47                             "jdk.httpserver"),
  48     COMPACT3("compact3", 3, "java.smartcardio",
  49                             "java.compiler",
  50                             "java.instrument",
  51                             "java.management",
  52                             "java.naming",
  53                             "java.prefs",
  54                             "java.security.jgss",


 120                   .map(systemModules::get)
 121                   .forEach(m -> p.addModule(systemModules, m)));
 122 
 123         // JDK modules should include full JRE plus other jdk.* modules
 124         // Just include all installed modules.  Assume jdeps is running
 125         // in JDK image
 126         JDK.addAll(systemModules.values());
 127     }
 128 
 129     private void addModule(Map<String, Module> systemModules, Module module) {
 130         modules.put(module.name(), module);
 131         module.descriptor().requires().stream()
 132               .map(ModuleDescriptor.Requires::name)
 133               .map(systemModules::get)
 134               .forEach(m -> modules.put(m.name(), m));
 135     }
 136 
 137     // for debugging
 138     public static void main(String[] args) throws IOException {
 139         // initialize Profiles
 140         new JdepsConfiguration.Builder().addmods(Set.of("ALL-SYSTEM")).build();
 141 
 142         // find platform modules
 143         if (Profile.getProfileCount() == 0) {
 144             System.err.println("No profile is present in this JDK");
 145         }
 146         for (Profile p : Profile.values()) {
 147             String profileName = p.name;
 148             System.out.format("%2d: %-10s  %s%n", p.profile, profileName, p.modules);
 149         }
 150         System.out.println("All JDK modules:-");
 151         JDK.stream().sorted(Comparator.comparing(Module::name))
 152            .forEach(System.out::println);
 153     }
 154 }
< prev index next >