# HG changeset patch # User coleenp # Date 1364386790 14400 # Node ID 0c3ee6f1fa23d9960d26c3a906ef6317ce2a63e6 # Parent 23f2d309e8556d1b33ad71bb7b71065f116d9dc1 8009531: Crash when redefining class with annotated method Summary: Neglected to copy the annotations in clone_with_new_data when they were moved to ConstMethod. Reviewed-by: acorn, sspitsyn, dcubed diff -r 23f2d309e855 -r 0c3ee6f1fa23 src/share/vm/oops/constMethod.cpp --- a/src/share/vm/oops/constMethod.cpp Tue Mar 26 15:20:05 2013 -0700 +++ b/src/share/vm/oops/constMethod.cpp Wed Mar 27 08:19:50 2013 -0400 @@ -363,6 +363,26 @@ return (AnnotationArray**)constMethod_end() - offset; } +// copy annotations from 'cm' to 'this' +void ConstMethod::copy_annotations_from(ConstMethod* cm) { + if (cm->has_method_annotations()) { + assert(has_method_annotations(), "should be allocated already"); + set_method_annotations(cm->method_annotations()); + } + if (cm->has_parameter_annotations()) { + assert(has_parameter_annotations(), "should be allocated already"); + set_parameter_annotations(cm->parameter_annotations()); + } + if (cm->has_type_annotations()) { + assert(has_type_annotations(), "should be allocated already"); + set_type_annotations(cm->type_annotations()); + } + if (cm->has_default_annotations()) { + assert(has_default_annotations(), "should be allocated already"); + set_default_annotations(cm->default_annotations()); + } +} + // Printing void ConstMethod::print_on(outputStream* st) const { diff -r 23f2d309e855 -r 0c3ee6f1fa23 src/share/vm/oops/constMethod.hpp --- a/src/share/vm/oops/constMethod.hpp Tue Mar 26 15:20:05 2013 -0700 +++ b/src/share/vm/oops/constMethod.hpp Wed Mar 27 08:19:50 2013 -0400 @@ -441,6 +441,9 @@ return has_default_annotations() ? default_annotations()->length() : 0; } + // Copy annotations from other ConstMethod + void copy_annotations_from(ConstMethod* cm); + // byte codes void set_code(address code) { if (code_size() > 0) { diff -r 23f2d309e855 -r 0c3ee6f1fa23 src/share/vm/oops/method.cpp --- a/src/share/vm/oops/method.cpp Tue Mar 26 15:20:05 2013 -0700 +++ b/src/share/vm/oops/method.cpp Wed Mar 27 08:19:50 2013 -0400 @@ -1170,6 +1170,8 @@ newm->set_stackmap_data(stackmap_data); } + // copy annotations over to new method + newcm->copy_annotations_from(cm); return newm; }