401 orgJsaFile = new File(new File(currentDir), "appcds.jsa.bak"); 402 copyFile(jsa, orgJsaFile); 403 404 // modify jsa header, test should fail 405 System.out.println("\n2. Corrupt header, should fail\n"); 406 modifyJsaHeader(jsa); 407 output = TestCommon.execCommon(execArgs); 408 output.shouldContain("The shared archive file has a bad magic number"); 409 output.shouldNotContain("Checksum verification failed"); 410 411 copyFile(orgJsaFile, jsa); 412 // modify _jvm_ident and _paths_misc_info_size, test should fail 413 System.out.println("\n2a. Corrupt _jvm_ident and _paths_misc_info_size, should fail\n"); 414 modifyJvmIdent(); 415 modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); 416 output = TestCommon.execCommon(execArgs); 417 output.shouldContain("The shared archive file was created by a different version or build of HotSpot"); 418 output.shouldNotContain("Checksum verification failed"); 419 420 copyFile(orgJsaFile, jsa); 421 // modify _magic and _paths_misc_info_size, test should fail 422 System.out.println("\n2b. Corrupt _magic and _paths_misc_info_size, should fail\n"); 423 modifyHeaderIntField(offset_magic, 0x00000000); 424 modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); 425 output = TestCommon.execCommon(execArgs); 426 output.shouldContain("The shared archive file has a bad magic number"); 427 output.shouldNotContain("Checksum verification failed"); 428 429 copyFile(orgJsaFile, jsa); 430 // modify _version and _paths_misc_info_size, test should fail 431 System.out.println("\n2c. Corrupt _version and _paths_misc_info_size, should fail\n"); 432 modifyHeaderIntField(offset_version, 0x00000000); 433 modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); 434 output = TestCommon.execCommon(execArgs); 435 output.shouldContain("The shared archive file has the wrong version"); 436 output.shouldNotContain("Checksum verification failed"); 437 438 File newJsaFile = null; 439 // modify content 440 System.out.println("\n3. Corrupt Content, should fail\n"); 441 for (int i=0; i<num_regions; i++) { 442 newJsaFile = new File(TestCommon.getNewArchiveName(shared_region_name[i])); 443 copyFile(orgJsaFile, newJsaFile); 444 TestCommon.setCurrentArchiveName(newJsaFile.toString()); 445 if (modifyJsaContent(i, newJsaFile)) { 446 testAndCheck(verifyExecArgs); 447 } 448 } 449 450 // modify both header and content, test should fail 451 System.out.println("\n4. Corrupt Header and Content, should fail\n"); | 401 orgJsaFile = new File(new File(currentDir), "appcds.jsa.bak"); 402 copyFile(jsa, orgJsaFile); 403 404 // modify jsa header, test should fail 405 System.out.println("\n2. Corrupt header, should fail\n"); 406 modifyJsaHeader(jsa); 407 output = TestCommon.execCommon(execArgs); 408 output.shouldContain("The shared archive file has a bad magic number"); 409 output.shouldNotContain("Checksum verification failed"); 410 411 copyFile(orgJsaFile, jsa); 412 // modify _jvm_ident and _paths_misc_info_size, test should fail 413 System.out.println("\n2a. Corrupt _jvm_ident and _paths_misc_info_size, should fail\n"); 414 modifyJvmIdent(); 415 modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); 416 output = TestCommon.execCommon(execArgs); 417 output.shouldContain("The shared archive file was created by a different version or build of HotSpot"); 418 output.shouldNotContain("Checksum verification failed"); 419 420 copyFile(orgJsaFile, jsa); 421 // modify _jvm_ident and run with -Xshare:auto 422 System.out.println("\n2b. Corrupt _jvm_ident run with -Xshare:auto\n"); 423 modifyJvmIdent(); 424 output = TestCommon.execAuto(execArgs); 425 output.shouldContain("The shared archive file was created by a different version or build of HotSpot"); 426 output.shouldContain("Hello World"); 427 428 copyFile(orgJsaFile, jsa); 429 // modify _magic and _paths_misc_info_size, test should fail 430 System.out.println("\n2c. Corrupt _magic and _paths_misc_info_size, should fail\n"); 431 modifyHeaderIntField(offset_magic, 0x00000000); 432 modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); 433 output = TestCommon.execCommon(execArgs); 434 output.shouldContain("The shared archive file has a bad magic number"); 435 output.shouldNotContain("Checksum verification failed"); 436 437 copyFile(orgJsaFile, jsa); 438 // modify _version and _paths_misc_info_size, test should fail 439 System.out.println("\n2d. Corrupt _version and _paths_misc_info_size, should fail\n"); 440 modifyHeaderIntField(offset_version, 0x00000000); 441 modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); 442 output = TestCommon.execCommon(execArgs); 443 output.shouldContain("The shared archive file has the wrong version"); 444 output.shouldNotContain("Checksum verification failed"); 445 446 File newJsaFile = null; 447 // modify content 448 System.out.println("\n3. Corrupt Content, should fail\n"); 449 for (int i=0; i<num_regions; i++) { 450 newJsaFile = new File(TestCommon.getNewArchiveName(shared_region_name[i])); 451 copyFile(orgJsaFile, newJsaFile); 452 TestCommon.setCurrentArchiveName(newJsaFile.toString()); 453 if (modifyJsaContent(i, newJsaFile)) { 454 testAndCheck(verifyExecArgs); 455 } 456 } 457 458 // modify both header and content, test should fail 459 System.out.println("\n4. Corrupt Header and Content, should fail\n"); |