src/hotspot/share/classfile/sharedClassUtil.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff src/hotspot/share/classfile

src/hotspot/share/classfile/sharedClassUtil.cpp

Print this page
rev 49650 : [mq]: module_path


  76           assert(*(value+1) == ' ', "Unrecognized format" );
  77           if (strstr((char*)attr, "-Digest") != NULL) {
  78             isSigned = true;
  79             break;
  80           }
  81         }
  82         *_current = '\n'; // restore
  83         attr = _current + 1;
  84       }
  85       _current ++;
  86     }
  87     return isSigned;
  88   }
  89 };
  90 
  91 void SharedPathsMiscInfoExt::print_path(outputStream* out, int type, const char* path) {
  92   switch(type) {
  93   case APP:
  94     ClassLoader::trace_class_path("Expecting -Djava.class.path=", path);
  95     break;



  96   default:
  97     SharedPathsMiscInfo::print_path(out, type, path);
  98   }
  99 }
 100 
 101 bool SharedPathsMiscInfoExt::check(jint type, const char* path) {
 102 
 103   switch (type) {
 104   case APP:
 105     {
 106       // Prefix is OK: E.g., dump with -cp foo.jar, but run with -cp foo.jar:bar.jar
 107       size_t len = strlen(path);
 108       const char *appcp = Arguments::get_appclasspath();
 109       assert(appcp != NULL, "NULL app classpath");
 110       size_t appcp_len = strlen(appcp);
 111       if (appcp_len < len) {
 112         return fail("Run time APP classpath is shorter than the one at dump time: ", appcp);
 113       }
 114       ResourceMark rm;
 115       char* tmp_path;


 150       isSigned = stream->check_is_signed();
 151       if (isSigned) {
 152         ent->_is_signed = true;
 153       } else {
 154         // Copy the manifest into the shared archive
 155         manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK);
 156         Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data,
 157                                                         manifest_size,
 158                                                         THREAD);
 159         char* p = (char*)(buf->data());
 160         memcpy(p, manifest, manifest_size);
 161         ent->set_manifest(buf);
 162         ent->_is_signed = false;
 163       }
 164     }
 165   }
 166 }
 167 
 168 void SharedClassUtil::initialize(TRAPS) {
 169   if (UseSharedSpaces) {
 170     int size = FileMapInfo::get_number_of_share_classpaths();
 171     if (size > 0) {
 172       SystemDictionaryShared::allocate_shared_data_arrays(size, THREAD);
 173       if (!DumpSharedSpaces) {
 174         FileMapHeaderExt* header = (FileMapHeaderExt*)FileMapInfo::current_info()->header();
 175         ClassLoaderExt::init_paths_start_index(header->_app_paths_start_index);

 176       }
 177     }
 178   }
 179 
 180   if (DumpSharedSpaces) {
 181     if (SharedArchiveConfigFile) {
 182       read_extra_data(SharedArchiveConfigFile, THREAD);
 183     }
 184   }
 185 }
 186 
 187 void SharedClassUtil::read_extra_data(const char* filename, TRAPS) {
 188   HashtableTextDump reader(filename);
 189   reader.check_version("VERSION: 1.0");
 190 
 191   while (reader.remain() > 0) {
 192     int utf8_length;
 193     int prefix_type = reader.scan_prefix(&utf8_length);
 194     ResourceMark rm(THREAD);
 195     char* utf8_buffer = NEW_RESOURCE_ARRAY(char, utf8_length);
 196     reader.get_utf8(utf8_buffer, utf8_length);
 197 
 198     if (prefix_type == HashtableTextDump::SymbolPrefix) {
 199       SymbolTable::new_symbol(utf8_buffer, utf8_length, THREAD);
 200     } else{
 201       assert(prefix_type == HashtableTextDump::StringPrefix, "Sanity");
 202       utf8_buffer[utf8_length] = '\0';
 203       oop s = StringTable::intern(utf8_buffer, THREAD);
 204     }
 205   }
 206 }
 207 
 208 bool SharedClassUtil::is_classpath_entry_signed(int classpath_index) {
 209   assert(classpath_index >= 0, "Sanity");
 210   SharedClassPathEntryExt* ent = (SharedClassPathEntryExt*)
 211     FileMapInfo::shared_classpath(classpath_index);
 212   return ent->_is_signed;
 213 }
 214 
 215 void FileMapHeaderExt::populate(FileMapInfo* mapinfo, size_t alignment) {
 216   FileMapInfo::FileMapHeader::populate(mapinfo, alignment);
 217 
 218   ClassLoaderExt::finalize_shared_paths_misc_info();
 219   _app_paths_start_index = ClassLoaderExt::app_paths_start_index();

 220 
 221   _verify_local = BytecodeVerificationLocal;
 222   _verify_remote = BytecodeVerificationRemote;
 223   _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
 224 }
 225 
 226 bool FileMapHeaderExt::validate() {
 227   if (UseAppCDS) {
 228     const char* prop = Arguments::get_property("java.system.class.loader");
 229     if (prop != NULL) {
 230       warning("UseAppCDS is disabled because the java.system.class.loader property is specified (value = \"%s\"). "
 231               "To enable UseAppCDS, this property must be not be set", prop);
 232       UseAppCDS = false;
 233     }
 234   }
 235 
 236   if (!FileMapInfo::FileMapHeader::validate()) {
 237     return false;
 238   }
 239 


  76           assert(*(value+1) == ' ', "Unrecognized format" );
  77           if (strstr((char*)attr, "-Digest") != NULL) {
  78             isSigned = true;
  79             break;
  80           }
  81         }
  82         *_current = '\n'; // restore
  83         attr = _current + 1;
  84       }
  85       _current ++;
  86     }
  87     return isSigned;
  88   }
  89 };
  90 
  91 void SharedPathsMiscInfoExt::print_path(outputStream* out, int type, const char* path) {
  92   switch(type) {
  93   case APP:
  94     ClassLoader::trace_class_path("Expecting -Djava.class.path=", path);
  95     break;
  96   case MODULE:
  97     ClassLoader::trace_class_path("Checking module path: ", path);
  98     break;
  99   default:
 100     SharedPathsMiscInfo::print_path(out, type, path);
 101   }
 102 }
 103 
 104 bool SharedPathsMiscInfoExt::check(jint type, const char* path) {
 105 
 106   switch (type) {
 107   case APP:
 108     {
 109       // Prefix is OK: E.g., dump with -cp foo.jar, but run with -cp foo.jar:bar.jar
 110       size_t len = strlen(path);
 111       const char *appcp = Arguments::get_appclasspath();
 112       assert(appcp != NULL, "NULL app classpath");
 113       size_t appcp_len = strlen(appcp);
 114       if (appcp_len < len) {
 115         return fail("Run time APP classpath is shorter than the one at dump time: ", appcp);
 116       }
 117       ResourceMark rm;
 118       char* tmp_path;


 153       isSigned = stream->check_is_signed();
 154       if (isSigned) {
 155         ent->_is_signed = true;
 156       } else {
 157         // Copy the manifest into the shared archive
 158         manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK);
 159         Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data,
 160                                                         manifest_size,
 161                                                         THREAD);
 162         char* p = (char*)(buf->data());
 163         memcpy(p, manifest, manifest_size);
 164         ent->set_manifest(buf);
 165         ent->_is_signed = false;
 166       }
 167     }
 168   }
 169 }
 170 
 171 void SharedClassUtil::initialize(TRAPS) {
 172   if (UseSharedSpaces) {
 173     int size = FileMapInfo::get_number_of_shared_paths();
 174     if (size > 0) {
 175       SystemDictionaryShared::allocate_shared_data_arrays(size, THREAD);
 176       if (!DumpSharedSpaces) {
 177         FileMapHeaderExt* header = (FileMapHeaderExt*)FileMapInfo::current_info()->header();
 178         ClassLoaderExt::init_paths_start_index(header->_app_class_paths_start_index);
 179         ClassLoaderExt::init_app_module_paths_start_index(header->_app_module_paths_start_index);
 180       }
 181     }
 182   }
 183 
 184   if (DumpSharedSpaces) {
 185     if (SharedArchiveConfigFile) {
 186       read_extra_data(SharedArchiveConfigFile, THREAD);
 187     }
 188   }
 189 }
 190 
 191 void SharedClassUtil::read_extra_data(const char* filename, TRAPS) {
 192   HashtableTextDump reader(filename);
 193   reader.check_version("VERSION: 1.0");
 194 
 195   while (reader.remain() > 0) {
 196     int utf8_length;
 197     int prefix_type = reader.scan_prefix(&utf8_length);
 198     ResourceMark rm(THREAD);
 199     char* utf8_buffer = NEW_RESOURCE_ARRAY(char, utf8_length);
 200     reader.get_utf8(utf8_buffer, utf8_length);
 201 
 202     if (prefix_type == HashtableTextDump::SymbolPrefix) {
 203       SymbolTable::new_symbol(utf8_buffer, utf8_length, THREAD);
 204     } else{
 205       assert(prefix_type == HashtableTextDump::StringPrefix, "Sanity");
 206       utf8_buffer[utf8_length] = '\0';
 207       oop s = StringTable::intern(utf8_buffer, THREAD);
 208     }
 209   }
 210 }
 211 
 212 bool SharedClassUtil::is_classpath_entry_signed(int classpath_index) {
 213   assert(classpath_index >= 0, "Sanity");
 214   SharedClassPathEntryExt* ent = (SharedClassPathEntryExt*)
 215     FileMapInfo::shared_path(classpath_index);
 216   return ent->_is_signed;
 217 }
 218 
 219 void FileMapHeaderExt::populate(FileMapInfo* mapinfo, size_t alignment) {
 220   FileMapInfo::FileMapHeader::populate(mapinfo, alignment);
 221 
 222   ClassLoaderExt::finalize_shared_paths_misc_info();
 223   _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
 224   _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
 225 
 226   _verify_local = BytecodeVerificationLocal;
 227   _verify_remote = BytecodeVerificationRemote;
 228   _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
 229 }
 230 
 231 bool FileMapHeaderExt::validate() {
 232   if (UseAppCDS) {
 233     const char* prop = Arguments::get_property("java.system.class.loader");
 234     if (prop != NULL) {
 235       warning("UseAppCDS is disabled because the java.system.class.loader property is specified (value = \"%s\"). "
 236               "To enable UseAppCDS, this property must be not be set", prop);
 237       UseAppCDS = false;
 238     }
 239   }
 240 
 241   if (!FileMapInfo::FileMapHeader::validate()) {
 242     return false;
 243   }
 244 
src/hotspot/share/classfile/sharedClassUtil.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File