3645 // When a retransformable agent is attached, JVMTI caches the |
3645 // When a retransformable agent is attached, JVMTI caches the |
3646 // class bytes that existed before the first retransformation. |
3646 // class bytes that existed before the first retransformation. |
3647 // If RedefineClasses() was used before the retransformable |
3647 // If RedefineClasses() was used before the retransformable |
3648 // agent attached, then the cached class bytes may not be the |
3648 // agent attached, then the cached class bytes may not be the |
3649 // original class bytes. |
3649 // original class bytes. |
3650 unsigned char *cached_class_file_bytes = NULL; |
3650 JvmtiCachedClassFileData *cached_class_file = NULL; |
3651 jint cached_class_file_length; |
|
3652 Handle class_loader(THREAD, loader_data->class_loader()); |
3651 Handle class_loader(THREAD, loader_data->class_loader()); |
3653 bool has_default_methods = false; |
3652 bool has_default_methods = false; |
3654 ResourceMark rm(THREAD); |
3653 ResourceMark rm(THREAD); |
3655 |
3654 |
3656 ClassFileStream* cfs = stream(); |
3655 ClassFileStream* cfs = stream(); |
3678 KlassHandle *h_class_being_redefined = |
3677 KlassHandle *h_class_being_redefined = |
3679 state->get_class_being_redefined(); |
3678 state->get_class_being_redefined(); |
3680 if (h_class_being_redefined != NULL) { |
3679 if (h_class_being_redefined != NULL) { |
3681 instanceKlassHandle ikh_class_being_redefined = |
3680 instanceKlassHandle ikh_class_being_redefined = |
3682 instanceKlassHandle(THREAD, (*h_class_being_redefined)()); |
3681 instanceKlassHandle(THREAD, (*h_class_being_redefined)()); |
3683 cached_class_file_bytes = |
3682 cached_class_file = ikh_class_being_redefined->get_cached_class_file(); |
3684 ikh_class_being_redefined->get_cached_class_file_bytes(); |
|
3685 cached_class_file_length = |
|
3686 ikh_class_being_redefined->get_cached_class_file_len(); |
|
3687 } |
3683 } |
3688 } |
3684 } |
3689 |
3685 |
3690 unsigned char* ptr = cfs->buffer(); |
3686 unsigned char* ptr = cfs->buffer(); |
3691 unsigned char* end_ptr = cfs->buffer() + cfs->length(); |
3687 unsigned char* end_ptr = cfs->buffer() + cfs->length(); |
3692 |
3688 |
3693 JvmtiExport::post_class_file_load_hook(name, class_loader(), protection_domain, |
3689 JvmtiExport::post_class_file_load_hook(name, class_loader(), protection_domain, |
3694 &ptr, &end_ptr, |
3690 &ptr, &end_ptr, &cached_class_file); |
3695 &cached_class_file_bytes, |
|
3696 &cached_class_file_length); |
|
3697 |
3691 |
3698 if (ptr != cfs->buffer()) { |
3692 if (ptr != cfs->buffer()) { |
3699 // JVMTI agent has modified class file data. |
3693 // JVMTI agent has modified class file data. |
3700 // Set new class file stream using JVMTI agent modified |
3694 // Set new class file stream using JVMTI agent modified |
3701 // class file data. |
3695 // class file data. |
4009 for (int j = 0; j < methods->length(); j++) { |
4003 for (int j = 0; j < methods->length(); j++) { |
4010 methods->at(j)->init_intrinsic_id(); |
4004 methods->at(j)->init_intrinsic_id(); |
4011 } |
4005 } |
4012 } |
4006 } |
4013 |
4007 |
4014 if (cached_class_file_bytes != NULL) { |
4008 if (cached_class_file != NULL) { |
4015 // JVMTI: we have an InstanceKlass now, tell it about the cached bytes |
4009 // JVMTI: we have an InstanceKlass now, tell it about the cached bytes |
4016 this_klass->set_cached_class_file(cached_class_file_bytes, |
4010 this_klass->set_cached_class_file(cached_class_file); |
4017 cached_class_file_length); |
|
4018 } |
4011 } |
4019 |
4012 |
4020 // Fill in field values obtained by parse_classfile_attributes |
4013 // Fill in field values obtained by parse_classfile_attributes |
4021 if (parsed_annotations.has_any_annotations()) |
4014 if (parsed_annotations.has_any_annotations()) |
4022 parsed_annotations.apply_to(this_klass); |
4015 parsed_annotations.apply_to(this_klass); |