src/hotspot/share/classfile/classLoaderExt.hpp
changeset 49739 00805b129186
parent 49341 4ad0085ad6d2
child 49931 840e26123940
equal deleted inserted replaced
49738:a7bc87a63dd8 49739:00805b129186
    24 
    24 
    25 #ifndef SHARE_VM_CLASSFILE_CLASSLOADEREXT_HPP
    25 #ifndef SHARE_VM_CLASSFILE_CLASSLOADEREXT_HPP
    26 #define SHARE_VM_CLASSFILE_CLASSLOADEREXT_HPP
    26 #define SHARE_VM_CLASSFILE_CLASSLOADEREXT_HPP
    27 
    27 
    28 #include "classfile/classLoader.hpp"
    28 #include "classfile/classLoader.hpp"
       
    29 #include "classfile/moduleEntry.hpp"
    29 #include "utilities/macros.hpp"
    30 #include "utilities/macros.hpp"
    30 
    31 
    31 CDS_ONLY(class SharedPathsMiscInfoExt;)
    32 CDS_ONLY(class SharedPathsMiscInfoExt;)
    32 CDS_ONLY(class ClassListParser;)
    33 CDS_ONLY(class ClassListParser;)
    33 
    34 
    57     Context(const char* class_name, const char* file_name, TRAPS) {
    58     Context(const char* class_name, const char* file_name, TRAPS) {
    58       _class_name = class_name;
    59       _class_name = class_name;
    59       _file_name = file_name;
    60       _file_name = file_name;
    60 #if INCLUDE_CDS
    61 #if INCLUDE_CDS
    61       if (!DumpSharedSpaces && !UseSharedSpaces) {
    62       if (!DumpSharedSpaces && !UseSharedSpaces) {
    62         // Must not modify _app_paths_start_index if we're not using CDS.
    63         // Must not modify _app_class_paths_start_index if we're not using CDS.
    63         assert(_app_paths_start_index == ClassLoaderExt::max_classpath_index, "must be");
    64         assert(_app_class_paths_start_index == ClassLoaderExt::max_classpath_index, "must be");
    64       }
    65       }
    65 #endif
    66 #endif
    66     }
    67     }
    67 
    68 
    68     bool should_verify(int classpath_index) {
    69     bool should_verify(int classpath_index) {
    69       CDS_ONLY(return (classpath_index >= _app_paths_start_index);)
    70       CDS_ONLY(return (classpath_index >= _app_class_paths_start_index);)
    70       NOT_CDS(return false;)
    71       NOT_CDS(return false;)
    71     }
    72     }
    72 
    73 
    73     void record_result(Symbol* class_name,
    74     void record_result(Symbol* class_name,
    74                        const s2 classpath_index,
    75                        const s2 classpath_index,
    80     }
    81     }
    81 
    82 
    82     ~Context() {
    83     ~Context() {
    83 #if INCLUDE_CDS
    84 #if INCLUDE_CDS
    84       if (!DumpSharedSpaces && !UseSharedSpaces) {
    85       if (!DumpSharedSpaces && !UseSharedSpaces) {
    85         // Must not modify app_paths_start_index if we're not using CDS.
    86         // Must not modify app_class_paths_start_index if we're not using CDS.
    86         assert(_app_paths_start_index == ClassLoaderExt::max_classpath_index, "must be");
    87         assert(_app_class_paths_start_index == ClassLoaderExt::max_classpath_index, "must be");
    87       }
    88       }
    88 #endif
    89 #endif
    89     }
    90     }
    90   }; // end ClassLoaderExt::Context
    91   }; // end ClassLoaderExt::Context
    91 
    92 
    92 private:
    93 private:
    93 #if INCLUDE_CDS
    94 #if INCLUDE_CDS
    94   static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size);
    95   static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size);
    95   static void setup_app_search_path(); // Only when -Xshare:dump
    96   static void setup_app_search_path(); // Only when -Xshare:dump
       
    97   static void process_module_table(ModuleEntryTable* met, TRAPS);
       
    98   static void setup_module_search_path(TRAPS);
    96   static SharedPathsMiscInfoExt* shared_paths_misc_info() {
    99   static SharedPathsMiscInfoExt* shared_paths_misc_info() {
    97     return (SharedPathsMiscInfoExt*)_shared_paths_misc_info;
   100     return (SharedPathsMiscInfoExt*)_shared_paths_misc_info;
    98   }
   101   }
    99   static jshort _app_paths_start_index; // index of first app JAR in shared classpath entry table
   102   // index of first app JAR in shared classpath entry table
       
   103   static jshort _app_class_paths_start_index;
       
   104   // index of first modular JAR in shared modulepath entry table
       
   105   static jshort _app_module_paths_start_index;
       
   106 
   100   static bool _has_app_classes;
   107   static bool _has_app_classes;
   101   static bool _has_platform_classes;
   108   static bool _has_platform_classes;
   102 #endif
   109 #endif
   103 
   110 
   104 public:
   111 public:
   114 #endif
   121 #endif
   115     ClassLoader::add_to_boot_append_entries(new_entry);
   122     ClassLoader::add_to_boot_append_entries(new_entry);
   116   }
   123   }
   117 
   124 
   118   static void setup_search_paths() NOT_CDS_RETURN;
   125   static void setup_search_paths() NOT_CDS_RETURN;
       
   126   static void setup_module_paths(TRAPS) NOT_CDS_RETURN;
   119 
   127 
   120 #if INCLUDE_CDS
   128 #if INCLUDE_CDS
   121 private:
   129 private:
   122   static char* read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS);
   130   static char* read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS);
   123   static ClassPathEntry* find_classpath_entry_from_cache(const char* path, TRAPS);
   131   static ClassPathEntry* find_classpath_entry_from_cache(const char* path, TRAPS);
   135     return read_manifest(entry, manifest_size, false, THREAD);
   143     return read_manifest(entry, manifest_size, false, THREAD);
   136   }
   144   }
   137 
   145 
   138   static void finalize_shared_paths_misc_info();
   146   static void finalize_shared_paths_misc_info();
   139 
   147 
   140   static jshort app_paths_start_index() { return _app_paths_start_index; }
   148   static jshort app_class_paths_start_index() { return _app_class_paths_start_index; }
       
   149 
       
   150   static jshort app_module_paths_start_index() { return _app_module_paths_start_index; }
   141 
   151 
   142   static void init_paths_start_index(jshort app_start) {
   152   static void init_paths_start_index(jshort app_start) {
   143     _app_paths_start_index = app_start;
   153     _app_class_paths_start_index = app_start;
       
   154   }
       
   155 
       
   156   static void init_app_module_paths_start_index(jshort module_start) {
       
   157     _app_module_paths_start_index = module_start;
   144   }
   158   }
   145 
   159 
   146   static bool is_boot_classpath(int classpath_index) {
   160   static bool is_boot_classpath(int classpath_index) {
   147     return classpath_index < _app_paths_start_index;
   161     return classpath_index < _app_class_paths_start_index;
   148   }
   162   }
   149 
   163 
   150   static bool has_platform_or_app_classes() {
   164   static bool has_platform_or_app_classes() {
   151     return _has_app_classes || _has_platform_classes;
   165     return _has_app_classes || _has_platform_classes;
   152   }
   166   }