8009531: Crash when redefining class with annotated method

Wed, 27 Mar 2013 08:19:50 -0400

author
coleenp
date
Wed, 27 Mar 2013 08:19:50 -0400
changeset 4837
0c3ee6f1fa23
parent 4823
23f2d309e855
child 4839
b601102d00c8

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

src/share/vm/oops/constMethod.cpp file | annotate | diff | comparison | revisions
src/share/vm/oops/constMethod.hpp file | annotate | diff | comparison | revisions
src/share/vm/oops/method.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/oops/constMethod.cpp	Tue Mar 26 15:20:05 2013 -0700
     1.2 +++ b/src/share/vm/oops/constMethod.cpp	Wed Mar 27 08:19:50 2013 -0400
     1.3 @@ -363,6 +363,26 @@
     1.4    return (AnnotationArray**)constMethod_end() - offset;
     1.5  }
     1.6  
     1.7 +// copy annotations from 'cm' to 'this'
     1.8 +void ConstMethod::copy_annotations_from(ConstMethod* cm) {
     1.9 +  if (cm->has_method_annotations()) {
    1.10 +    assert(has_method_annotations(), "should be allocated already");
    1.11 +    set_method_annotations(cm->method_annotations());
    1.12 +  }
    1.13 +  if (cm->has_parameter_annotations()) {
    1.14 +    assert(has_parameter_annotations(), "should be allocated already");
    1.15 +    set_parameter_annotations(cm->parameter_annotations());
    1.16 +  }
    1.17 +  if (cm->has_type_annotations()) {
    1.18 +    assert(has_type_annotations(), "should be allocated already");
    1.19 +    set_type_annotations(cm->type_annotations());
    1.20 +  }
    1.21 +  if (cm->has_default_annotations()) {
    1.22 +    assert(has_default_annotations(), "should be allocated already");
    1.23 +    set_default_annotations(cm->default_annotations());
    1.24 +  }
    1.25 +}
    1.26 +
    1.27  // Printing
    1.28  
    1.29  void ConstMethod::print_on(outputStream* st) const {
     2.1 --- a/src/share/vm/oops/constMethod.hpp	Tue Mar 26 15:20:05 2013 -0700
     2.2 +++ b/src/share/vm/oops/constMethod.hpp	Wed Mar 27 08:19:50 2013 -0400
     2.3 @@ -441,6 +441,9 @@
     2.4      return has_default_annotations() ? default_annotations()->length() : 0;
     2.5    }
     2.6  
     2.7 +  // Copy annotations from other ConstMethod
     2.8 +  void copy_annotations_from(ConstMethod* cm);
     2.9 +
    2.10    // byte codes
    2.11    void    set_code(address code) {
    2.12      if (code_size() > 0) {
     3.1 --- a/src/share/vm/oops/method.cpp	Tue Mar 26 15:20:05 2013 -0700
     3.2 +++ b/src/share/vm/oops/method.cpp	Wed Mar 27 08:19:50 2013 -0400
     3.3 @@ -1170,6 +1170,8 @@
     3.4      newm->set_stackmap_data(stackmap_data);
     3.5    }
     3.6  
     3.7 +  // copy annotations over to new method
     3.8 +  newcm->copy_annotations_from(cm);
     3.9    return newm;
    3.10  }
    3.11  

mercurial