src/java.base/share/classes/jdk/internal/module/Modules.java
changeset 59133 580fb715b29d
parent 52427 3c6aa484536c
equal deleted inserted replaced
59132:189f47d990b5 59133:580fb715b29d
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package jdk.internal.module;
    26 package jdk.internal.module;
    27 
    27 
       
    28 import java.io.PrintStream;
    28 import java.lang.module.Configuration;
    29 import java.lang.module.Configuration;
    29 import java.lang.module.ModuleDescriptor;
    30 import java.lang.module.ModuleDescriptor;
    30 import java.lang.module.ModuleFinder;
    31 import java.lang.module.ModuleFinder;
    31 import java.lang.module.ModuleReference;
    32 import java.lang.module.ModuleReference;
    32 import java.lang.module.ResolvedModule;
    33 import java.lang.module.ResolvedModule;
    33 import java.net.URI;
    34 import java.net.URI;
    34 import java.security.AccessController;
    35 import java.security.AccessController;
    35 import java.security.PrivilegedAction;
    36 import java.security.PrivilegedAction;
       
    37 import java.util.Collection;
    36 import java.util.List;
    38 import java.util.List;
    37 import java.util.Map;
    39 import java.util.Map;
    38 import java.util.Optional;
    40 import java.util.Optional;
    39 import java.util.Set;
    41 import java.util.Set;
    40 import java.util.function.Function;
    42 import java.util.function.Function;
    41 import java.util.stream.Collectors;
    43 import java.util.stream.Collectors;
    42 
    44 
       
    45 import jdk.internal.access.JavaLangModuleAccess;
    43 import jdk.internal.loader.BootLoader;
    46 import jdk.internal.loader.BootLoader;
    44 import jdk.internal.loader.BuiltinClassLoader;
    47 import jdk.internal.loader.BuiltinClassLoader;
    45 import jdk.internal.loader.ClassLoaders;
    48 import jdk.internal.loader.ClassLoaders;
    46 import jdk.internal.access.JavaLangAccess;
    49 import jdk.internal.access.JavaLangAccess;
    47 import jdk.internal.access.SharedSecrets;
    50 import jdk.internal.access.SharedSecrets;
    59 
    62 
    60 public class Modules {
    63 public class Modules {
    61     private Modules() { }
    64     private Modules() { }
    62 
    65 
    63     private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
    66     private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
       
    67     private static final JavaLangModuleAccess JLMA = SharedSecrets.getJavaLangModuleAccess();
    64 
    68 
    65     /**
    69     /**
    66      * Creates a new Module. The module has the given ModuleDescriptor and
    70      * Creates a new Module. The module has the given ModuleDescriptor and
    67      * is defined to the given class loader.
    71      * is defined to the given class loader.
    68      *
    72      *
   154 
   158 
   155         if (layer != null) {
   159         if (layer != null) {
   156             // update Layer catalog
   160             // update Layer catalog
   157             JLA.getServicesCatalog(layer).addProvider(m, service, impl);
   161             JLA.getServicesCatalog(layer).addProvider(m, service, impl);
   158         }
   162         }
       
   163     }
       
   164 
       
   165     /**
       
   166      * Resolves a collection of root modules, with service binding and the empty
       
   167      * Configuration as the parent to create a Configuration for the boot layer.
       
   168      *
       
   169      * This method is intended to be used to create the Configuration for the
       
   170      * boot layer during startup or at a link-time.
       
   171      */
       
   172     public static Configuration newBootLayerConfiguration(ModuleFinder finder,
       
   173                                                           Collection<String> roots,
       
   174                                                           PrintStream traceOutput)
       
   175     {
       
   176         return JLMA.resolveAndBind(finder, roots, traceOutput);
   159     }
   177     }
   160 
   178 
   161     /**
   179     /**
   162      * Called by the VM when code in the given Module has been transformed by
   180      * Called by the VM when code in the given Module has been transformed by
   163      * an agent and so may have been instrumented to call into supporting
   181      * an agent and so may have been instrumented to call into supporting