src/share/vm/oops/instanceKlass.cpp

changeset 6195
5832cdaf89c6
parent 6169
ad72068ac41e
child 6316
85318d1fe8fe
child 6503
a9becfeecd1b
     1.1 --- a/src/share/vm/oops/instanceKlass.cpp	Fri Dec 13 09:48:29 2013 -0800
     1.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Mon Dec 16 08:24:33 2013 -0500
     1.3 @@ -1498,13 +1498,18 @@
     1.4    return -1;
     1.5  }
     1.6  
     1.7 -// lookup_method searches both the local methods array and all superclasses methods arrays
     1.8 +// uncached_lookup_method searches both the local class methods array and all
     1.9 +// superclasses methods arrays, skipping any overpass methods in superclasses.
    1.10  Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
    1.11    Klass* klass = const_cast<InstanceKlass*>(this);
    1.12 +  bool dont_ignore_overpasses = true;  // For the class being searched, find its overpasses.
    1.13    while (klass != NULL) {
    1.14      Method* method = InstanceKlass::cast(klass)->find_method(name, signature);
    1.15 -    if (method != NULL) return method;
    1.16 +    if ((method != NULL) && (dont_ignore_overpasses || !method->is_overpass())) {
    1.17 +      return method;
    1.18 +    }
    1.19      klass = InstanceKlass::cast(klass)->super();
    1.20 +    dont_ignore_overpasses = false;  // Ignore overpass methods in all superclasses.
    1.21    }
    1.22    return NULL;
    1.23  }
    1.24 @@ -1519,7 +1524,7 @@
    1.25    }
    1.26    // Look up interfaces
    1.27    if (m == NULL) {
    1.28 -    m = lookup_method_in_all_interfaces(name, signature);
    1.29 +    m = lookup_method_in_all_interfaces(name, signature, false);
    1.30    }
    1.31    return m;
    1.32  }
    1.33 @@ -1528,14 +1533,16 @@
    1.34  // Do NOT return private or static methods, new in JDK8 which are not externally visible
    1.35  // They should only be found in the initial InterfaceMethodRef
    1.36  Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
    1.37 -                                                         Symbol* signature) const {
    1.38 +                                                       Symbol* signature,
    1.39 +                                                       bool skip_default_methods) const {
    1.40    Array<Klass*>* all_ifs = transitive_interfaces();
    1.41    int num_ifs = all_ifs->length();
    1.42    InstanceKlass *ik = NULL;
    1.43    for (int i = 0; i < num_ifs; i++) {
    1.44      ik = InstanceKlass::cast(all_ifs->at(i));
    1.45      Method* m = ik->lookup_method(name, signature);
    1.46 -    if (m != NULL && m->is_public() && !m->is_static()) {
    1.47 +    if (m != NULL && m->is_public() && !m->is_static() &&
    1.48 +        (!skip_default_methods || !m->is_default_method())) {
    1.49        return m;
    1.50      }
    1.51    }

mercurial