Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/classFileParser.cpp @ 6934:4735d2c84362
7200776: Implement default methods in interfaces
Summary: Add generic type analysis and default method selection algorithms
Reviewed-by: coleenp, acorn
author | kamg |
---|---|
date | Thu, 11 Oct 2012 12:25:42 -0400 |
parents | e52361627b65 |
children | 18fb7da42534 |
comparison
equal
deleted
inserted
replaced
6921:a1b8cf9cf970 | 6934:4735d2c84362 |
---|---|
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "classfile/classFileParser.hpp" | 26 #include "classfile/classFileParser.hpp" |
27 #include "classfile/classLoader.hpp" | 27 #include "classfile/classLoader.hpp" |
28 #include "classfile/classLoaderData.hpp" | 28 #include "classfile/classLoaderData.hpp" |
29 #include "classfile/classLoaderData.inline.hpp" | 29 #include "classfile/classLoaderData.inline.hpp" |
30 #include "classfile/defaultMethods.hpp" | |
31 #include "classfile/genericSignatures.hpp" | |
30 #include "classfile/javaClasses.hpp" | 32 #include "classfile/javaClasses.hpp" |
31 #include "classfile/symbolTable.hpp" | 33 #include "classfile/symbolTable.hpp" |
32 #include "classfile/systemDictionary.hpp" | 34 #include "classfile/systemDictionary.hpp" |
33 #include "classfile/verificationType.hpp" | 35 #include "classfile/verificationType.hpp" |
34 #include "classfile/verifier.hpp" | 36 #include "classfile/verifier.hpp" |
81 #define JAVA_6_VERSION 50 | 83 #define JAVA_6_VERSION 50 |
82 | 84 |
83 // Used for backward compatibility reasons: | 85 // Used for backward compatibility reasons: |
84 // - to check NameAndType_info signatures more aggressively | 86 // - to check NameAndType_info signatures more aggressively |
85 #define JAVA_7_VERSION 51 | 87 #define JAVA_7_VERSION 51 |
88 | |
89 // Extension method support. | |
90 #define JAVA_8_VERSION 52 | |
86 | 91 |
87 | 92 |
88 void ClassFileParser::parse_constant_pool_entries(ClassLoaderData* loader_data, constantPoolHandle cp, int length, TRAPS) { | 93 void ClassFileParser::parse_constant_pool_entries(ClassLoaderData* loader_data, constantPoolHandle cp, int length, TRAPS) { |
89 // Use a local copy of ClassFileStream. It helps the C++ compiler to optimize | 94 // Use a local copy of ClassFileStream. It helps the C++ compiler to optimize |
90 // this function (_current can be allocated in a register, with scalar | 95 // this function (_current can be allocated in a register, with scalar |
783 Array<Klass*>* ClassFileParser::parse_interfaces(constantPoolHandle cp, | 788 Array<Klass*>* ClassFileParser::parse_interfaces(constantPoolHandle cp, |
784 int length, | 789 int length, |
785 ClassLoaderData* loader_data, | 790 ClassLoaderData* loader_data, |
786 Handle protection_domain, | 791 Handle protection_domain, |
787 Symbol* class_name, | 792 Symbol* class_name, |
793 bool* has_default_methods, | |
788 TRAPS) { | 794 TRAPS) { |
789 ClassFileStream* cfs = stream(); | 795 ClassFileStream* cfs = stream(); |
790 assert(length > 0, "only called for length>0"); | 796 assert(length > 0, "only called for length>0"); |
791 // FIXME: Leak at later OOM. | 797 // FIXME: Leak at later OOM. |
792 Array<Klass*>* interfaces = MetadataFactory::new_array<Klass*>(loader_data, length, NULL, CHECK_NULL); | 798 Array<Klass*>* interfaces = MetadataFactory::new_array<Klass*>(loader_data, length, NULL, CHECK_NULL); |
818 interf = KlassHandle(THREAD, k); | 824 interf = KlassHandle(THREAD, k); |
819 } | 825 } |
820 | 826 |
821 if (!Klass::cast(interf())->is_interface()) { | 827 if (!Klass::cast(interf())->is_interface()) { |
822 THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", NULL); | 828 THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", NULL); |
829 } | |
830 if (InstanceKlass::cast(interf())->has_default_methods()) { | |
831 *has_default_methods = true; | |
823 } | 832 } |
824 interfaces->at_put(index, interf()); | 833 interfaces->at_put(index, interf()); |
825 } | 834 } |
826 | 835 |
827 if (!_need_verify || length <= 1) { | 836 if (!_need_verify || length <= 1) { |
1926 | 1935 |
1927 Symbol* method_attribute_name = cp->symbol_at(method_attribute_name_index); | 1936 Symbol* method_attribute_name = cp->symbol_at(method_attribute_name_index); |
1928 if (method_attribute_name == vmSymbols::tag_code()) { | 1937 if (method_attribute_name == vmSymbols::tag_code()) { |
1929 // Parse Code attribute | 1938 // Parse Code attribute |
1930 if (_need_verify) { | 1939 if (_need_verify) { |
1931 guarantee_property(!access_flags.is_native() && !access_flags.is_abstract(), | 1940 guarantee_property( |
1941 !access_flags.is_native() && !access_flags.is_abstract(), | |
1932 "Code attribute in native or abstract methods in class file %s", | 1942 "Code attribute in native or abstract methods in class file %s", |
1933 CHECK_(nullHandle)); | 1943 CHECK_(nullHandle)); |
1934 } | 1944 } |
1935 if (parsed_code_attribute) { | 1945 if (parsed_code_attribute) { |
1936 classfile_parse_error("Multiple Code attributes in class file %s", CHECK_(nullHandle)); | 1946 classfile_parse_error("Multiple Code attributes in class file %s", CHECK_(nullHandle)); |
2123 generic_signature_index = cfs->get_u2_fast(); | 2133 generic_signature_index = cfs->get_u2_fast(); |
2124 } else if (method_attribute_name == vmSymbols::tag_runtime_visible_annotations()) { | 2134 } else if (method_attribute_name == vmSymbols::tag_runtime_visible_annotations()) { |
2125 runtime_visible_annotations_length = method_attribute_length; | 2135 runtime_visible_annotations_length = method_attribute_length; |
2126 runtime_visible_annotations = cfs->get_u1_buffer(); | 2136 runtime_visible_annotations = cfs->get_u1_buffer(); |
2127 assert(runtime_visible_annotations != NULL, "null visible annotations"); | 2137 assert(runtime_visible_annotations != NULL, "null visible annotations"); |
2128 parse_annotations(runtime_visible_annotations, runtime_visible_annotations_length, cp, &parsed_annotations, CHECK_(nullHandle)); | 2138 parse_annotations(runtime_visible_annotations, |
2139 runtime_visible_annotations_length, cp, &parsed_annotations, | |
2140 CHECK_(nullHandle)); | |
2129 cfs->skip_u1(runtime_visible_annotations_length, CHECK_(nullHandle)); | 2141 cfs->skip_u1(runtime_visible_annotations_length, CHECK_(nullHandle)); |
2130 } else if (PreserveAllAnnotations && method_attribute_name == vmSymbols::tag_runtime_invisible_annotations()) { | 2142 } else if (PreserveAllAnnotations && method_attribute_name == vmSymbols::tag_runtime_invisible_annotations()) { |
2131 runtime_invisible_annotations_length = method_attribute_length; | 2143 runtime_invisible_annotations_length = method_attribute_length; |
2132 runtime_invisible_annotations = cfs->get_u1_buffer(); | 2144 runtime_invisible_annotations = cfs->get_u1_buffer(); |
2133 assert(runtime_invisible_annotations != NULL, "null invisible annotations"); | 2145 assert(runtime_invisible_annotations != NULL, "null invisible annotations"); |
2167 guarantee_property(access_flags.is_native() || access_flags.is_abstract() || parsed_code_attribute, | 2179 guarantee_property(access_flags.is_native() || access_flags.is_abstract() || parsed_code_attribute, |
2168 "Absent Code attribute in method that is not native or abstract in class file %s", CHECK_(nullHandle)); | 2180 "Absent Code attribute in method that is not native or abstract in class file %s", CHECK_(nullHandle)); |
2169 } | 2181 } |
2170 | 2182 |
2171 // All sizing information for a Method* is finally available, now create it | 2183 // All sizing information for a Method* is finally available, now create it |
2172 Method* m = Method::allocate(loader_data, code_length, access_flags, | 2184 Method* m = Method::allocate( |
2173 linenumber_table_length, | 2185 loader_data, code_length, access_flags, linenumber_table_length, |
2174 total_lvt_length, | 2186 total_lvt_length, exception_table_length, checked_exceptions_length, |
2175 exception_table_length, | 2187 ConstMethod::NORMAL, CHECK_(nullHandle)); |
2176 checked_exceptions_length, | |
2177 CHECK_(nullHandle)); | |
2178 | 2188 |
2179 ClassLoadingService::add_class_method_size(m->size()*HeapWordSize); | 2189 ClassLoadingService::add_class_method_size(m->size()*HeapWordSize); |
2180 | 2190 |
2181 // Fill in information from fixed part (access_flags already set) | 2191 // Fill in information from fixed part (access_flags already set) |
2182 m->set_constants(cp()); | 2192 m->set_constants(cp()); |
2202 #endif | 2212 #endif |
2203 | 2213 |
2204 // Fill in code attribute information | 2214 // Fill in code attribute information |
2205 m->set_max_stack(max_stack); | 2215 m->set_max_stack(max_stack); |
2206 m->set_max_locals(max_locals); | 2216 m->set_max_locals(max_locals); |
2207 | |
2208 m->constMethod()->set_stackmap_data(stackmap_data); | 2217 m->constMethod()->set_stackmap_data(stackmap_data); |
2209 | 2218 |
2210 // Copy byte codes | 2219 // Copy byte codes |
2211 m->set_code(code_start); | 2220 m->set_code(code_start); |
2212 | 2221 |
2354 AccessFlags* promoted_flags, | 2363 AccessFlags* promoted_flags, |
2355 bool* has_final_method, | 2364 bool* has_final_method, |
2356 Array<AnnotationArray*>** methods_annotations, | 2365 Array<AnnotationArray*>** methods_annotations, |
2357 Array<AnnotationArray*>** methods_parameter_annotations, | 2366 Array<AnnotationArray*>** methods_parameter_annotations, |
2358 Array<AnnotationArray*>** methods_default_annotations, | 2367 Array<AnnotationArray*>** methods_default_annotations, |
2368 bool* has_default_methods, | |
2359 TRAPS) { | 2369 TRAPS) { |
2360 ClassFileStream* cfs = stream(); | 2370 ClassFileStream* cfs = stream(); |
2361 AnnotationArray* method_annotations = NULL; | 2371 AnnotationArray* method_annotations = NULL; |
2362 AnnotationArray* method_parameter_annotations = NULL; | 2372 AnnotationArray* method_parameter_annotations = NULL; |
2363 AnnotationArray* method_default_annotations = NULL; | 2373 AnnotationArray* method_default_annotations = NULL; |
2379 &method_default_annotations, | 2389 &method_default_annotations, |
2380 CHECK_NULL); | 2390 CHECK_NULL); |
2381 | 2391 |
2382 if (method->is_final()) { | 2392 if (method->is_final()) { |
2383 *has_final_method = true; | 2393 *has_final_method = true; |
2394 } | |
2395 if (is_interface && !method->is_abstract() && !method->is_static()) { | |
2396 // default method | |
2397 *has_default_methods = true; | |
2384 } | 2398 } |
2385 methods->at_put(index, method()); | 2399 methods->at_put(index, method()); |
2386 if (*methods_annotations == NULL) { | 2400 if (*methods_annotations == NULL) { |
2387 *methods_annotations = | 2401 *methods_annotations = |
2388 MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL); | 2402 MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL); |
2905 } | 2919 } |
2906 return annotations; | 2920 return annotations; |
2907 } | 2921 } |
2908 | 2922 |
2909 | 2923 |
2924 #ifndef PRODUCT | |
2925 static void parseAndPrintGenericSignatures( | |
2926 instanceKlassHandle this_klass, TRAPS) { | |
2927 assert(ParseAllGenericSignatures == true, "Shouldn't call otherwise"); | |
2928 ResourceMark rm; | |
2929 | |
2930 if (this_klass->generic_signature() != NULL) { | |
2931 using namespace generic; | |
2932 ClassDescriptor* spec = ClassDescriptor::parse_generic_signature(this_klass(), CHECK); | |
2933 | |
2934 tty->print_cr("Parsing %s", this_klass->generic_signature()->as_C_string()); | |
2935 spec->print_on(tty); | |
2936 | |
2937 for (int i = 0; i < this_klass->methods()->length(); ++i) { | |
2938 Method* m = this_klass->methods()->at(i); | |
2939 MethodDescriptor* method_spec = MethodDescriptor::parse_generic_signature(m, spec); | |
2940 Symbol* sig = m->generic_signature(); | |
2941 if (sig == NULL) { | |
2942 sig = m->signature(); | |
2943 } | |
2944 tty->print_cr("Parsing %s", sig->as_C_string()); | |
2945 method_spec->print_on(tty); | |
2946 } | |
2947 } | |
2948 } | |
2949 #endif // ndef PRODUCT | |
2950 | |
2951 | |
2910 instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name, | 2952 instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name, |
2911 Handle class_loader, | 2953 Handle class_loader, |
2912 Handle protection_domain, | 2954 Handle protection_domain, |
2913 KlassHandle host_klass, | 2955 KlassHandle host_klass, |
2914 GrowableArray<Handle>* cp_patches, | 2956 GrowableArray<Handle>* cp_patches, |
2921 // agent attached, then the cached class bytes may not be the | 2963 // agent attached, then the cached class bytes may not be the |
2922 // original class bytes. | 2964 // original class bytes. |
2923 unsigned char *cached_class_file_bytes = NULL; | 2965 unsigned char *cached_class_file_bytes = NULL; |
2924 jint cached_class_file_length; | 2966 jint cached_class_file_length; |
2925 ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader()); | 2967 ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader()); |
2968 bool has_default_methods = false; | |
2969 ResourceMark rm(THREAD); | |
2926 | 2970 |
2927 ClassFileStream* cfs = stream(); | 2971 ClassFileStream* cfs = stream(); |
2928 // Timing | 2972 // Timing |
2929 assert(THREAD->is_Java_thread(), "must be a JavaThread"); | 2973 assert(THREAD->is_Java_thread(), "must be a JavaThread"); |
2930 JavaThread* jt = (JavaThread*) THREAD; | 2974 JavaThread* jt = (JavaThread*) THREAD; |
3136 u2 itfs_len = cfs->get_u2_fast(); | 3180 u2 itfs_len = cfs->get_u2_fast(); |
3137 Array<Klass*>* local_interfaces; | 3181 Array<Klass*>* local_interfaces; |
3138 if (itfs_len == 0) { | 3182 if (itfs_len == 0) { |
3139 local_interfaces = Universe::the_empty_klass_array(); | 3183 local_interfaces = Universe::the_empty_klass_array(); |
3140 } else { | 3184 } else { |
3141 local_interfaces = parse_interfaces(cp, itfs_len, loader_data, protection_domain, _class_name, CHECK_(nullHandle)); | 3185 local_interfaces = parse_interfaces( |
3186 cp, itfs_len, loader_data, protection_domain, _class_name, | |
3187 &has_default_methods, CHECK_(nullHandle)); | |
3142 } | 3188 } |
3143 | 3189 |
3144 u2 java_fields_count = 0; | 3190 u2 java_fields_count = 0; |
3145 // Fields (offsets are filled in later) | 3191 // Fields (offsets are filled in later) |
3146 FieldAllocationCount fac; | 3192 FieldAllocationCount fac; |
3162 &promoted_flags, | 3208 &promoted_flags, |
3163 &has_final_method, | 3209 &has_final_method, |
3164 &methods_annotations, | 3210 &methods_annotations, |
3165 &methods_parameter_annotations, | 3211 &methods_parameter_annotations, |
3166 &methods_default_annotations, | 3212 &methods_default_annotations, |
3213 &has_default_methods, | |
3167 CHECK_(nullHandle)); | 3214 CHECK_(nullHandle)); |
3168 | 3215 |
3169 // Additional attributes | 3216 // Additional attributes |
3170 ClassAnnotationCollector parsed_annotations; | 3217 ClassAnnotationCollector parsed_annotations; |
3171 parse_classfile_attributes(loader_data, cp, &parsed_annotations, CHECK_(nullHandle)); | 3218 parse_classfile_attributes(loader_data, cp, &parsed_annotations, CHECK_(nullHandle)); |
3191 | 3238 |
3192 KlassHandle kh (THREAD, k); | 3239 KlassHandle kh (THREAD, k); |
3193 super_klass = instanceKlassHandle(THREAD, kh()); | 3240 super_klass = instanceKlassHandle(THREAD, kh()); |
3194 } | 3241 } |
3195 if (super_klass.not_null()) { | 3242 if (super_klass.not_null()) { |
3243 | |
3244 if (super_klass->has_default_methods()) { | |
3245 has_default_methods = true; | |
3246 } | |
3247 | |
3196 if (super_klass->is_interface()) { | 3248 if (super_klass->is_interface()) { |
3197 ResourceMark rm(THREAD); | 3249 ResourceMark rm(THREAD); |
3198 Exceptions::fthrow( | 3250 Exceptions::fthrow( |
3199 THREAD_AND_LOCATION, | 3251 THREAD_AND_LOCATION, |
3200 vmSymbols::java_lang_IncompatibleClassChangeError(), | 3252 vmSymbols::java_lang_IncompatibleClassChangeError(), |
3227 // Size of Java vtable (in words) | 3279 // Size of Java vtable (in words) |
3228 int vtable_size = 0; | 3280 int vtable_size = 0; |
3229 int itable_size = 0; | 3281 int itable_size = 0; |
3230 int num_miranda_methods = 0; | 3282 int num_miranda_methods = 0; |
3231 | 3283 |
3232 klassVtable::compute_vtable_size_and_num_mirandas(vtable_size, | 3284 GrowableArray<Method*> all_mirandas(20); |
3233 num_miranda_methods, | 3285 |
3234 super_klass(), | 3286 klassVtable::compute_vtable_size_and_num_mirandas( |
3235 methods, | 3287 &vtable_size, &num_miranda_methods, &all_mirandas, super_klass(), methods, |
3236 access_flags, | 3288 access_flags, class_loader, class_name, local_interfaces, |
3237 class_loader, | |
3238 class_name, | |
3239 local_interfaces, | |
3240 CHECK_(nullHandle)); | 3289 CHECK_(nullHandle)); |
3241 | 3290 |
3242 // Size of Java itable (in words) | 3291 // Size of Java itable (in words) |
3243 itable_size = access_flags.is_interface() ? 0 : klassItable::compute_itable_size(transitive_interfaces); | 3292 itable_size = access_flags.is_interface() ? 0 : klassItable::compute_itable_size(transitive_interfaces); |
3244 | 3293 |
3654 } | 3703 } |
3655 | 3704 |
3656 | 3705 |
3657 this_klass->set_minor_version(minor_version); | 3706 this_klass->set_minor_version(minor_version); |
3658 this_klass->set_major_version(major_version); | 3707 this_klass->set_major_version(major_version); |
3708 this_klass->set_has_default_methods(has_default_methods); | |
3659 | 3709 |
3660 // Set up Method*::intrinsic_id as soon as we know the names of methods. | 3710 // Set up Method*::intrinsic_id as soon as we know the names of methods. |
3661 // (We used to do this lazily, but now we query it in Rewriter, | 3711 // (We used to do this lazily, but now we query it in Rewriter, |
3662 // which is eagerly done for every method, so we might as well do it now, | 3712 // which is eagerly done for every method, so we might as well do it now, |
3663 // when everything is fresh in memory.) | 3713 // when everything is fresh in memory.) |
3671 // JVMTI: we have an InstanceKlass now, tell it about the cached bytes | 3721 // JVMTI: we have an InstanceKlass now, tell it about the cached bytes |
3672 this_klass->set_cached_class_file(cached_class_file_bytes, | 3722 this_klass->set_cached_class_file(cached_class_file_bytes, |
3673 cached_class_file_length); | 3723 cached_class_file_length); |
3674 } | 3724 } |
3675 | 3725 |
3726 // Fill in field values obtained by parse_classfile_attributes | |
3727 if (parsed_annotations.has_any_annotations()) | |
3728 parsed_annotations.apply_to(this_klass); | |
3729 // Create annotations | |
3730 if (_annotations != NULL && this_klass->annotations() == NULL) { | |
3731 Annotations* anno = Annotations::allocate(loader_data, CHECK_NULL); | |
3732 this_klass->set_annotations(anno); | |
3733 } | |
3734 apply_parsed_class_attributes(this_klass); | |
3735 | |
3676 // Miranda methods | 3736 // Miranda methods |
3677 if ((num_miranda_methods > 0) || | 3737 if ((num_miranda_methods > 0) || |
3678 // if this class introduced new miranda methods or | 3738 // if this class introduced new miranda methods or |
3679 (super_klass.not_null() && (super_klass->has_miranda_methods())) | 3739 (super_klass.not_null() && (super_klass->has_miranda_methods())) |
3680 // super class exists and this class inherited miranda methods | 3740 // super class exists and this class inherited miranda methods |
3681 ) { | 3741 ) { |
3682 this_klass->set_has_miranda_methods(); // then set a flag | 3742 this_klass->set_has_miranda_methods(); // then set a flag |
3683 } | 3743 } |
3684 | 3744 |
3685 // Fill in field values obtained by parse_classfile_attributes | |
3686 if (parsed_annotations.has_any_annotations()) { | |
3687 parsed_annotations.apply_to(this_klass); | |
3688 } | |
3689 // Create annotations | |
3690 if (_annotations != NULL && this_klass->annotations() == NULL) { | |
3691 Annotations* anno = Annotations::allocate(loader_data, CHECK_NULL); | |
3692 this_klass->set_annotations(anno); | |
3693 } | |
3694 apply_parsed_class_attributes(this_klass); | |
3695 | |
3696 // Compute transitive closure of interfaces this class implements | |
3697 this_klass->set_transitive_interfaces(transitive_interfaces); | 3745 this_klass->set_transitive_interfaces(transitive_interfaces); |
3698 | 3746 |
3699 // Fill in information needed to compute superclasses. | 3747 // Fill in information needed to compute superclasses. |
3700 this_klass->initialize_supers(super_klass(), CHECK_(nullHandle)); | 3748 this_klass->initialize_supers(super_klass(), CHECK_(nullHandle)); |
3701 | 3749 |
3702 // Initialize itable offset tables | 3750 // Initialize itable offset tables |
3703 klassItable::setup_itable_offset_table(this_klass); | 3751 klassItable::setup_itable_offset_table(this_klass); |
3704 | 3752 |
3753 // Compute transitive closure of interfaces this class implements | |
3705 // Do final class setup | 3754 // Do final class setup |
3706 fill_oop_maps(this_klass, nonstatic_oop_map_count, nonstatic_oop_offsets, nonstatic_oop_counts); | 3755 fill_oop_maps(this_klass, nonstatic_oop_map_count, nonstatic_oop_offsets, nonstatic_oop_counts); |
3707 | 3756 |
3708 // Fill in has_finalizer, has_vanilla_constructor, and layout_helper | 3757 // Fill in has_finalizer, has_vanilla_constructor, and layout_helper |
3709 set_precomputed_flags(this_klass); | 3758 set_precomputed_flags(this_klass); |
3722 check_final_method_override(this_klass, CHECK_(nullHandle)); | 3771 check_final_method_override(this_klass, CHECK_(nullHandle)); |
3723 | 3772 |
3724 // check that if this class is an interface then it doesn't have static methods | 3773 // check that if this class is an interface then it doesn't have static methods |
3725 if (this_klass->is_interface()) { | 3774 if (this_klass->is_interface()) { |
3726 check_illegal_static_method(this_klass, CHECK_(nullHandle)); | 3775 check_illegal_static_method(this_klass, CHECK_(nullHandle)); |
3776 } | |
3777 | |
3778 | |
3779 #ifdef ASSERT | |
3780 if (ParseAllGenericSignatures) { | |
3781 parseAndPrintGenericSignatures(this_klass, CHECK_(nullHandle)); | |
3782 } | |
3783 #endif | |
3784 | |
3785 // Generate any default methods - default methods are interface methods | |
3786 // that have a default implementation. This is new with Lambda project. | |
3787 if (has_default_methods && !access_flags.is_interface() && | |
3788 local_interfaces->length() > 0) { | |
3789 DefaultMethods::generate_default_methods( | |
3790 this_klass(), &all_mirandas, CHECK_(nullHandle)); | |
3727 } | 3791 } |
3728 | 3792 |
3729 // Allocate mirror and initialize static fields | 3793 // Allocate mirror and initialize static fields |
3730 java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle)); | 3794 java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle)); |
3731 | 3795 |
3742 | 3806 |
3743 ClassLoadingService::notify_class_loaded(InstanceKlass::cast(this_klass()), | 3807 ClassLoadingService::notify_class_loaded(InstanceKlass::cast(this_klass()), |
3744 false /* not shared class */); | 3808 false /* not shared class */); |
3745 | 3809 |
3746 if (TraceClassLoading) { | 3810 if (TraceClassLoading) { |
3811 ResourceMark rm; | |
3747 // print in a single call to reduce interleaving of output | 3812 // print in a single call to reduce interleaving of output |
3748 if (cfs->source() != NULL) { | 3813 if (cfs->source() != NULL) { |
3749 tty->print("[Loaded %s from %s]\n", this_klass->external_name(), | 3814 tty->print("[Loaded %s from %s]\n", this_klass->external_name(), |
3750 cfs->source()); | 3815 cfs->source()); |
3751 } else if (class_loader.is_null()) { | 3816 } else if (class_loader.is_null()) { |
3756 InstanceKlass::cast(caller)->external_name()); | 3821 InstanceKlass::cast(caller)->external_name()); |
3757 } else { | 3822 } else { |
3758 tty->print("[Loaded %s]\n", this_klass->external_name()); | 3823 tty->print("[Loaded %s]\n", this_klass->external_name()); |
3759 } | 3824 } |
3760 } else { | 3825 } else { |
3761 ResourceMark rm; | |
3762 tty->print("[Loaded %s from %s]\n", this_klass->external_name(), | 3826 tty->print("[Loaded %s from %s]\n", this_klass->external_name(), |
3763 InstanceKlass::cast(class_loader->klass())->external_name()); | 3827 InstanceKlass::cast(class_loader->klass())->external_name()); |
3764 } | 3828 } |
3765 } | 3829 } |
3766 | 3830 |
3767 if (TraceClassResolution) { | 3831 if (TraceClassResolution) { |
3832 ResourceMark rm; | |
3768 // print out the superclass. | 3833 // print out the superclass. |
3769 const char * from = Klass::cast(this_klass())->external_name(); | 3834 const char * from = Klass::cast(this_klass())->external_name(); |
3770 if (this_klass->java_super() != NULL) { | 3835 if (this_klass->java_super() != NULL) { |
3771 tty->print("RESOLVE %s %s (super)\n", from, InstanceKlass::cast(this_klass->java_super())->external_name()); | 3836 tty->print("RESOLVE %s %s (super)\n", from, InstanceKlass::cast(this_klass->java_super())->external_name()); |
3772 } | 3837 } |
3783 } | 3848 } |
3784 } | 3849 } |
3785 | 3850 |
3786 #ifndef PRODUCT | 3851 #ifndef PRODUCT |
3787 if( PrintCompactFieldsSavings ) { | 3852 if( PrintCompactFieldsSavings ) { |
3853 ResourceMark rm; | |
3788 if( nonstatic_field_size < orig_nonstatic_field_size ) { | 3854 if( nonstatic_field_size < orig_nonstatic_field_size ) { |
3789 tty->print("[Saved %d of %d bytes in %s]\n", | 3855 tty->print("[Saved %d of %d bytes in %s]\n", |
3790 (orig_nonstatic_field_size - nonstatic_field_size)*heapOopSize, | 3856 (orig_nonstatic_field_size - nonstatic_field_size)*heapOopSize, |
3791 orig_nonstatic_field_size*heapOopSize, | 3857 orig_nonstatic_field_size*heapOopSize, |
3792 this_klass->external_name()); | 3858 this_klass->external_name()); |
3808 instanceKlassHandle this_klass (THREAD, preserve_this_klass); | 3874 instanceKlassHandle this_klass (THREAD, preserve_this_klass); |
3809 debug_only(this_klass->verify();) | 3875 debug_only(this_klass->verify();) |
3810 | 3876 |
3811 return this_klass; | 3877 return this_klass; |
3812 } | 3878 } |
3813 | |
3814 | 3879 |
3815 unsigned int | 3880 unsigned int |
3816 ClassFileParser::compute_oop_map_count(instanceKlassHandle super, | 3881 ClassFileParser::compute_oop_map_count(instanceKlassHandle super, |
3817 unsigned int nonstatic_oop_map_count, | 3882 unsigned int nonstatic_oop_map_count, |
3818 int first_nonstatic_oop_offset) { | 3883 int first_nonstatic_oop_offset) { |
4261 const bool is_abstract = (flags & JVM_ACC_ABSTRACT) != 0; | 4326 const bool is_abstract = (flags & JVM_ACC_ABSTRACT) != 0; |
4262 const bool is_bridge = (flags & JVM_ACC_BRIDGE) != 0; | 4327 const bool is_bridge = (flags & JVM_ACC_BRIDGE) != 0; |
4263 const bool is_strict = (flags & JVM_ACC_STRICT) != 0; | 4328 const bool is_strict = (flags & JVM_ACC_STRICT) != 0; |
4264 const bool is_synchronized = (flags & JVM_ACC_SYNCHRONIZED) != 0; | 4329 const bool is_synchronized = (flags & JVM_ACC_SYNCHRONIZED) != 0; |
4265 const bool major_gte_15 = _major_version >= JAVA_1_5_VERSION; | 4330 const bool major_gte_15 = _major_version >= JAVA_1_5_VERSION; |
4331 const bool major_gte_8 = _major_version >= JAVA_8_VERSION; | |
4266 const bool is_initializer = (name == vmSymbols::object_initializer_name()); | 4332 const bool is_initializer = (name == vmSymbols::object_initializer_name()); |
4267 | 4333 |
4268 bool is_illegal = false; | 4334 bool is_illegal = false; |
4269 | 4335 |
4270 if (is_interface) { | 4336 if (is_interface) { |
4271 if (!is_abstract || !is_public || is_static || is_final || | 4337 if (!is_public || is_static || is_final || is_native || |
4272 is_native || (major_gte_15 && (is_synchronized || is_strict))) { | 4338 ((is_synchronized || is_strict) && major_gte_15 && |
4339 (!major_gte_8 || is_abstract)) || | |
4340 (!major_gte_8 && !is_abstract)) { | |
4273 is_illegal = true; | 4341 is_illegal = true; |
4274 } | 4342 } |
4275 } else { // not interface | 4343 } else { // not interface |
4276 if (is_initializer) { | 4344 if (is_initializer) { |
4277 if (is_static || is_final || is_synchronized || is_native || | 4345 if (is_static || is_final || is_synchronized || is_native || |