提交 a0b353c4 编写于 作者: C coleenp

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
上级 3be34a45
...@@ -363,6 +363,26 @@ AnnotationArray** ConstMethod::default_annotations_addr() const { ...@@ -363,6 +363,26 @@ AnnotationArray** ConstMethod::default_annotations_addr() const {
return (AnnotationArray**)constMethod_end() - offset; 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 // Printing
void ConstMethod::print_on(outputStream* st) const { void ConstMethod::print_on(outputStream* st) const {
......
...@@ -441,6 +441,9 @@ public: ...@@ -441,6 +441,9 @@ public:
return has_default_annotations() ? default_annotations()->length() : 0; return has_default_annotations() ? default_annotations()->length() : 0;
} }
// Copy annotations from other ConstMethod
void copy_annotations_from(ConstMethod* cm);
// byte codes // byte codes
void set_code(address code) { void set_code(address code) {
if (code_size() > 0) { if (code_size() > 0) {
......
...@@ -1170,6 +1170,8 @@ methodHandle Method::clone_with_new_data(methodHandle m, u_char* new_code, int n ...@@ -1170,6 +1170,8 @@ methodHandle Method::clone_with_new_data(methodHandle m, u_char* new_code, int n
newm->set_stackmap_data(stackmap_data); newm->set_stackmap_data(stackmap_data);
} }
// copy annotations over to new method
newcm->copy_annotations_from(cm);
return newm; return newm;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册