src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File bug_8028520 Sdiff src/share/vm/classfile

src/share/vm/classfile/classFileParser.cpp

Print this page




4466         THREAD_AND_LOCATION,
4467         vmSymbols::java_lang_IllegalAccessError(),
4468         "class %s cannot access its superinterface %s",
4469         this_klass->external_name(),
4470         InstanceKlass::cast(k)->external_name()
4471       );
4472       return;
4473     }
4474   }
4475 }
4476 
4477 
4478 void ClassFileParser::check_final_method_override(instanceKlassHandle this_klass, TRAPS) {
4479   Array<Method*>* methods = this_klass->methods();
4480   int num_methods = methods->length();
4481 
4482   // go thru each method and check if it overrides a final method
4483   for (int index = 0; index < num_methods; index++) {
4484     Method* m = methods->at(index);
4485 
4486     // skip static and <init> methods
4487     if ((!m->is_static()) &&
4488         (m->name() != vmSymbols::object_initializer_name())) {
4489 
4490       Symbol* name = m->name();
4491       Symbol* signature = m->signature();
4492       Klass* k = this_klass->super();
4493       Method* super_m = NULL;
4494       while (k != NULL) {
4495         // skip supers that don't have final methods.
4496         if (k->has_final_method()) {
4497           // lookup a matching method in the super class hierarchy
4498           super_m = InstanceKlass::cast(k)->lookup_method(name, signature);
4499           if (super_m == NULL) {
4500             break; // didn't find any match; get out
4501           }
4502 
4503           if (super_m->is_final() &&
4504               // matching method in super is final
4505               (Reflection::verify_field_access(this_klass(),
4506                                                super_m->method_holder(),
4507                                                super_m->method_holder(),




4466         THREAD_AND_LOCATION,
4467         vmSymbols::java_lang_IllegalAccessError(),
4468         "class %s cannot access its superinterface %s",
4469         this_klass->external_name(),
4470         InstanceKlass::cast(k)->external_name()
4471       );
4472       return;
4473     }
4474   }
4475 }
4476 
4477 
4478 void ClassFileParser::check_final_method_override(instanceKlassHandle this_klass, TRAPS) {
4479   Array<Method*>* methods = this_klass->methods();
4480   int num_methods = methods->length();
4481 
4482   // go thru each method and check if it overrides a final method
4483   for (int index = 0; index < num_methods; index++) {
4484     Method* m = methods->at(index);
4485 
4486     // skip private, static, and <init> methods
4487     if ((!m->is_private() && !m->is_static()) &&
4488         (m->name() != vmSymbols::object_initializer_name())) {
4489 
4490       Symbol* name = m->name();
4491       Symbol* signature = m->signature();
4492       Klass* k = this_klass->super();
4493       Method* super_m = NULL;
4494       while (k != NULL) {
4495         // skip supers that don't have final methods.
4496         if (k->has_final_method()) {
4497           // lookup a matching method in the super class hierarchy
4498           super_m = InstanceKlass::cast(k)->lookup_method(name, signature);
4499           if (super_m == NULL) {
4500             break; // didn't find any match; get out
4501           }
4502 
4503           if (super_m->is_final() &&
4504               // matching method in super is final
4505               (Reflection::verify_field_access(this_klass(),
4506                                                super_m->method_holder(),
4507                                                super_m->method_holder(),


src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File