jdk/src/java.base/share/classes/java/lang/StackTraceElement.java
changeset 44545 83b611b88ac8
parent 43712 5dfd0950317c
equal deleted inserted replaced
44480:2c33418a6d57 44545:83b611b88ac8
    31 import jdk.internal.module.ModuleReferenceImpl;
    31 import jdk.internal.module.ModuleReferenceImpl;
    32 
    32 
    33 import java.lang.module.ModuleDescriptor.Version;
    33 import java.lang.module.ModuleDescriptor.Version;
    34 import java.lang.module.ModuleReference;
    34 import java.lang.module.ModuleReference;
    35 import java.lang.module.ResolvedModule;
    35 import java.lang.module.ResolvedModule;
    36 import java.lang.reflect.Layer;
       
    37 import java.lang.reflect.Module;
       
    38 import java.util.HashSet;
    36 import java.util.HashSet;
    39 import java.util.Objects;
    37 import java.util.Objects;
    40 import java.util.Optional;
    38 import java.util.Optional;
    41 import java.util.Set;
    39 import java.util.Set;
    42 
    40 
   189      * @return the module name of the {@code Module} containing the execution
   187      * @return the module name of the {@code Module} containing the execution
   190      *         point represented by this stack trace element; {@code null}
   188      *         point represented by this stack trace element; {@code null}
   191      *         if the module name is not available.
   189      *         if the module name is not available.
   192      * @since 9
   190      * @since 9
   193      * @spec JPMS
   191      * @spec JPMS
   194      * @see java.lang.reflect.Module#getName()
   192      * @see Module#getName()
   195      */
   193      */
   196     public String getModuleName() {
   194     public String getModuleName() {
   197         return moduleName;
   195         return moduleName;
   198     }
   196     }
   199 
   197 
   478         // return true if module system is not initialized as the code
   476         // return true if module system is not initialized as the code
   479         // must be in java.base
   477         // must be in java.base
   480         if (!VM.isModuleSystemInited())
   478         if (!VM.isModuleSystemInited())
   481             return true;
   479             return true;
   482 
   480 
   483         return Layer.boot() == m.getLayer() && HashedModules.contains(m);
   481         return ModuleLayer.boot() == m.getLayer() && HashedModules.contains(m);
   484     }
   482     }
   485 
   483 
   486     /*
   484     /*
   487      * Finds JDK non-upgradeable modules, i.e. the modules that are
   485      * Finds JDK non-upgradeable modules, i.e. the modules that are
   488      * included in the hashes in java.base.
   486      * included in the hashes in java.base.
   490     private static class HashedModules {
   488     private static class HashedModules {
   491         static Set<String> HASHED_MODULES = hashedModules();
   489         static Set<String> HASHED_MODULES = hashedModules();
   492 
   490 
   493         static Set<String> hashedModules() {
   491         static Set<String> hashedModules() {
   494 
   492 
   495             Optional<ResolvedModule> resolvedModule = Layer.boot()
   493             Optional<ResolvedModule> resolvedModule = ModuleLayer.boot()
   496                     .configuration()
   494                     .configuration()
   497                     .findModule("java.base");
   495                     .findModule("java.base");
   498             assert resolvedModule.isPresent();
   496             assert resolvedModule.isPresent();
   499             ModuleReference mref = resolvedModule.get().reference();
   497             ModuleReference mref = resolvedModule.get().reference();
   500             assert mref instanceof ModuleReferenceImpl;
   498             assert mref instanceof ModuleReferenceImpl;