comparison src/share/vm/oops/instanceKlass.cpp @ 17464:5832cdaf89c6

8027804: JCK resolveMethod test fails expecting AbstractMethodError Summary: Create AME overpass methods and fix method search logic Reviewed-by: kamg, acorn, lfoltan, coleenp
author hseigel
date Mon, 16 Dec 2013 08:24:33 -0500
parents ad72068ac41e
children 48314d596a04 abec000618bf a9becfeecd1b
comparison
equal deleted inserted replaced
17452:7469c9ca967a 17464:5832cdaf89c6
1496 return start; 1496 return start;
1497 } 1497 }
1498 return -1; 1498 return -1;
1499 } 1499 }
1500 1500
1501 // lookup_method searches both the local methods array and all superclasses methods arrays 1501 // uncached_lookup_method searches both the local class methods array and all
1502 // superclasses methods arrays, skipping any overpass methods in superclasses.
1502 Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const { 1503 Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
1503 Klass* klass = const_cast<InstanceKlass*>(this); 1504 Klass* klass = const_cast<InstanceKlass*>(this);
1505 bool dont_ignore_overpasses = true; // For the class being searched, find its overpasses.
1504 while (klass != NULL) { 1506 while (klass != NULL) {
1505 Method* method = InstanceKlass::cast(klass)->find_method(name, signature); 1507 Method* method = InstanceKlass::cast(klass)->find_method(name, signature);
1506 if (method != NULL) return method; 1508 if ((method != NULL) && (dont_ignore_overpasses || !method->is_overpass())) {
1509 return method;
1510 }
1507 klass = InstanceKlass::cast(klass)->super(); 1511 klass = InstanceKlass::cast(klass)->super();
1512 dont_ignore_overpasses = false; // Ignore overpass methods in all superclasses.
1508 } 1513 }
1509 return NULL; 1514 return NULL;
1510 } 1515 }
1511 1516
1512 // lookup a method in the default methods list then in all transitive interfaces 1517 // lookup a method in the default methods list then in all transitive interfaces
1517 if (default_methods() != NULL) { 1522 if (default_methods() != NULL) {
1518 m = find_method(default_methods(), name, signature); 1523 m = find_method(default_methods(), name, signature);
1519 } 1524 }
1520 // Look up interfaces 1525 // Look up interfaces
1521 if (m == NULL) { 1526 if (m == NULL) {
1522 m = lookup_method_in_all_interfaces(name, signature); 1527 m = lookup_method_in_all_interfaces(name, signature, false);
1523 } 1528 }
1524 return m; 1529 return m;
1525 } 1530 }
1526 1531
1527 // lookup a method in all the interfaces that this class implements 1532 // lookup a method in all the interfaces that this class implements
1528 // Do NOT return private or static methods, new in JDK8 which are not externally visible 1533 // Do NOT return private or static methods, new in JDK8 which are not externally visible
1529 // They should only be found in the initial InterfaceMethodRef 1534 // They should only be found in the initial InterfaceMethodRef
1530 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name, 1535 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
1531 Symbol* signature) const { 1536 Symbol* signature,
1537 bool skip_default_methods) const {
1532 Array<Klass*>* all_ifs = transitive_interfaces(); 1538 Array<Klass*>* all_ifs = transitive_interfaces();
1533 int num_ifs = all_ifs->length(); 1539 int num_ifs = all_ifs->length();
1534 InstanceKlass *ik = NULL; 1540 InstanceKlass *ik = NULL;
1535 for (int i = 0; i < num_ifs; i++) { 1541 for (int i = 0; i < num_ifs; i++) {
1536 ik = InstanceKlass::cast(all_ifs->at(i)); 1542 ik = InstanceKlass::cast(all_ifs->at(i));
1537 Method* m = ik->lookup_method(name, signature); 1543 Method* m = ik->lookup_method(name, signature);
1538 if (m != NULL && m->is_public() && !m->is_static()) { 1544 if (m != NULL && m->is_public() && !m->is_static() &&
1545 (!skip_default_methods || !m->is_default_method())) {
1539 return m; 1546 return m;
1540 } 1547 }
1541 } 1548 }
1542 return NULL; 1549 return NULL;
1543 } 1550 }