comparison src/share/vm/classfile/classFileParser.cpp @ 4988:eb5b24d1499f

Merge
author Christian Haeubl <christian.haeubl@oracle.com>
date Mon, 27 Feb 2012 15:06:36 -0800
parents 2b3acb34791f
children f7c4174b33ba fc9d8850ab8b
comparison
equal deleted inserted replaced
4987:f292f9c590ba 4988:eb5b24d1499f
43 #include "oops/klassOop.hpp" 43 #include "oops/klassOop.hpp"
44 #include "oops/klassVtable.hpp" 44 #include "oops/klassVtable.hpp"
45 #include "oops/methodOop.hpp" 45 #include "oops/methodOop.hpp"
46 #include "oops/symbol.hpp" 46 #include "oops/symbol.hpp"
47 #include "prims/jvmtiExport.hpp" 47 #include "prims/jvmtiExport.hpp"
48 #include "prims/jvmtiThreadState.hpp"
48 #include "runtime/javaCalls.hpp" 49 #include "runtime/javaCalls.hpp"
49 #include "runtime/perfData.hpp" 50 #include "runtime/perfData.hpp"
50 #include "runtime/reflection.hpp" 51 #include "runtime/reflection.hpp"
51 #include "runtime/signature.hpp" 52 #include "runtime/signature.hpp"
52 #include "runtime/timer.hpp" 53 #include "runtime/timer.hpp"
1048 return result; 1049 return result;
1049 } 1050 }
1050 1051
1051 class FieldAllocationCount: public ResourceObj { 1052 class FieldAllocationCount: public ResourceObj {
1052 public: 1053 public:
1053 unsigned int count[MAX_FIELD_ALLOCATION_TYPE]; 1054 u2 count[MAX_FIELD_ALLOCATION_TYPE];
1054 1055
1055 FieldAllocationCount() { 1056 FieldAllocationCount() {
1056 for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) { 1057 for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) {
1057 count[i] = 0; 1058 count[i] = 0;
1058 } 1059 }
1059 } 1060 }
1060 1061
1061 FieldAllocationType update(bool is_static, BasicType type) { 1062 FieldAllocationType update(bool is_static, BasicType type) {
1062 FieldAllocationType atype = basic_type_to_atype(is_static, type); 1063 FieldAllocationType atype = basic_type_to_atype(is_static, type);
1064 // Make sure there is no overflow with injected fields.
1065 assert(count[atype] < 0xFFFF, "More than 65535 fields");
1063 count[atype]++; 1066 count[atype]++;
1064 return atype; 1067 return atype;
1065 } 1068 }
1066 }; 1069 };
1067 1070
1068 1071
1069 typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name, 1072 typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name,
1070 constantPoolHandle cp, bool is_interface, 1073 constantPoolHandle cp, bool is_interface,
1071 FieldAllocationCount *fac, 1074 FieldAllocationCount *fac,
1072 objArrayHandle* fields_annotations, 1075 objArrayHandle* fields_annotations,
1073 int* java_fields_count_ptr, TRAPS) { 1076 u2* java_fields_count_ptr, TRAPS) {
1074 ClassFileStream* cfs = stream(); 1077 ClassFileStream* cfs = stream();
1075 typeArrayHandle nullHandle; 1078 typeArrayHandle nullHandle;
1076 cfs->guarantee_more(2, CHECK_(nullHandle)); // length 1079 cfs->guarantee_more(2, CHECK_(nullHandle)); // length
1077 u2 length = cfs->get_u2_fast(); 1080 u2 length = cfs->get_u2_fast();
1078 *java_fields_count_ptr = length; 1081 *java_fields_count_ptr = length;
2637 KlassHandle host_klass, 2640 KlassHandle host_klass,
2638 GrowableArray<Handle>* cp_patches, 2641 GrowableArray<Handle>* cp_patches,
2639 TempNewSymbol& parsed_name, 2642 TempNewSymbol& parsed_name,
2640 bool verify, 2643 bool verify,
2641 TRAPS) { 2644 TRAPS) {
2642 // So that JVMTI can cache class file in the state before retransformable agents 2645 // When a retransformable agent is attached, JVMTI caches the
2643 // have modified it 2646 // class bytes that existed before the first retransformation.
2647 // If RedefineClasses() was used before the retransformable
2648 // agent attached, then the cached class bytes may not be the
2649 // original class bytes.
2644 unsigned char *cached_class_file_bytes = NULL; 2650 unsigned char *cached_class_file_bytes = NULL;
2645 jint cached_class_file_length; 2651 jint cached_class_file_length;
2646 2652
2647 ClassFileStream* cfs = stream(); 2653 ClassFileStream* cfs = stream();
2648 // Timing 2654 // Timing
2658 2664
2659 _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false; 2665 _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
2660 _max_bootstrap_specifier_index = -1; 2666 _max_bootstrap_specifier_index = -1;
2661 2667
2662 if (JvmtiExport::should_post_class_file_load_hook()) { 2668 if (JvmtiExport::should_post_class_file_load_hook()) {
2669 // Get the cached class file bytes (if any) from the class that
2670 // is being redefined or retransformed. We use jvmti_thread_state()
2671 // instead of JvmtiThreadState::state_for(jt) so we don't allocate
2672 // a JvmtiThreadState any earlier than necessary. This will help
2673 // avoid the bug described by 7126851.
2674 JvmtiThreadState *state = jt->jvmti_thread_state();
2675 if (state != NULL) {
2676 KlassHandle *h_class_being_redefined =
2677 state->get_class_being_redefined();
2678 if (h_class_being_redefined != NULL) {
2679 instanceKlassHandle ikh_class_being_redefined =
2680 instanceKlassHandle(THREAD, (*h_class_being_redefined)());
2681 cached_class_file_bytes =
2682 ikh_class_being_redefined->get_cached_class_file_bytes();
2683 cached_class_file_length =
2684 ikh_class_being_redefined->get_cached_class_file_len();
2685 }
2686 }
2687
2663 unsigned char* ptr = cfs->buffer(); 2688 unsigned char* ptr = cfs->buffer();
2664 unsigned char* end_ptr = cfs->buffer() + cfs->length(); 2689 unsigned char* end_ptr = cfs->buffer() + cfs->length();
2665 2690
2666 JvmtiExport::post_class_file_load_hook(name, class_loader, protection_domain, 2691 JvmtiExport::post_class_file_load_hook(name, class_loader, protection_domain,
2667 &ptr, &end_ptr, 2692 &ptr, &end_ptr,
2841 local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array()); 2866 local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array());
2842 } else { 2867 } else {
2843 local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle)); 2868 local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle));
2844 } 2869 }
2845 2870
2846 int java_fields_count = 0; 2871 u2 java_fields_count = 0;
2847 // Fields (offsets are filled in later) 2872 // Fields (offsets are filled in later)
2848 FieldAllocationCount fac; 2873 FieldAllocationCount fac;
2849 objArrayHandle fields_annotations; 2874 objArrayHandle fields_annotations;
2850 typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations, 2875 typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations,
2851 &java_fields_count, 2876 &java_fields_count,