From 80c9e32b4fd58ee73df507fc49c1c3c25d443b0f Mon Sep 17 00:00:00 2001 From: emc Date: Tue, 19 Feb 2013 11:36:52 -0500 Subject: [PATCH] 8007153: Ensure that MethodParameters API works properly with RedefineClasses Summary: Adds code to HotSpot to properly update MethodParameter attributes' constant pool indexes when redefineClasses is called Reviewed-by: coleenp, sspitsyn --- src/share/vm/oops/method.hpp | 2 ++ src/share/vm/prims/jvmtiRedefineClasses.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/share/vm/oops/method.hpp b/src/share/vm/oops/method.hpp index a2d24ebca..0c6203fc6 100644 --- a/src/share/vm/oops/method.hpp +++ b/src/share/vm/oops/method.hpp @@ -456,6 +456,8 @@ class Method : public Metadata { void print_codes_on(int from, int to, outputStream* st) const PRODUCT_RETURN; // method parameters + bool has_method_parameters() const + { return constMethod()->has_method_parameters(); } int method_parameters_length() const { return constMethod()->method_parameters_length(); } MethodParametersElement* method_parameters_start() const diff --git a/src/share/vm/prims/jvmtiRedefineClasses.cpp b/src/share/vm/prims/jvmtiRedefineClasses.cpp index 14cb63c60..9eaa07a09 100644 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -1558,6 +1558,18 @@ void VM_RedefineClasses::rewrite_cp_refs_in_method(methodHandle method, } break; } } // end for each bytecode + + // We also need to rewrite the parameter name indexes, if there is + // method parameter data present + if(method->has_method_parameters()) { + const int len = method->method_parameters_length(); + MethodParametersElement* elem = method->method_parameters_start(); + + for (int i = 0; i < len; i++) { + const u2 cp_index = elem[i].name_cp_index; + elem[i].name_cp_index = find_new_index(cp_index); + } + } } // end rewrite_cp_refs_in_method() -- GitLab