src/hotspot/share/classfile/sharedPathsMiscInfo.cpp
changeset 54927 1512d88b24c6
parent 51439 0517bd2a0eda
child 55524 b279ae9843b8
equal deleted inserted replaced
54926:d4e7ccaf1445 54927:1512d88b24c6
     1 /*
     1 /*
     2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 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.
     7  * published by the Free Software Foundation.
   102   default:
   102   default:
   103     ShouldNotReachHere();
   103     ShouldNotReachHere();
   104   }
   104   }
   105 }
   105 }
   106 
   106 
   107 bool SharedPathsMiscInfo::check() {
   107 bool SharedPathsMiscInfo::check(bool is_static) {
   108   // The whole buffer must be 0 terminated so that we can use strlen and strcmp
   108   // The whole buffer must be 0 terminated so that we can use strlen and strcmp
   109   // without fear.
   109   // without fear.
   110   _end_ptr -= sizeof(jint);
   110   _end_ptr -= sizeof(jint);
   111   if (_cur_ptr >= _end_ptr) {
   111   if (_cur_ptr >= _end_ptr) {
   112     return fail("Truncated archive file header");
   112     return fail("Truncated archive file header");
   114   if (*_end_ptr != 0) {
   114   if (*_end_ptr != 0) {
   115     return fail("Corrupted archive file header");
   115     return fail("Corrupted archive file header");
   116   }
   116   }
   117 
   117 
   118   jshort cur_index = 0;
   118   jshort cur_index = 0;
   119   jshort max_cp_index = FileMapInfo::current_info()->header()->max_used_path_index();
   119   FileMapHeader* header = is_static ? FileMapInfo::current_info()->header() :
   120   jshort module_paths_start_index =
   120                                       FileMapInfo::dynamic_info()->header();
   121     FileMapInfo::current_info()->header()->app_module_paths_start_index();
   121   jshort max_cp_index = header->max_used_path_index();
       
   122   jshort module_paths_start_index = header->app_module_paths_start_index();
   122   while (_cur_ptr < _end_ptr) {
   123   while (_cur_ptr < _end_ptr) {
   123     jint type;
   124     jint type;
   124     const char* path = _cur_ptr;
   125     const char* path = _cur_ptr;
   125     _cur_ptr += strlen(path) + 1;
   126     _cur_ptr += strlen(path) + 1;
   126 
   127 
   134       print_path(&ls, type, path);
   135       print_path(&ls, type, path);
   135       ls.cr();
   136       ls.cr();
   136     }
   137     }
   137     // skip checking the class path(s) which was not referenced during CDS dump
   138     // skip checking the class path(s) which was not referenced during CDS dump
   138     if ((cur_index <= max_cp_index) || (cur_index >= module_paths_start_index)) {
   139     if ((cur_index <= max_cp_index) || (cur_index >= module_paths_start_index)) {
   139       if (!check(type, path)) {
   140       if (!check(type, path, is_static)) {
   140         if (!PrintSharedArchiveAndExit) {
   141         if (!PrintSharedArchiveAndExit) {
   141           return false;
   142           return false;
   142         }
   143         }
   143       } else {
   144       } else {
   144         ClassLoader::trace_class_path("ok");
   145         ClassLoader::trace_class_path("ok");
   169     } );
   170     } );
   170   }
   171   }
   171   return p;
   172   return p;
   172 }
   173 }
   173 
   174 
   174 bool SharedPathsMiscInfo::check(jint type, const char* path) {
   175 bool SharedPathsMiscInfo::check(jint type, const char* path, bool is_static) {
   175   assert(UseSharedSpaces, "runtime only");
   176   assert(UseSharedSpaces, "runtime only");
   176   switch (type) {
   177   switch (type) {
   177   case BOOT_PATH:
   178   case BOOT_PATH:
   178     {
   179     {
   179       //
   180       //
   194       // common cases, the dump time boot path might contain modules_image only.
   195       // common cases, the dump time boot path might contain modules_image only.
   195       char* runtime_boot_path = Arguments::get_sysclasspath();
   196       char* runtime_boot_path = Arguments::get_sysclasspath();
   196       char* rp = skip_first_path_entry(runtime_boot_path);
   197       char* rp = skip_first_path_entry(runtime_boot_path);
   197       char* dp = skip_first_path_entry(path);
   198       char* dp = skip_first_path_entry(path);
   198 
   199 
   199       bool relaxed_check = !FileMapInfo::current_info()->header()->has_platform_or_app_classes();
   200       bool relaxed_check = is_static ?
       
   201                              !FileMapInfo::current_info()->header()->has_platform_or_app_classes() :
       
   202                              !FileMapInfo::dynamic_info()->header()->has_platform_or_app_classes();
   200       if (dp == NULL && rp == NULL) {
   203       if (dp == NULL && rp == NULL) {
   201         break;   // ok, both runtime and dump time boot paths have modules_images only
   204         break;   // ok, both runtime and dump time boot paths have modules_images only
   202       } else if (dp == NULL && rp != NULL && relaxed_check) {
   205       } else if (dp == NULL && rp != NULL && relaxed_check) {
   203         break;   // ok, relaxed check, runtime has extra boot append path entries
   206         break;   // ok, relaxed check, runtime has extra boot append path entries
   204       } else if (dp != NULL && rp != NULL) {
   207       } else if (dp != NULL && rp != NULL) {