162 }
163
164 size_t FileMapInfo::FileMapHeader::data_size() {
165 return SharedClassUtil::file_map_header_size() - sizeof(FileMapInfo::FileMapHeaderBase);
166 }
167
168 void FileMapInfo::FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) {
169 _magic = 0xf00baba2;
170 _version = _current_version;
171 _alignment = alignment;
172 _obj_alignment = ObjectAlignmentInBytes;
173 _compact_strings = CompactStrings;
174 _narrow_oop_mode = Universe::narrow_oop_mode();
175 _narrow_oop_shift = Universe::narrow_oop_shift();
176 _max_heap_size = MaxHeapSize;
177 _narrow_klass_base = Universe::narrow_klass_base();
178 _narrow_klass_shift = Universe::narrow_klass_shift();
179 _classpath_entry_table_size = mapinfo->_classpath_entry_table_size;
180 _classpath_entry_table = mapinfo->_classpath_entry_table;
181 _classpath_entry_size = mapinfo->_classpath_entry_size;
182 _num_patch_mod_prefixes = ClassLoader::num_patch_mod_prefixes();
183
184 // The following fields are for sanity checks for whether this archive
185 // will function correctly with this JVM and the bootclasspath it's
186 // invoked with.
187
188 // JVM version string ... changes on each build.
189 get_header_version(_jvm_ident);
190 }
191
192 void FileMapInfo::allocate_classpath_entry_table() {
193 int bytes = 0;
194 int count = 0;
195 char* strptr = NULL;
196 char* strptr_max = NULL;
197 Thread* THREAD = Thread::current();
198
199 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
200 size_t entry_size = SharedClassUtil::shared_class_path_entry_size();
201
202 for (int pass=0; pass<2; pass++) {
929 get_header_version(header_version);
930 if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) {
931 log_info(class, path)("expected: %s", header_version);
932 log_info(class, path)("actual: %s", _jvm_ident);
933 FileMapInfo::fail_continue("The shared archive file was created by a different"
934 " version or build of HotSpot");
935 return false;
936 }
937 if (_obj_alignment != ObjectAlignmentInBytes) {
938 FileMapInfo::fail_continue("The shared archive file's ObjectAlignmentInBytes of %d"
939 " does not equal the current ObjectAlignmentInBytes of " INTX_FORMAT ".",
940 _obj_alignment, ObjectAlignmentInBytes);
941 return false;
942 }
943 if (_compact_strings != CompactStrings) {
944 FileMapInfo::fail_continue("The shared archive file's CompactStrings setting (%s)"
945 " does not equal the current CompactStrings setting (%s).",
946 _compact_strings ? "enabled" : "disabled",
947 CompactStrings ? "enabled" : "disabled");
948 return false;
949 }
950
951 // Check if there is a mismatch in --patch-module entry counts between dump time and run time.
952 // More checks will be performed on individual --patch-module entry in the
953 // SharedPathsMiscInfo::check() function.
954 GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
955 if (patch_mod_args != NULL) {
956 if (_num_patch_mod_prefixes == 0) {
957 FileMapInfo::fail_stop("--patch-module found in run time but none was specified in dump time");
958 }
959 if (patch_mod_args->length() != _num_patch_mod_prefixes) {
960 FileMapInfo::fail_stop("mismatched --patch-module entry counts between dump time and run time");
961 }
962 } else {
963 if (_num_patch_mod_prefixes > 0) {
964 FileMapInfo::fail_stop("--patch-module specified in dump time but none was specified in run time");
965 }
966 }
967
968 return true;
969 }
970
971 bool FileMapInfo::validate_header() {
972 bool status = _header->validate();
973
974 if (status) {
975 if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) {
976 if (!PrintSharedArchiveAndExit) {
977 fail_continue("shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)");
978 status = false;
979 }
980 }
981 }
982
983 if (_paths_misc_info != NULL) {
984 FREE_C_HEAP_ARRAY(char, _paths_misc_info);
985 _paths_misc_info = NULL;
|
162 }
163
164 size_t FileMapInfo::FileMapHeader::data_size() {
165 return SharedClassUtil::file_map_header_size() - sizeof(FileMapInfo::FileMapHeaderBase);
166 }
167
168 void FileMapInfo::FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) {
169 _magic = 0xf00baba2;
170 _version = _current_version;
171 _alignment = alignment;
172 _obj_alignment = ObjectAlignmentInBytes;
173 _compact_strings = CompactStrings;
174 _narrow_oop_mode = Universe::narrow_oop_mode();
175 _narrow_oop_shift = Universe::narrow_oop_shift();
176 _max_heap_size = MaxHeapSize;
177 _narrow_klass_base = Universe::narrow_klass_base();
178 _narrow_klass_shift = Universe::narrow_klass_shift();
179 _classpath_entry_table_size = mapinfo->_classpath_entry_table_size;
180 _classpath_entry_table = mapinfo->_classpath_entry_table;
181 _classpath_entry_size = mapinfo->_classpath_entry_size;
182
183 // The following fields are for sanity checks for whether this archive
184 // will function correctly with this JVM and the bootclasspath it's
185 // invoked with.
186
187 // JVM version string ... changes on each build.
188 get_header_version(_jvm_ident);
189 }
190
191 void FileMapInfo::allocate_classpath_entry_table() {
192 int bytes = 0;
193 int count = 0;
194 char* strptr = NULL;
195 char* strptr_max = NULL;
196 Thread* THREAD = Thread::current();
197
198 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
199 size_t entry_size = SharedClassUtil::shared_class_path_entry_size();
200
201 for (int pass=0; pass<2; pass++) {
928 get_header_version(header_version);
929 if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) {
930 log_info(class, path)("expected: %s", header_version);
931 log_info(class, path)("actual: %s", _jvm_ident);
932 FileMapInfo::fail_continue("The shared archive file was created by a different"
933 " version or build of HotSpot");
934 return false;
935 }
936 if (_obj_alignment != ObjectAlignmentInBytes) {
937 FileMapInfo::fail_continue("The shared archive file's ObjectAlignmentInBytes of %d"
938 " does not equal the current ObjectAlignmentInBytes of " INTX_FORMAT ".",
939 _obj_alignment, ObjectAlignmentInBytes);
940 return false;
941 }
942 if (_compact_strings != CompactStrings) {
943 FileMapInfo::fail_continue("The shared archive file's CompactStrings setting (%s)"
944 " does not equal the current CompactStrings setting (%s).",
945 _compact_strings ? "enabled" : "disabled",
946 CompactStrings ? "enabled" : "disabled");
947 return false;
948 }
949
950 return true;
951 }
952
953 bool FileMapInfo::validate_header() {
954 bool status = _header->validate();
955
956 if (status) {
957 if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) {
958 if (!PrintSharedArchiveAndExit) {
959 fail_continue("shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)");
960 status = false;
961 }
962 }
963 }
964
965 if (_paths_misc_info != NULL) {
966 FREE_C_HEAP_ARRAY(char, _paths_misc_info);
967 _paths_misc_info = NULL;
|