Java Code Examples for jdk.internal.loader.BootLoader#getUnnamedModule()

The following examples show how to use jdk.internal.loader.BootLoader#getUnnamedModule() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceBundle.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * This method will find resource bundles using the legacy mechanism
 * if the caller is unnamed module or the given class loader is
 * not the class loader of the caller module getting the resource
 * bundle, i.e. find the class that is visible to the class loader
 * and properties from unnamed module.
 *
 * The module-aware resource bundle lookup mechanism will load
 * the service providers using the service loader mechanism
 * as well as properties local in the caller module.
 */
private static ResourceBundle getBundleImpl(String baseName,
                                            Locale locale,
                                            Class<?> caller,
                                            ClassLoader loader,
                                            Control control) {
    if (caller == null) {
        throw new InternalError("null caller");
    }
    Module callerModule = caller.getModule();

    // get resource bundles for a named module only if loader is the module's class loader
    if (callerModule.isNamed() && loader == getLoader(callerModule)) {
        return getBundleImpl(callerModule, callerModule, baseName, locale, control);
    }

    // find resource bundles from unnamed module of given class loader
    // Java agent can add to the bootclasspath e.g. via
    // java.lang.instrument.Instrumentation and load classes in unnamed module.
    // It may call RB::getBundle that will end up here with loader == null.
    Module unnamedModule = loader != null
        ? loader.getUnnamedModule()
        : BootLoader.getUnnamedModule();

    return getBundleImpl(callerModule, unnamedModule, baseName, locale, control);
}
 
Example 2
Source File: ResourceBundle.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method will find resource bundles using the legacy mechanism
 * if the caller is unnamed module or the given class loader is
 * not the class loader of the caller module getting the resource
 * bundle, i.e. find the class that is visible to the class loader
 * and properties from unnamed module.
 *
 * The module-aware resource bundle lookup mechanism will load
 * the service providers using the service loader mechanism
 * as well as properties local in the caller module.
 */
private static ResourceBundle getBundleImpl(String baseName,
                                            Locale locale,
                                            Class<?> caller,
                                            ClassLoader loader,
                                            Control control) {
    if (caller == null) {
        throw new InternalError("null caller");
    }
    Module callerModule = caller.getModule();

    // get resource bundles for a named module only if loader is the module's class loader
    if (callerModule.isNamed() && loader == getLoader(callerModule)) {
        return getBundleImpl(callerModule, callerModule, baseName, locale, control);
    }

    // find resource bundles from unnamed module of given class loader
    // Java agent can add to the bootclasspath e.g. via
    // java.lang.instrument.Instrumentation and load classes in unnamed module.
    // It may call RB::getBundle that will end up here with loader == null.
    Module unnamedModule = loader != null
        ? loader.getUnnamedModule()
        : BootLoader.getUnnamedModule();

    return getBundleImpl(callerModule, unnamedModule, baseName, locale, control);
}
 
Example 3
Source File: Package.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Construct a package instance for an unnamed module
 * with the specified version information.
 *
 * @apiNote
 * This method should not be called to define a Package for named module.
 *
 * @param name the name of the package
 * @param spectitle the title of the specification
 * @param specversion the version of the specification
 * @param specvendor the organization that maintains the specification
 * @param impltitle the title of the implementation
 * @param implversion the version of the implementation
 * @param implvendor the organization that maintains the implementation
 * @param sealbase code source where this Package comes from
 * @param loader defining class loader
 */
Package(String name,
        String spectitle, String specversion, String specvendor,
        String impltitle, String implversion, String implvendor,
        URL sealbase, ClassLoader loader)
{
    super(Objects.requireNonNull(name),
          loader != null ? loader.getUnnamedModule()
                         : BootLoader.getUnnamedModule());

    this.versionInfo = VersionInfo.getInstance(spectitle, specversion,
                                               specvendor, impltitle,
                                               implversion, implvendor,
                                               sealbase);
}
 
Example 4
Source File: Package.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Construct a package instance for an unnamed module
 * with the specified version information.
 *
 * @apiNote
 * This method should not be called to define a Package for named module.
 *
 * @param name the name of the package
 * @param spectitle the title of the specification
 * @param specversion the version of the specification
 * @param specvendor the organization that maintains the specification
 * @param impltitle the title of the implementation
 * @param implversion the version of the implementation
 * @param implvendor the organization that maintains the implementation
 * @param sealbase code source where this Package comes from
 * @param loader defining class loader
 */
Package(String name,
        String spectitle, String specversion, String specvendor,
        String impltitle, String implversion, String implvendor,
        URL sealbase, ClassLoader loader)
{
    super(Objects.requireNonNull(name),
          loader != null ? loader.getUnnamedModule()
                         : BootLoader.getUnnamedModule());

    this.versionInfo = VersionInfo.getInstance(spectitle, specversion,
                                               specvendor, impltitle,
                                               implversion, implvendor,
                                               sealbase);
}