59 public static WhiteBox wb; |
59 public static WhiteBox wb; |
60 public static int offset_magic; // CDSFileMapHeaderBase::_magic |
60 public static int offset_magic; // CDSFileMapHeaderBase::_magic |
61 public static int offset_version; // CDSFileMapHeaderBase::_version |
61 public static int offset_version; // CDSFileMapHeaderBase::_version |
62 public static int offset_jvm_ident; // FileMapHeader::_jvm_ident |
62 public static int offset_jvm_ident; // FileMapHeader::_jvm_ident |
63 public static int sp_offset_crc; // CDSFileMapRegion::_crc |
63 public static int sp_offset_crc; // CDSFileMapRegion::_crc |
64 public static int offset_paths_misc_info_size; |
|
65 public static int file_header_size = -1;// total size of header, variant, need calculation |
64 public static int file_header_size = -1;// total size of header, variant, need calculation |
66 public static int CDSFileMapRegion_size; // size of CDSFileMapRegion |
65 public static int CDSFileMapRegion_size; // size of CDSFileMapRegion |
67 public static int sp_offset; // offset of CDSFileMapRegion |
66 public static int sp_offset; // offset of CDSFileMapRegion |
68 public static int sp_used_offset; // offset of CDSFileMapRegion::_used |
67 public static int sp_used_offset; // offset of CDSFileMapRegion::_used |
69 public static int size_t_size; // size of size_t |
68 public static int size_t_size; // size of size_t |
115 return file_header_size; |
114 return file_header_size; |
116 } |
115 } |
117 // this is not real header size, it is struct size |
116 // this is not real header size, it is struct size |
118 int_size = wb.getOffsetForName("int_size"); |
117 int_size = wb.getOffsetForName("int_size"); |
119 file_header_size = wb.getOffsetForName("file_header_size"); |
118 file_header_size = wb.getOffsetForName("file_header_size"); |
120 offset_paths_misc_info_size = wb.getOffsetForName("FileMapHeader::_paths_misc_info_size") - |
|
121 offset_magic; |
|
122 int path_misc_info_size = (int)readInt(fc, offset_paths_misc_info_size, int_size); |
|
123 file_header_size += path_misc_info_size; |
|
124 System.out.println("offset_paths_misc_info_size = " + offset_paths_misc_info_size); |
|
125 System.out.println("path_misc_info_size = " + path_misc_info_size); |
|
126 System.out.println("file_header_size = " + file_header_size); |
119 System.out.println("file_header_size = " + file_header_size); |
127 file_header_size = (int)align_up_page(file_header_size); |
120 file_header_size = (int)align_up_page(file_header_size); |
128 System.out.println("file_header_size (aligned to page) = " + file_header_size); |
121 System.out.println("file_header_size (aligned to page) = " + file_header_size); |
129 return file_header_size; |
122 return file_header_size; |
130 } |
123 } |
403 output = TestCommon.execCommon(execArgs); |
396 output = TestCommon.execCommon(execArgs); |
404 output.shouldContain("The shared archive file has a bad magic number"); |
397 output.shouldContain("The shared archive file has a bad magic number"); |
405 output.shouldNotContain("Checksum verification failed"); |
398 output.shouldNotContain("Checksum verification failed"); |
406 |
399 |
407 copyFile(orgJsaFile, jsa); |
400 copyFile(orgJsaFile, jsa); |
408 // modify _jvm_ident and _paths_misc_info_size, test should fail |
401 // modify _jvm_ident, test should fail |
409 System.out.println("\n2a. Corrupt _jvm_ident and _paths_misc_info_size, should fail\n"); |
402 System.out.println("\n2a. Corrupt _jvm_ident, should fail\n"); |
410 modifyJvmIdent(); |
403 modifyJvmIdent(); |
411 modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); |
|
412 output = TestCommon.execCommon(execArgs); |
404 output = TestCommon.execCommon(execArgs); |
413 output.shouldContain("The shared archive file was created by a different version or build of HotSpot"); |
405 output.shouldContain("The shared archive file was created by a different version or build of HotSpot"); |
414 output.shouldNotContain("Checksum verification failed"); |
406 output.shouldNotContain("Checksum verification failed"); |
415 |
407 |
416 copyFile(orgJsaFile, jsa); |
408 copyFile(orgJsaFile, jsa); |
420 output = TestCommon.execAuto(execArgs); |
412 output = TestCommon.execAuto(execArgs); |
421 output.shouldContain("The shared archive file was created by a different version or build of HotSpot"); |
413 output.shouldContain("The shared archive file was created by a different version or build of HotSpot"); |
422 output.shouldContain("Hello World"); |
414 output.shouldContain("Hello World"); |
423 |
415 |
424 copyFile(orgJsaFile, jsa); |
416 copyFile(orgJsaFile, jsa); |
425 // modify _magic and _paths_misc_info_size, test should fail |
417 // modify _magic, test should fail |
426 System.out.println("\n2c. Corrupt _magic and _paths_misc_info_size, should fail\n"); |
418 System.out.println("\n2c. Corrupt _magic, should fail\n"); |
427 modifyHeaderIntField(offset_magic, 0x00000000); |
419 modifyHeaderIntField(offset_magic, 0x00000000); |
428 modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); |
|
429 output = TestCommon.execCommon(execArgs); |
420 output = TestCommon.execCommon(execArgs); |
430 output.shouldContain("The shared archive file has a bad magic number"); |
421 output.shouldContain("The shared archive file has a bad magic number"); |
431 output.shouldNotContain("Checksum verification failed"); |
422 output.shouldNotContain("Checksum verification failed"); |
432 |
423 |
433 copyFile(orgJsaFile, jsa); |
424 copyFile(orgJsaFile, jsa); |
434 // modify _version and _paths_misc_info_size, test should fail |
425 // modify _version, test should fail |
435 System.out.println("\n2d. Corrupt _version and _paths_misc_info_size, should fail\n"); |
426 System.out.println("\n2d. Corrupt _version, should fail\n"); |
436 modifyHeaderIntField(offset_version, 0x00000000); |
427 modifyHeaderIntField(offset_version, 0x00000000); |
437 modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); |
|
438 output = TestCommon.execCommon(execArgs); |
428 output = TestCommon.execCommon(execArgs); |
439 output.shouldContain("The shared archive file has the wrong version"); |
429 output.shouldContain("The shared archive file has the wrong version"); |
440 output.shouldNotContain("Checksum verification failed"); |
430 output.shouldNotContain("Checksum verification failed"); |
441 |
431 |
442 File newJsaFile = null; |
432 File newJsaFile = null; |