< prev index next >

src/share/vm/code/dependencies.cpp

Print this page




1065       // Default methods from interfaces can be added to classes. In
1066       // that case the holder of the method is not the class but the
1067       // interface where it's defined.
1068       assert(fm->is_default_method(), "sanity");
1069       return NULL;
1070     }
1071     return fm;
1072   }
1073 
1074 #ifdef ASSERT
1075   // Assert that m is inherited into ctxk, without intervening overrides.
1076   // (May return true even if this is not true, in corner cases where we punt.)
1077   bool check_method_context(Klass* ctxk, Method* m) {
1078     if (m->method_holder() == ctxk)
1079       return true;  // Quick win.
1080     if (m->is_private())
1081       return false; // Quick lose.  Should not happen.
1082     if (!(m->is_public() || m->is_protected()))
1083       // The override story is complex when packages get involved.
1084       return true;  // Must punt the assertion to true.
1085     Klass* k = ctxk;
1086     Method* lm = k->lookup_method(m->name(), m->signature());
1087     if (lm == NULL && k->is_instance_klass()) {
1088       // It might be an interface method
1089       lm = InstanceKlass::cast(k)->lookup_method_in_ordered_interfaces(m->name(),
1090                                                                  m->signature());
1091     }
1092     if (lm == m)
1093       // Method m is inherited into ctxk.
1094       return true;
1095     if (lm != NULL) {
1096       if (!(lm->is_public() || lm->is_protected())) {
1097         // Method is [package-]private, so the override story is complex.
1098         return true;  // Must punt the assertion to true.
1099       }
1100       if (lm->is_static()) {
1101         // Static methods don't override non-static so punt
1102         return true;
1103       }
1104       if (   !Dependencies::is_concrete_method(lm, k)
1105           && !Dependencies::is_concrete_method(m, ctxk)
1106           && lm->method_holder()->is_subtype_of(m->method_holder()))

1107         // Method m is overridden by lm, but both are non-concrete.
1108         return true;
1109     }







1110     ResourceMark rm;
1111     tty->print_cr("Dependency method not found in the associated context:");
1112     tty->print_cr("  context = %s", ctxk->external_name());
1113     tty->print(   "  method = "); m->print_short_name(tty); tty->cr();
1114     if (lm != NULL) {
1115       tty->print( "  found = "); lm->print_short_name(tty); tty->cr();
1116     }
1117     return false;
1118   }
1119 #endif
1120 
1121   void add_participant(Klass* participant) {
1122     assert(_num_participants + _record_witnesses < PARTICIPANT_LIMIT, "oob");
1123     int np = _num_participants++;
1124     _participants[np] = participant;
1125     _participants[np+1] = NULL;
1126     _found_methods[np+1] = NULL;
1127   }
1128 
1129   void record_witnesses(int add) {




1065       // Default methods from interfaces can be added to classes. In
1066       // that case the holder of the method is not the class but the
1067       // interface where it's defined.
1068       assert(fm->is_default_method(), "sanity");
1069       return NULL;
1070     }
1071     return fm;
1072   }
1073 
1074 #ifdef ASSERT
1075   // Assert that m is inherited into ctxk, without intervening overrides.
1076   // (May return true even if this is not true, in corner cases where we punt.)
1077   bool check_method_context(Klass* ctxk, Method* m) {
1078     if (m->method_holder() == ctxk)
1079       return true;  // Quick win.
1080     if (m->is_private())
1081       return false; // Quick lose.  Should not happen.
1082     if (!(m->is_public() || m->is_protected()))
1083       // The override story is complex when packages get involved.
1084       return true;  // Must punt the assertion to true.
1085     Method* lm = ctxk->lookup_method(m->name(), m->signature());
1086     if (lm == NULL && ctxk->is_instance_klass()) {

1087       // It might be an interface method
1088       lm = InstanceKlass::cast(ctxk)->lookup_method_in_ordered_interfaces(m->name(),
1089                                                                           m->signature());
1090     }
1091     if (lm == m)
1092       // Method m is inherited into ctxk.
1093       return true;
1094     if (lm != NULL) {
1095       if (!(lm->is_public() || lm->is_protected())) {
1096         // Method is [package-]private, so the override story is complex.
1097         return true;  // Must punt the assertion to true.
1098       }
1099       if (lm->is_static()) {
1100         // Static methods don't override non-static so punt
1101         return true;
1102       }
1103       if (!Dependencies::is_concrete_method(lm, ctxk) &&
1104           !Dependencies::is_concrete_method(m, ctxk)) {
1105         // They are both non-concrete
1106         if (lm->method_holder()->is_subtype_of(m->method_holder())) {
1107           // Method m is overridden by lm, but both are non-concrete.
1108           return true;
1109         }
1110         if (lm->method_holder()->is_interface() && m->method_holder()->is_interface() &&
1111             ctxk->is_subtype_of(m->method_holder()) && ctxk->is_subtype_of(lm->method_holder())) {
1112           // Interface method defined in multiple super interfaces
1113           return true;
1114         }
1115       }
1116     }
1117     ResourceMark rm;
1118     tty->print_cr("Dependency method not found in the associated context:");
1119     tty->print_cr("  context = %s", ctxk->external_name());
1120     tty->print(   "  method = "); m->print_short_name(tty); tty->cr();
1121     if (lm != NULL) {
1122       tty->print( "  found = "); lm->print_short_name(tty); tty->cr();
1123     }
1124     return false;
1125   }
1126 #endif
1127 
1128   void add_participant(Klass* participant) {
1129     assert(_num_participants + _record_witnesses < PARTICIPANT_LIMIT, "oob");
1130     int np = _num_participants++;
1131     _participants[np] = participant;
1132     _participants[np+1] = NULL;
1133     _found_methods[np+1] = NULL;
1134   }
1135 
1136   void record_witnesses(int add) {


< prev index next >