< prev index next >

src/hotspot/share/classfile/moduleEntry.cpp

Print this page


  40 #include "utilities/growableArray.hpp"
  41 #include "utilities/hashtable.inline.hpp"
  42 #include "utilities/ostream.hpp"
  43 
  44 ModuleEntry* ModuleEntryTable::_javabase_module = NULL;
  45 
  46 oop ModuleEntry::module() const { return _module.resolve(); }
  47 
  48 void ModuleEntry::set_location(Symbol* location) {
  49   if (_location != NULL) {
  50     // _location symbol's refcounts are managed by ModuleEntry,
  51     // must decrement the old one before updating.
  52     _location->decrement_refcount();
  53   }
  54 
  55   _location = location;
  56 
  57   if (location != NULL) {
  58     location->increment_refcount();
  59     CDS_ONLY(if (UseSharedSpaces) {
  60         _shared_path_index = FileMapInfo::get_module_shared_path_index(_location);
  61       });
  62   }
  63 }
  64 
  65 // Return true if the module's version should be displayed in error messages,
  66 // logging, etc.
  67 // Return false if the module's version is null, if it is unnamed, or if the
  68 // module is not an upgradeable module.
  69 // Detect if the module is not upgradeable by checking:
  70 //     1. Module location is "jrt:/java." and its loader is boot or platform
  71 //     2. Module location is "jrt:/jdk.", its loader is one of the builtin loaders
  72 //        and its version is the same as module java.base's version
  73 // The above check is imprecise but should work in almost all cases.
  74 bool ModuleEntry::should_show_version() {
  75   if (version() == NULL || !is_named()) return false;
  76 
  77   if (location() != NULL) {
  78     ResourceMark rm;
  79     const char* loc = location()->as_C_string();
  80     ClassLoaderData* cld = loader_data();




  40 #include "utilities/growableArray.hpp"
  41 #include "utilities/hashtable.inline.hpp"
  42 #include "utilities/ostream.hpp"
  43 
  44 ModuleEntry* ModuleEntryTable::_javabase_module = NULL;
  45 
  46 oop ModuleEntry::module() const { return _module.resolve(); }
  47 
  48 void ModuleEntry::set_location(Symbol* location) {
  49   if (_location != NULL) {
  50     // _location symbol's refcounts are managed by ModuleEntry,
  51     // must decrement the old one before updating.
  52     _location->decrement_refcount();
  53   }
  54 
  55   _location = location;
  56 
  57   if (location != NULL) {
  58     location->increment_refcount();
  59     CDS_ONLY(if (UseSharedSpaces) {
  60         _shared_path_index = FileMapInfo::get_module_shared_path_index(location);
  61       });
  62   }
  63 }
  64 
  65 // Return true if the module's version should be displayed in error messages,
  66 // logging, etc.
  67 // Return false if the module's version is null, if it is unnamed, or if the
  68 // module is not an upgradeable module.
  69 // Detect if the module is not upgradeable by checking:
  70 //     1. Module location is "jrt:/java." and its loader is boot or platform
  71 //     2. Module location is "jrt:/jdk.", its loader is one of the builtin loaders
  72 //        and its version is the same as module java.base's version
  73 // The above check is imprecise but should work in almost all cases.
  74 bool ModuleEntry::should_show_version() {
  75   if (version() == NULL || !is_named()) return false;
  76 
  77   if (location() != NULL) {
  78     ResourceMark rm;
  79     const char* loc = location()->as_C_string();
  80     ClassLoaderData* cld = loader_data();


< prev index next >