Mercurial > hg > truffle
comparison src/share/vm/classfile/classFileParser.cpp @ 20576:90257dfad6e3
8043275: 8u40 backport: Fix interface initialization for default methods.
Reviewed-by: dcubed, coleenp
author | acorn |
---|---|
date | Fri, 24 Oct 2014 12:29:08 -0700 |
parents | 8e15758b2e94 |
children | 0fa1f71a905b |
comparison
equal
deleted
inserted
replaced
20570:1bd99e1dc168 | 20576:90257dfad6e3 |
---|---|
2527 // are added to klass's access_flags. | 2527 // are added to klass's access_flags. |
2528 | 2528 |
2529 Array<Method*>* ClassFileParser::parse_methods(bool is_interface, | 2529 Array<Method*>* ClassFileParser::parse_methods(bool is_interface, |
2530 AccessFlags* promoted_flags, | 2530 AccessFlags* promoted_flags, |
2531 bool* has_final_method, | 2531 bool* has_final_method, |
2532 bool* has_default_methods, | 2532 bool* declares_default_methods, |
2533 TRAPS) { | 2533 TRAPS) { |
2534 ClassFileStream* cfs = stream(); | 2534 ClassFileStream* cfs = stream(); |
2535 cfs->guarantee_more(2, CHECK_NULL); // length | 2535 cfs->guarantee_more(2, CHECK_NULL); // length |
2536 u2 length = cfs->get_u2_fast(); | 2536 u2 length = cfs->get_u2_fast(); |
2537 if (length == 0) { | 2537 if (length == 0) { |
2546 CHECK_NULL); | 2546 CHECK_NULL); |
2547 | 2547 |
2548 if (method->is_final()) { | 2548 if (method->is_final()) { |
2549 *has_final_method = true; | 2549 *has_final_method = true; |
2550 } | 2550 } |
2551 if (is_interface && !(*has_default_methods) | 2551 // declares_default_methods: declares concrete instance methods, any access flags |
2552 && !method->is_abstract() && !method->is_static() | 2552 // used for interface initialization, and default method inheritance analysis |
2553 && !method->is_private()) { | 2553 if (is_interface && !(*declares_default_methods) |
2554 // default method | 2554 && !method->is_abstract() && !method->is_static()) { |
2555 *has_default_methods = true; | 2555 *declares_default_methods = true; |
2556 } | 2556 } |
2557 _methods->at_put(index, method()); | 2557 _methods->at_put(index, method()); |
2558 } | 2558 } |
2559 | 2559 |
2560 if (_need_verify && length > 1) { | 2560 if (_need_verify && length > 1) { |
3689 // agent attached, then the cached class bytes may not be the | 3689 // agent attached, then the cached class bytes may not be the |
3690 // original class bytes. | 3690 // original class bytes. |
3691 JvmtiCachedClassFileData *cached_class_file = NULL; | 3691 JvmtiCachedClassFileData *cached_class_file = NULL; |
3692 Handle class_loader(THREAD, loader_data->class_loader()); | 3692 Handle class_loader(THREAD, loader_data->class_loader()); |
3693 bool has_default_methods = false; | 3693 bool has_default_methods = false; |
3694 bool declares_default_methods = false; | |
3694 ResourceMark rm(THREAD); | 3695 ResourceMark rm(THREAD); |
3695 | 3696 |
3696 ClassFileStream* cfs = stream(); | 3697 ClassFileStream* cfs = stream(); |
3697 // Timing | 3698 // Timing |
3698 assert(THREAD->is_Java_thread(), "must be a JavaThread"); | 3699 assert(THREAD->is_Java_thread(), "must be a JavaThread"); |
3926 AccessFlags promoted_flags; | 3927 AccessFlags promoted_flags; |
3927 promoted_flags.set_flags(0); | 3928 promoted_flags.set_flags(0); |
3928 Array<Method*>* methods = parse_methods(access_flags.is_interface(), | 3929 Array<Method*>* methods = parse_methods(access_flags.is_interface(), |
3929 &promoted_flags, | 3930 &promoted_flags, |
3930 &has_final_method, | 3931 &has_final_method, |
3931 &has_default_methods, | 3932 &declares_default_methods, |
3932 CHECK_(nullHandle)); | 3933 CHECK_(nullHandle)); |
3934 if (declares_default_methods) { | |
3935 has_default_methods = true; | |
3936 } | |
3933 | 3937 |
3934 // Additional attributes | 3938 // Additional attributes |
3935 ClassAnnotationCollector parsed_annotations; | 3939 ClassAnnotationCollector parsed_annotations; |
3936 parse_classfile_attributes(&parsed_annotations, CHECK_(nullHandle)); | 3940 parse_classfile_attributes(&parsed_annotations, CHECK_(nullHandle)); |
3937 | 3941 |
4070 cp->klass_at_put(this_class_index, this_klass()); // eagerly resolve | 4074 cp->klass_at_put(this_class_index, this_klass()); // eagerly resolve |
4071 | 4075 |
4072 this_klass->set_minor_version(minor_version); | 4076 this_klass->set_minor_version(minor_version); |
4073 this_klass->set_major_version(major_version); | 4077 this_klass->set_major_version(major_version); |
4074 this_klass->set_has_default_methods(has_default_methods); | 4078 this_klass->set_has_default_methods(has_default_methods); |
4079 this_klass->set_declares_default_methods(declares_default_methods); | |
4075 | 4080 |
4076 if (!host_klass.is_null()) { | 4081 if (!host_klass.is_null()) { |
4077 assert (this_klass->is_anonymous(), "should be the same"); | 4082 assert (this_klass->is_anonymous(), "should be the same"); |
4078 this_klass->set_host_klass(host_klass()); | 4083 this_klass->set_host_klass(host_klass()); |
4079 } | 4084 } |