comparison src/share/vm/classfile/classFileParser.cpp @ 17474:6fa574bfd32a

Merge
author chegar
date Thu, 03 Oct 2013 19:13:12 +0100
parents 9b4ce069642e da051ce490eb
children 6795fcebbf42
comparison
equal deleted inserted replaced
17473:9b4ce069642e 17474:6fa574bfd32a
886 int runtime_invisible_annotations_length = 0; 886 int runtime_invisible_annotations_length = 0;
887 u1* runtime_visible_type_annotations = NULL; 887 u1* runtime_visible_type_annotations = NULL;
888 int runtime_visible_type_annotations_length = 0; 888 int runtime_visible_type_annotations_length = 0;
889 u1* runtime_invisible_type_annotations = NULL; 889 u1* runtime_invisible_type_annotations = NULL;
890 int runtime_invisible_type_annotations_length = 0; 890 int runtime_invisible_type_annotations_length = 0;
891 bool runtime_invisible_type_annotations_exists = false;
891 while (attributes_count--) { 892 while (attributes_count--) {
892 cfs->guarantee_more(6, CHECK); // attribute_name_index, attribute_length 893 cfs->guarantee_more(6, CHECK); // attribute_name_index, attribute_length
893 u2 attribute_name_index = cfs->get_u2_fast(); 894 u2 attribute_name_index = cfs->get_u2_fast();
894 u4 attribute_length = cfs->get_u4_fast(); 895 u4 attribute_length = cfs->get_u4_fast();
895 check_property(valid_symbol_at(attribute_name_index), 896 check_property(valid_symbol_at(attribute_name_index),
944 runtime_invisible_annotations_length = attribute_length; 945 runtime_invisible_annotations_length = attribute_length;
945 runtime_invisible_annotations = cfs->get_u1_buffer(); 946 runtime_invisible_annotations = cfs->get_u1_buffer();
946 assert(runtime_invisible_annotations != NULL, "null invisible annotations"); 947 assert(runtime_invisible_annotations != NULL, "null invisible annotations");
947 cfs->skip_u1(runtime_invisible_annotations_length, CHECK); 948 cfs->skip_u1(runtime_invisible_annotations_length, CHECK);
948 } else if (attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) { 949 } else if (attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
950 if (runtime_visible_type_annotations != NULL) {
951 classfile_parse_error(
952 "Multiple RuntimeVisibleTypeAnnotations attributes for field in class file %s", CHECK);
953 }
949 runtime_visible_type_annotations_length = attribute_length; 954 runtime_visible_type_annotations_length = attribute_length;
950 runtime_visible_type_annotations = cfs->get_u1_buffer(); 955 runtime_visible_type_annotations = cfs->get_u1_buffer();
951 assert(runtime_visible_type_annotations != NULL, "null visible type annotations"); 956 assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
952 cfs->skip_u1(runtime_visible_type_annotations_length, CHECK); 957 cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
953 } else if (PreserveAllAnnotations && attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) { 958 } else if (attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
954 runtime_invisible_type_annotations_length = attribute_length; 959 if (runtime_invisible_type_annotations_exists) {
955 runtime_invisible_type_annotations = cfs->get_u1_buffer(); 960 classfile_parse_error(
956 assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); 961 "Multiple RuntimeInvisibleTypeAnnotations attributes for field in class file %s", CHECK);
957 cfs->skip_u1(runtime_invisible_type_annotations_length, CHECK); 962 } else {
963 runtime_invisible_type_annotations_exists = true;
964 }
965 if (PreserveAllAnnotations) {
966 runtime_invisible_type_annotations_length = attribute_length;
967 runtime_invisible_type_annotations = cfs->get_u1_buffer();
968 assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
969 }
970 cfs->skip_u1(attribute_length, CHECK);
958 } else { 971 } else {
959 cfs->skip_u1(attribute_length, CHECK); // Skip unknown attributes 972 cfs->skip_u1(attribute_length, CHECK); // Skip unknown attributes
960 } 973 }
961 } else { 974 } else {
962 cfs->skip_u1(attribute_length, CHECK); // Skip unknown attributes 975 cfs->skip_u1(attribute_length, CHECK); // Skip unknown attributes
1772 return _method_LambdaForm_Compiled; 1785 return _method_LambdaForm_Compiled;
1773 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Hidden_signature): 1786 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Hidden_signature):
1774 if (_location != _in_method) break; // only allow for methods 1787 if (_location != _in_method) break; // only allow for methods
1775 if (!privileged) break; // only allow in privileged code 1788 if (!privileged) break; // only allow in privileged code
1776 return _method_LambdaForm_Hidden; 1789 return _method_LambdaForm_Hidden;
1790 case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_invoke_Stable_signature):
1791 if (_location != _in_field) break; // only allow for fields
1792 if (!privileged) break; // only allow in privileged code
1793 return _field_Stable;
1777 case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_misc_Contended_signature): 1794 case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_misc_Contended_signature):
1778 if (_location != _in_field && _location != _in_class) break; // only allow for fields and classes 1795 if (_location != _in_field && _location != _in_class) break; // only allow for fields and classes
1779 if (!EnableContended || (RestrictContended && !privileged)) break; // honor privileges 1796 if (!EnableContended || (RestrictContended && !privileged)) break; // honor privileges
1780 return _sun_misc_Contended; 1797 return _sun_misc_Contended;
1781 default: break; 1798 default: break;
1784 } 1801 }
1785 1802
1786 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) { 1803 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) {
1787 if (is_contended()) 1804 if (is_contended())
1788 f->set_contended_group(contended_group()); 1805 f->set_contended_group(contended_group());
1806 if (is_stable())
1807 f->set_stable(true);
1789 } 1808 }
1790 1809
1791 ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() { 1810 ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
1792 // If there's an error deallocate metadata for field annotations 1811 // If there's an error deallocate metadata for field annotations
1793 MetadataFactory::free_array<u1>(_loader_data, _field_annotations); 1812 MetadataFactory::free_array<u1>(_loader_data, _field_annotations);
2058 int runtime_invisible_parameter_annotations_length = 0; 2077 int runtime_invisible_parameter_annotations_length = 0;
2059 u1* runtime_visible_type_annotations = NULL; 2078 u1* runtime_visible_type_annotations = NULL;
2060 int runtime_visible_type_annotations_length = 0; 2079 int runtime_visible_type_annotations_length = 0;
2061 u1* runtime_invisible_type_annotations = NULL; 2080 u1* runtime_invisible_type_annotations = NULL;
2062 int runtime_invisible_type_annotations_length = 0; 2081 int runtime_invisible_type_annotations_length = 0;
2082 bool runtime_invisible_type_annotations_exists = false;
2063 u1* annotation_default = NULL; 2083 u1* annotation_default = NULL;
2064 int annotation_default_length = 0; 2084 int annotation_default_length = 0;
2065 2085
2066 // Parse code and exceptions attribute 2086 // Parse code and exceptions attribute
2067 u2 method_attributes_count = cfs->get_u2_fast(); 2087 u2 method_attributes_count = cfs->get_u2_fast();
2314 annotation_default_length = method_attribute_length; 2334 annotation_default_length = method_attribute_length;
2315 annotation_default = cfs->get_u1_buffer(); 2335 annotation_default = cfs->get_u1_buffer();
2316 assert(annotation_default != NULL, "null annotation default"); 2336 assert(annotation_default != NULL, "null annotation default");
2317 cfs->skip_u1(annotation_default_length, CHECK_(nullHandle)); 2337 cfs->skip_u1(annotation_default_length, CHECK_(nullHandle));
2318 } else if (method_attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) { 2338 } else if (method_attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
2339 if (runtime_visible_type_annotations != NULL) {
2340 classfile_parse_error(
2341 "Multiple RuntimeVisibleTypeAnnotations attributes for method in class file %s",
2342 CHECK_(nullHandle));
2343 }
2319 runtime_visible_type_annotations_length = method_attribute_length; 2344 runtime_visible_type_annotations_length = method_attribute_length;
2320 runtime_visible_type_annotations = cfs->get_u1_buffer(); 2345 runtime_visible_type_annotations = cfs->get_u1_buffer();
2321 assert(runtime_visible_type_annotations != NULL, "null visible type annotations"); 2346 assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
2322 // No need for the VM to parse Type annotations 2347 // No need for the VM to parse Type annotations
2323 cfs->skip_u1(runtime_visible_type_annotations_length, CHECK_(nullHandle)); 2348 cfs->skip_u1(runtime_visible_type_annotations_length, CHECK_(nullHandle));
2324 } else if (PreserveAllAnnotations && method_attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) { 2349 } else if (method_attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
2325 runtime_invisible_type_annotations_length = method_attribute_length; 2350 if (runtime_invisible_type_annotations_exists) {
2326 runtime_invisible_type_annotations = cfs->get_u1_buffer(); 2351 classfile_parse_error(
2327 assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); 2352 "Multiple RuntimeInvisibleTypeAnnotations attributes for method in class file %s",
2328 cfs->skip_u1(runtime_invisible_type_annotations_length, CHECK_(nullHandle)); 2353 CHECK_(nullHandle));
2354 } else {
2355 runtime_invisible_type_annotations_exists = true;
2356 }
2357 if (PreserveAllAnnotations) {
2358 runtime_invisible_type_annotations_length = method_attribute_length;
2359 runtime_invisible_type_annotations = cfs->get_u1_buffer();
2360 assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
2361 }
2362 cfs->skip_u1(method_attribute_length, CHECK_(nullHandle));
2329 } else { 2363 } else {
2330 // Skip unknown attributes 2364 // Skip unknown attributes
2331 cfs->skip_u1(method_attribute_length, CHECK_(nullHandle)); 2365 cfs->skip_u1(method_attribute_length, CHECK_(nullHandle));
2332 } 2366 }
2333 } else { 2367 } else {
2816 int runtime_invisible_annotations_length = 0; 2850 int runtime_invisible_annotations_length = 0;
2817 u1* runtime_visible_type_annotations = NULL; 2851 u1* runtime_visible_type_annotations = NULL;
2818 int runtime_visible_type_annotations_length = 0; 2852 int runtime_visible_type_annotations_length = 0;
2819 u1* runtime_invisible_type_annotations = NULL; 2853 u1* runtime_invisible_type_annotations = NULL;
2820 int runtime_invisible_type_annotations_length = 0; 2854 int runtime_invisible_type_annotations_length = 0;
2855 bool runtime_invisible_type_annotations_exists = false;
2821 u1* inner_classes_attribute_start = NULL; 2856 u1* inner_classes_attribute_start = NULL;
2822 u4 inner_classes_attribute_length = 0; 2857 u4 inner_classes_attribute_length = 0;
2823 u2 enclosing_method_class_index = 0; 2858 u2 enclosing_method_class_index = 0;
2824 u2 enclosing_method_method_index = 0; 2859 u2 enclosing_method_method_index = 0;
2825 // Iterate over attributes 2860 // Iterate over attributes
2919 if (parsed_bootstrap_methods_attribute) 2954 if (parsed_bootstrap_methods_attribute)
2920 classfile_parse_error("Multiple BootstrapMethods attributes in class file %s", CHECK); 2955 classfile_parse_error("Multiple BootstrapMethods attributes in class file %s", CHECK);
2921 parsed_bootstrap_methods_attribute = true; 2956 parsed_bootstrap_methods_attribute = true;
2922 parse_classfile_bootstrap_methods_attribute(attribute_length, CHECK); 2957 parse_classfile_bootstrap_methods_attribute(attribute_length, CHECK);
2923 } else if (tag == vmSymbols::tag_runtime_visible_type_annotations()) { 2958 } else if (tag == vmSymbols::tag_runtime_visible_type_annotations()) {
2959 if (runtime_visible_type_annotations != NULL) {
2960 classfile_parse_error(
2961 "Multiple RuntimeVisibleTypeAnnotations attributes in class file %s", CHECK);
2962 }
2924 runtime_visible_type_annotations_length = attribute_length; 2963 runtime_visible_type_annotations_length = attribute_length;
2925 runtime_visible_type_annotations = cfs->get_u1_buffer(); 2964 runtime_visible_type_annotations = cfs->get_u1_buffer();
2926 assert(runtime_visible_type_annotations != NULL, "null visible type annotations"); 2965 assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
2927 // No need for the VM to parse Type annotations 2966 // No need for the VM to parse Type annotations
2928 cfs->skip_u1(runtime_visible_type_annotations_length, CHECK); 2967 cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
2929 } else if (PreserveAllAnnotations && tag == vmSymbols::tag_runtime_invisible_type_annotations()) { 2968 } else if (tag == vmSymbols::tag_runtime_invisible_type_annotations()) {
2930 runtime_invisible_type_annotations_length = attribute_length; 2969 if (runtime_invisible_type_annotations_exists) {
2931 runtime_invisible_type_annotations = cfs->get_u1_buffer(); 2970 classfile_parse_error(
2932 assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); 2971 "Multiple RuntimeInvisibleTypeAnnotations attributes in class file %s", CHECK);
2933 cfs->skip_u1(runtime_invisible_type_annotations_length, CHECK); 2972 } else {
2973 runtime_invisible_type_annotations_exists = true;
2974 }
2975 if (PreserveAllAnnotations) {
2976 runtime_invisible_type_annotations_length = attribute_length;
2977 runtime_invisible_type_annotations = cfs->get_u1_buffer();
2978 assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
2979 }
2980 cfs->skip_u1(attribute_length, CHECK);
2934 } else { 2981 } else {
2935 // Unknown attribute 2982 // Unknown attribute
2936 cfs->skip_u1(attribute_length, CHECK); 2983 cfs->skip_u1(attribute_length, CHECK);
2937 } 2984 }
2938 } else { 2985 } else {
3946 3993
3947 if (has_final_method) { 3994 if (has_final_method) {
3948 this_klass->set_has_final_method(); 3995 this_klass->set_has_final_method();
3949 } 3996 }
3950 this_klass->copy_method_ordering(method_ordering, CHECK_NULL); 3997 this_klass->copy_method_ordering(method_ordering, CHECK_NULL);
3951 // The InstanceKlass::_methods_jmethod_ids cache and the 3998 // The InstanceKlass::_methods_jmethod_ids cache
3952 // InstanceKlass::_methods_cached_itable_indices cache are 3999 // is managed on the assumption that the initial cache
3953 // both managed on the assumption that the initial cache
3954 // size is equal to the number of methods in the class. If 4000 // size is equal to the number of methods in the class. If
3955 // that changes, then InstanceKlass::idnum_can_increment() 4001 // that changes, then InstanceKlass::idnum_can_increment()
3956 // has to be changed accordingly. 4002 // has to be changed accordingly.
3957 this_klass->set_initial_method_idnum(methods->length()); 4003 this_klass->set_initial_method_idnum(methods->length());
3958 this_klass->set_name(cp->klass_name_at(this_class_index)); 4004 this_klass->set_name(cp->klass_name_at(this_class_index));