366 if (has_parameter_annotations()) offset++; |
366 if (has_parameter_annotations()) offset++; |
367 if (has_type_annotations()) offset++; |
367 if (has_type_annotations()) offset++; |
368 return (AnnotationArray**)constMethod_end() - offset; |
368 return (AnnotationArray**)constMethod_end() - offset; |
369 } |
369 } |
370 |
370 |
|
371 Array<u1>* copy_annotations(ClassLoaderData* loader_data, AnnotationArray* from, TRAPS) { |
|
372 int length = from->length(); |
|
373 Array<u1>* a = MetadataFactory::new_array<u1>(loader_data, length, 0, CHECK_NULL); |
|
374 memcpy((void*)a->adr_at(0), (void*)from->adr_at(0), length); |
|
375 return a; |
|
376 } |
|
377 |
371 // copy annotations from 'cm' to 'this' |
378 // copy annotations from 'cm' to 'this' |
372 void ConstMethod::copy_annotations_from(ConstMethod* cm) { |
379 // Must make copy because these are deallocated with their constMethod, if redefined. |
|
380 void ConstMethod::copy_annotations_from(ClassLoaderData* loader_data, ConstMethod* cm, TRAPS) { |
|
381 Array<u1>* a; |
373 if (cm->has_method_annotations()) { |
382 if (cm->has_method_annotations()) { |
374 assert(has_method_annotations(), "should be allocated already"); |
383 assert(has_method_annotations(), "should be allocated already"); |
375 set_method_annotations(cm->method_annotations()); |
384 a = copy_annotations(loader_data, cm->method_annotations(), CHECK); |
|
385 set_method_annotations(a); |
376 } |
386 } |
377 if (cm->has_parameter_annotations()) { |
387 if (cm->has_parameter_annotations()) { |
378 assert(has_parameter_annotations(), "should be allocated already"); |
388 assert(has_parameter_annotations(), "should be allocated already"); |
379 set_parameter_annotations(cm->parameter_annotations()); |
389 a = copy_annotations(loader_data, cm->parameter_annotations(), CHECK); |
|
390 set_parameter_annotations(a); |
380 } |
391 } |
381 if (cm->has_type_annotations()) { |
392 if (cm->has_type_annotations()) { |
382 assert(has_type_annotations(), "should be allocated already"); |
393 assert(has_type_annotations(), "should be allocated already"); |
383 set_type_annotations(cm->type_annotations()); |
394 a = copy_annotations(loader_data, cm->type_annotations(), CHECK); |
|
395 set_type_annotations(a); |
384 } |
396 } |
385 if (cm->has_default_annotations()) { |
397 if (cm->has_default_annotations()) { |
386 assert(has_default_annotations(), "should be allocated already"); |
398 assert(has_default_annotations(), "should be allocated already"); |
387 set_default_annotations(cm->default_annotations()); |
399 a = copy_annotations(loader_data, cm->default_annotations(), CHECK); |
|
400 set_default_annotations(a); |
388 } |
401 } |
389 } |
402 } |
390 |
403 |
391 // Printing |
404 // Printing |
392 |
405 |