1.1 --- a/src/share/vm/oops/instanceKlass.cpp Fri May 20 22:27:48 2011 -0700 1.2 +++ b/src/share/vm/oops/instanceKlass.cpp Sat May 21 15:39:54 2011 -0700 1.3 @@ -335,6 +335,9 @@ 1.4 this_oop->rewrite_class(CHECK_false); 1.5 } 1.6 1.7 + // relocate jsrs and link methods after they are all rewritten 1.8 + this_oop->relocate_and_link_methods(CHECK_false); 1.9 + 1.10 // Initialize the vtable and interface table after 1.11 // methods have been rewritten since rewrite may 1.12 // fabricate new methodOops. 1.13 @@ -365,17 +368,8 @@ 1.14 1.15 1.16 // Rewrite the byte codes of all of the methods of a class. 1.17 -// Three cases: 1.18 -// During the link of a newly loaded class. 1.19 -// During the preloading of classes to be written to the shared spaces. 1.20 -// - Rewrite the methods and update the method entry points. 1.21 -// 1.22 -// During the link of a class in the shared spaces. 1.23 -// - The methods were already rewritten, update the metho entry points. 1.24 -// 1.25 // The rewriter must be called exactly once. Rewriting must happen after 1.26 // verification but before the first method of the class is executed. 1.27 - 1.28 void instanceKlass::rewrite_class(TRAPS) { 1.29 assert(is_loaded(), "must be loaded"); 1.30 instanceKlassHandle this_oop(THREAD, this->as_klassOop()); 1.31 @@ -383,10 +377,19 @@ 1.32 assert(this_oop()->is_shared(), "rewriting an unshared class?"); 1.33 return; 1.34 } 1.35 - Rewriter::rewrite(this_oop, CHECK); // No exception can happen here 1.36 + Rewriter::rewrite(this_oop, CHECK); 1.37 this_oop->set_rewritten(); 1.38 } 1.39 1.40 +// Now relocate and link method entry points after class is rewritten. 1.41 +// This is outside is_rewritten flag. In case of an exception, it can be 1.42 +// executed more than once. 1.43 +void instanceKlass::relocate_and_link_methods(TRAPS) { 1.44 + assert(is_loaded(), "must be loaded"); 1.45 + instanceKlassHandle this_oop(THREAD, this->as_klassOop()); 1.46 + Rewriter::relocate_and_link(this_oop, CHECK); 1.47 +} 1.48 + 1.49 1.50 void instanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { 1.51 // Make sure klass is linked (verified) before initialization