1 /*
   2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  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 jdk.internal.module;
  27 
  28 import java.lang.module.ModuleDescriptor;
  29 
  30 /*
  31  * SystemModules class will be generated at link time to create
  32  * ModuleDescriptor for the system modules directly to improve
  33  * the module descriptor reconstitution time.
  34  *
  35  * This will skip parsing of module-info.class file and validating
  36  * names such as module name, package name, service and provider type names.
  37  * It also avoids taking a defensive copy of any collection.
  38  *
  39  * @see jdk.tools.jlink.internal.plugins.SystemModulesPlugin
  40  */
  41 public final class SystemModules {
  42     /**
  43      * Name of the system modules.
  44      *
  45      * This array provides a way for SystemModuleFinder to fallback
  46      * and read module-info.class from the run-time image instead of
  47      * the fastpath.
  48      */
  49     public static final String[] MODULE_NAMES = new String[0];
  50 
  51     /**
  52      * Number of packages in the boot layer from the installed modules.
  53      *
  54      * Don't make it final to avoid inlining during compile time as
  55      * the value will be changed at jlink time.
  56      */
  57     public static int PACKAGES_IN_BOOT_LAYER = 1024;
  58 
  59     /**
  60      * @return {@code false} if there are no split packages in the run-time
  61      *         image, {@code true} if there are or if it's not been checked.
  62      */
  63     public static boolean hasSplitPackages() {
  64         return true;
  65     }
  66 
  67     /**
  68      * Returns a non-empty array of ModuleDescriptors in the run-time image.
  69      *
  70      * When running an exploded image it returns an empty array.
  71      */
  72     public static ModuleDescriptor[] descriptors() {
  73         throw new InternalError("expected to be overridden at link time");
  74     }
  75 
  76     /**
  77      * Returns a non-empty array of ModuleHashes recorded in each module
  78      * in the run-time image.
  79      *
  80      * When running an exploded image it returns an empty array.
  81      */
  82     public static ModuleHashes[] hashes() {
  83         throw new InternalError("expected to be overridden at link time");
  84     }
  85 
  86     /**
  87      * Returns a non-empty array of ModuleResolutions in the run-time image.
  88      */
  89     public static ModuleResolution[] moduleResolutions() {
  90         throw new InternalError("expected to be overridden at link time");
  91     }
  92 }