189 // } |
189 // } |
190 attr_size += 2 + 4 + 2 + local_variable_table_length * (2 + 2 + 2 + 2 + 2); |
190 attr_size += 2 + 4 + 2 + local_variable_table_length * (2 + 2 + 2 + 2 + 2); |
191 } |
191 } |
192 } |
192 } |
193 |
193 |
194 typeArrayHandle exception_table(thread(), const_method->exception_table()); |
194 ExceptionTable exception_table(method()); |
195 int exception_table_length = exception_table->length(); |
195 int exception_table_length = exception_table.length(); |
196 int exception_table_entries = exception_table_length / 4; |
|
197 int code_size = const_method->code_size(); |
196 int code_size = const_method->code_size(); |
198 int size = |
197 int size = |
199 2+2+4 + // max_stack, max_locals, code_length |
198 2+2+4 + // max_stack, max_locals, code_length |
200 code_size + // code |
199 code_size + // code |
201 2 + // exception_table_length |
200 2 + // exception_table_length |
202 (2+2+2+2) * exception_table_entries + // exception_table |
201 (2+2+2+2) * exception_table_length + // exception_table |
203 2 + // attributes_count |
202 2 + // attributes_count |
204 attr_size; // attributes |
203 attr_size; // attributes |
205 |
204 |
206 write_attribute_name_index("Code"); |
205 write_attribute_name_index("Code"); |
207 write_u4(size); |
206 write_u4(size); |
208 write_u2(method->max_stack()); |
207 write_u2(method->max_stack()); |
209 write_u2(method->max_locals()); |
208 write_u2(method->max_locals()); |
210 write_u4(code_size); |
209 write_u4(code_size); |
211 copy_bytecodes(method, (unsigned char*)writeable_address(code_size)); |
210 copy_bytecodes(method, (unsigned char*)writeable_address(code_size)); |
212 write_u2(exception_table_entries); |
211 write_u2(exception_table_length); |
213 for (int index = 0; index < exception_table_length; ) { |
212 for (int index = 0; index < exception_table_length; index++) { |
214 write_u2(exception_table->int_at(index++)); |
213 write_u2(exception_table.start_pc(index)); |
215 write_u2(exception_table->int_at(index++)); |
214 write_u2(exception_table.end_pc(index)); |
216 write_u2(exception_table->int_at(index++)); |
215 write_u2(exception_table.handler_pc(index)); |
217 write_u2(exception_table->int_at(index++)); |
216 write_u2(exception_table.catch_type_index(index)); |
218 } |
217 } |
219 write_u2(attr_count); |
218 write_u2(attr_count); |
220 if (line_num_cnt != 0) { |
219 if (line_num_cnt != 0) { |
221 write_line_number_table_attribute(method, line_num_cnt); |
220 write_line_number_table_attribute(method, line_num_cnt); |
222 } |
221 } |