Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/classFileParser.cpp @ 20703:0fa1f71a905b
8065634: Crash in InstanceKlass::clean_method_data when _method is NULL
Reviewed-by: coleenp, hseigel, poonam
author | stefank |
---|---|
date | Thu, 11 Dec 2014 11:13:13 +0100 |
parents | 90257dfad6e3 |
children | 7848fc12602b |
comparison
equal
deleted
inserted
replaced
20701:b6585ac86988 | 20703:0fa1f71a905b |
---|---|
3056 if (_sde_buffer != NULL) { | 3056 if (_sde_buffer != NULL) { |
3057 k->set_source_debug_extension(_sde_buffer, _sde_length); | 3057 k->set_source_debug_extension(_sde_buffer, _sde_length); |
3058 } | 3058 } |
3059 } | 3059 } |
3060 | 3060 |
3061 // Transfer ownership of metadata allocated to the InstanceKlass. | 3061 // Create the Annotations object that will |
3062 void ClassFileParser::apply_parsed_class_metadata( | 3062 // hold the annotations array for the Klass. |
3063 instanceKlassHandle this_klass, | 3063 void ClassFileParser::create_combined_annotations(TRAPS) { |
3064 int java_fields_count, TRAPS) { | 3064 if (_annotations == NULL && |
3065 // Assign annotations if needed | 3065 _type_annotations == NULL && |
3066 if (_annotations != NULL || _type_annotations != NULL || | 3066 _fields_annotations == NULL && |
3067 _fields_annotations != NULL || _fields_type_annotations != NULL) { | 3067 _fields_type_annotations == NULL) { |
3068 // Don't create the Annotations object unnecessarily. | |
3069 return; | |
3070 } | |
3071 | |
3068 Annotations* annotations = Annotations::allocate(_loader_data, CHECK); | 3072 Annotations* annotations = Annotations::allocate(_loader_data, CHECK); |
3069 annotations->set_class_annotations(_annotations); | 3073 annotations->set_class_annotations(_annotations); |
3070 annotations->set_class_type_annotations(_type_annotations); | 3074 annotations->set_class_type_annotations(_type_annotations); |
3071 annotations->set_fields_annotations(_fields_annotations); | 3075 annotations->set_fields_annotations(_fields_annotations); |
3072 annotations->set_fields_type_annotations(_fields_type_annotations); | 3076 annotations->set_fields_type_annotations(_fields_type_annotations); |
3073 this_klass->set_annotations(annotations); | 3077 |
3074 } | 3078 // This is the Annotations object that will be |
3075 | 3079 // assigned to InstanceKlass being constructed. |
3080 _combined_annotations = annotations; | |
3081 | |
3082 // The annotations arrays below has been transfered the | |
3083 // _combined_annotations so these fields can now be cleared. | |
3084 _annotations = NULL; | |
3085 _type_annotations = NULL; | |
3086 _fields_annotations = NULL; | |
3087 _fields_type_annotations = NULL; | |
3088 } | |
3089 | |
3090 // Transfer ownership of metadata allocated to the InstanceKlass. | |
3091 void ClassFileParser::apply_parsed_class_metadata( | |
3092 instanceKlassHandle this_klass, | |
3093 int java_fields_count, TRAPS) { | |
3076 _cp->set_pool_holder(this_klass()); | 3094 _cp->set_pool_holder(this_klass()); |
3077 this_klass->set_constants(_cp); | 3095 this_klass->set_constants(_cp); |
3078 this_klass->set_fields(_fields, java_fields_count); | 3096 this_klass->set_fields(_fields, java_fields_count); |
3079 this_klass->set_methods(_methods); | 3097 this_klass->set_methods(_methods); |
3080 this_klass->set_inner_classes(_inner_classes); | 3098 this_klass->set_inner_classes(_inner_classes); |
3081 this_klass->set_local_interfaces(_local_interfaces); | 3099 this_klass->set_local_interfaces(_local_interfaces); |
3082 this_klass->set_transitive_interfaces(_transitive_interfaces); | 3100 this_klass->set_transitive_interfaces(_transitive_interfaces); |
3101 this_klass->set_annotations(_combined_annotations); | |
3083 | 3102 |
3084 // Clear out these fields so they don't get deallocated by the destructor | 3103 // Clear out these fields so they don't get deallocated by the destructor |
3085 clear_class_metadata(); | 3104 clear_class_metadata(); |
3086 } | 3105 } |
3087 | 3106 |
3937 | 3956 |
3938 // Additional attributes | 3957 // Additional attributes |
3939 ClassAnnotationCollector parsed_annotations; | 3958 ClassAnnotationCollector parsed_annotations; |
3940 parse_classfile_attributes(&parsed_annotations, CHECK_(nullHandle)); | 3959 parse_classfile_attributes(&parsed_annotations, CHECK_(nullHandle)); |
3941 | 3960 |
3961 // Finalize the Annotations metadata object, | |
3962 // now that all annotation arrays have been created. | |
3963 create_combined_annotations(CHECK_(nullHandle)); | |
3964 | |
3942 // Make sure this is the end of class file stream | 3965 // Make sure this is the end of class file stream |
3943 guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle)); | 3966 guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle)); |
3944 | 3967 |
3945 // We check super class after class file is parsed and format is checked | 3968 // We check super class after class file is parsed and format is checked |
3946 if (super_class_index > 0 && super_klass.is_null()) { | 3969 if (super_class_index > 0 && super_klass.is_null()) { |
4237 | 4260 |
4238 // Free interfaces | 4261 // Free interfaces |
4239 InstanceKlass::deallocate_interfaces(_loader_data, _super_klass(), | 4262 InstanceKlass::deallocate_interfaces(_loader_data, _super_klass(), |
4240 _local_interfaces, _transitive_interfaces); | 4263 _local_interfaces, _transitive_interfaces); |
4241 | 4264 |
4242 MetadataFactory::free_array<u1>(_loader_data, _annotations); | 4265 if (_combined_annotations != NULL) { |
4243 MetadataFactory::free_array<u1>(_loader_data, _type_annotations); | 4266 // After all annotations arrays have been created, they are installed into the |
4244 Annotations::free_contents(_loader_data, _fields_annotations); | 4267 // Annotations object that will be assigned to the InstanceKlass being created. |
4245 Annotations::free_contents(_loader_data, _fields_type_annotations); | 4268 |
4269 // Deallocate the Annotations object and the installed annotations arrays. | |
4270 _combined_annotations->deallocate_contents(_loader_data); | |
4271 | |
4272 // If the _combined_annotations pointer is non-NULL, | |
4273 // then the other annotations fields should have been cleared. | |
4274 assert(_annotations == NULL, "Should have been cleared"); | |
4275 assert(_type_annotations == NULL, "Should have been cleared"); | |
4276 assert(_fields_annotations == NULL, "Should have been cleared"); | |
4277 assert(_fields_type_annotations == NULL, "Should have been cleared"); | |
4278 } else { | |
4279 // If the annotations arrays were not installed into the Annotations object, | |
4280 // then they have to be deallocated explicitly. | |
4281 MetadataFactory::free_array<u1>(_loader_data, _annotations); | |
4282 MetadataFactory::free_array<u1>(_loader_data, _type_annotations); | |
4283 Annotations::free_contents(_loader_data, _fields_annotations); | |
4284 Annotations::free_contents(_loader_data, _fields_type_annotations); | |
4285 } | |
4246 | 4286 |
4247 clear_class_metadata(); | 4287 clear_class_metadata(); |
4248 | 4288 |
4249 // deallocate the klass if already created. Don't directly deallocate, but add | 4289 // deallocate the klass if already created. Don't directly deallocate, but add |
4250 // to the deallocate list so that the klass is removed from the CLD::_klasses list | 4290 // to the deallocate list so that the klass is removed from the CLD::_klasses list |