2446 CHECK_NULL); |
2446 CHECK_NULL); |
2447 } |
2447 } |
2448 parsed_code_attribute = true; |
2448 parsed_code_attribute = true; |
2449 |
2449 |
2450 // Stack size, locals size, and code size |
2450 // Stack size, locals size, and code size |
2451 if (_major_version == 45 && _minor_version <= 2) { |
2451 cfs->guarantee_more(8, CHECK_NULL); |
2452 cfs->guarantee_more(4, CHECK_NULL); |
2452 max_stack = cfs->get_u2_fast(); |
2453 max_stack = cfs->get_u1_fast(); |
2453 max_locals = cfs->get_u2_fast(); |
2454 max_locals = cfs->get_u1_fast(); |
2454 code_length = cfs->get_u4_fast(); |
2455 code_length = cfs->get_u2_fast(); |
|
2456 } else { |
|
2457 cfs->guarantee_more(8, CHECK_NULL); |
|
2458 max_stack = cfs->get_u2_fast(); |
|
2459 max_locals = cfs->get_u2_fast(); |
|
2460 code_length = cfs->get_u4_fast(); |
|
2461 } |
|
2462 if (_need_verify) { |
2455 if (_need_verify) { |
2463 guarantee_property(args_size <= max_locals, |
2456 guarantee_property(args_size <= max_locals, |
2464 "Arguments can't fit into locals in class file %s", |
2457 "Arguments can't fit into locals in class file %s", |
2465 CHECK_NULL); |
2458 CHECK_NULL); |
2466 guarantee_property(code_length > 0 && code_length <= MAX_CODE_SIZE, |
2459 guarantee_property(code_length > 0 && code_length <= MAX_CODE_SIZE, |
2487 cfs->guarantee_more(2, CHECK_NULL); // code_attributes_count |
2480 cfs->guarantee_more(2, CHECK_NULL); // code_attributes_count |
2488 u2 code_attributes_count = cfs->get_u2_fast(); |
2481 u2 code_attributes_count = cfs->get_u2_fast(); |
2489 |
2482 |
2490 unsigned int calculated_attribute_length = 0; |
2483 unsigned int calculated_attribute_length = 0; |
2491 |
2484 |
2492 if (_major_version > 45 || (_major_version == 45 && _minor_version > 2)) { |
2485 calculated_attribute_length = |
2493 calculated_attribute_length = |
2486 sizeof(max_stack) + sizeof(max_locals) + sizeof(code_length); |
2494 sizeof(max_stack) + sizeof(max_locals) + sizeof(code_length); |
|
2495 } else { |
|
2496 // max_stack, locals and length are smaller in pre-version 45.2 classes |
|
2497 calculated_attribute_length = sizeof(u1) + sizeof(u1) + sizeof(u2); |
|
2498 } |
|
2499 calculated_attribute_length += |
2487 calculated_attribute_length += |
2500 code_length + |
2488 code_length + |
2501 sizeof(exception_table_length) + |
2489 sizeof(exception_table_length) + |
2502 sizeof(code_attributes_count) + |
2490 sizeof(code_attributes_count) + |
2503 exception_table_length * |
2491 exception_table_length * |