src/share/vm/oops/instanceKlass.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File bug_8027804.2 Sdiff src/share/vm/oops

src/share/vm/oops/instanceKlass.cpp

Print this page




1481   return -1;
1482 }
1483 int InstanceKlass::find_method_by_name(Symbol* name, int* end) {
1484   return find_method_by_name(methods(), name, end);
1485 }
1486 
1487 int InstanceKlass::find_method_by_name(
1488     Array<Method*>* methods, Symbol* name, int* end_ptr) {
1489   assert(end_ptr != NULL, "just checking");
1490   int start = binary_search(methods, name);
1491   int end = start + 1;
1492   if (start != -1) {
1493     while (start - 1 >= 0 && (methods->at(start - 1))->name() == name) --start;
1494     while (end < methods->length() && (methods->at(end))->name() == name) ++end;
1495     *end_ptr = end;
1496     return start;
1497   }
1498   return -1;
1499 }
1500 
1501 // lookup_method searches both the local methods array and all superclasses methods arrays

1502 Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
1503   Klass* klass = const_cast<InstanceKlass*>(this);

1504   while (klass != NULL) {
1505     Method* method = InstanceKlass::cast(klass)->find_method(name, signature);
1506     if (method != NULL) return method;


1507     klass = InstanceKlass::cast(klass)->super();

1508   }
1509   return NULL;
1510 }
1511 
1512 // lookup a method in the default methods list then in all transitive interfaces
1513 // Do NOT return private or static methods
1514 Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name,
1515                                                          Symbol* signature) const {
1516   Method* m = NULL;
1517   if (default_methods() != NULL) {
1518     m = find_method(default_methods(), name, signature);
1519   }
1520   // Look up interfaces
1521   if (m == NULL) {
1522     m = lookup_method_in_all_interfaces(name, signature);
1523   }
1524   return m;
1525 }
1526 
1527 // 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
1529 // They should only be found in the initial InterfaceMethodRef
1530 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
1531                                                          Symbol* signature) const {

1532   Array<Klass*>* all_ifs = transitive_interfaces();
1533   int num_ifs = all_ifs->length();
1534   InstanceKlass *ik = NULL;
1535   for (int i = 0; i < num_ifs; i++) {
1536     ik = InstanceKlass::cast(all_ifs->at(i));
1537     Method* m = ik->lookup_method(name, signature);
1538     if (m != NULL && m->is_public() && !m->is_static()) {

1539       return m;
1540     }
1541   }
1542   return NULL;
1543 }
1544 
1545 /* jni_id_for_impl for jfieldIds only */
1546 JNIid* InstanceKlass::jni_id_for_impl(instanceKlassHandle this_oop, int offset) {
1547   MutexLocker ml(JfieldIdCreation_lock);
1548   // Retry lookup after we got the lock
1549   JNIid* probe = this_oop->jni_ids() == NULL ? NULL : this_oop->jni_ids()->find(offset);
1550   if (probe == NULL) {
1551     // Slow case, allocate new static field identifier
1552     probe = new JNIid(this_oop(), offset, this_oop->jni_ids());
1553     this_oop->set_jni_ids(probe);
1554   }
1555   return probe;
1556 }
1557 
1558 




1481   return -1;
1482 }
1483 int InstanceKlass::find_method_by_name(Symbol* name, int* end) {
1484   return find_method_by_name(methods(), name, end);
1485 }
1486 
1487 int InstanceKlass::find_method_by_name(
1488     Array<Method*>* methods, Symbol* name, int* end_ptr) {
1489   assert(end_ptr != NULL, "just checking");
1490   int start = binary_search(methods, name);
1491   int end = start + 1;
1492   if (start != -1) {
1493     while (start - 1 >= 0 && (methods->at(start - 1))->name() == name) --start;
1494     while (end < methods->length() && (methods->at(end))->name() == name) ++end;
1495     *end_ptr = end;
1496     return start;
1497   }
1498   return -1;
1499 }
1500 
1501 // uncached_lookup_method searches both the local class methods array and all
1502 // superclasses methods arrays, skipping any overpass methods in superclasses.
1503 Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
1504   Klass* klass = const_cast<InstanceKlass*>(this);
1505   bool dont_ignore_overpasses = true;  // For the class being searched, find its overpasses.
1506   while (klass != NULL) {
1507     Method* method = InstanceKlass::cast(klass)->find_method(name, signature);
1508     if ((method != NULL) && (dont_ignore_overpasses || !method->is_overpass())) {
1509       return method;
1510     }
1511     klass = InstanceKlass::cast(klass)->super();
1512     dont_ignore_overpasses = false;  // Ignore overpass methods in all superclasses.
1513   }
1514   return NULL;
1515 }
1516 
1517 // lookup a method in the default methods list then in all transitive interfaces
1518 // Do NOT return private or static methods
1519 Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name,
1520                                                          Symbol* signature) const {
1521   Method* m = NULL;
1522   if (default_methods() != NULL) {
1523     m = find_method(default_methods(), name, signature);
1524   }
1525   // Look up interfaces
1526   if (m == NULL) {
1527     m = lookup_method_in_all_interfaces(name, signature, false);
1528   }
1529   return m;
1530 }
1531 
1532 // lookup a method in all the interfaces that this class implements
1533 // Do NOT return private or static methods, new in JDK8 which are not externally visible
1534 // They should only be found in the initial InterfaceMethodRef
1535 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
1536                                                        Symbol* signature,
1537                                                        bool skip_default_methods) const {
1538   Array<Klass*>* all_ifs = transitive_interfaces();
1539   int num_ifs = all_ifs->length();
1540   InstanceKlass *ik = NULL;
1541   for (int i = 0; i < num_ifs; i++) {
1542     ik = InstanceKlass::cast(all_ifs->at(i));
1543     Method* m = ik->lookup_method(name, signature);
1544     if (m != NULL && m->is_public() && !m->is_static() &&
1545         (!skip_default_methods || !m->is_default_method())) {
1546       return m;
1547     }
1548   }
1549   return NULL;
1550 }
1551 
1552 /* jni_id_for_impl for jfieldIds only */
1553 JNIid* InstanceKlass::jni_id_for_impl(instanceKlassHandle this_oop, int offset) {
1554   MutexLocker ml(JfieldIdCreation_lock);
1555   // Retry lookup after we got the lock
1556   JNIid* probe = this_oop->jni_ids() == NULL ? NULL : this_oop->jni_ids()->find(offset);
1557   if (probe == NULL) {
1558     // Slow case, allocate new static field identifier
1559     probe = new JNIid(this_oop(), offset, this_oop->jni_ids());
1560     this_oop->set_jni_ids(probe);
1561   }
1562   return probe;
1563 }
1564 
1565 


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