< prev index next >

src/share/vm/oops/method.cpp

Print this page




1458   if (id != vmIntrinsics::_none) {
1459     // Set up its iid.  It is an alias method.
1460     set_intrinsic_id(id);
1461     return;
1462   }
1463 }
1464 
1465 // These two methods are static since a GC may move the Method
1466 bool Method::load_signature_classes(methodHandle m, TRAPS) {
1467   if (!THREAD->can_call_java()) {
1468     // There is nothing useful this routine can do from within the Compile thread.
1469     // Hopefully, the signature contains only well-known classes.
1470     // We could scan for this and return true/false, but the caller won't care.
1471     return false;
1472   }
1473   bool sig_is_loaded = true;
1474   Handle class_loader(THREAD, m->method_holder()->class_loader());
1475   Handle protection_domain(THREAD, m->method_holder()->protection_domain());
1476   ResourceMark rm(THREAD);
1477   Symbol*  signature = m->signature();
1478   for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
1479     if (ss.is_object()) {
1480       Symbol* sym = ss.as_symbol(CHECK_(false));
1481       Symbol*  name  = sym;
1482       Klass* klass = SystemDictionary::resolve_or_null(name, class_loader,
1483                                              protection_domain, THREAD);
1484       // We are loading classes eagerly. If a ClassNotFoundException or
1485       // a LinkageError was generated, be sure to ignore it.
1486       if (HAS_PENDING_EXCEPTION) {
1487         if (PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass()) ||
1488             PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) {
1489           CLEAR_PENDING_EXCEPTION;
1490         } else {
1491           return false;
1492         }
1493       }
1494       if( klass == NULL) { sig_is_loaded = false; }
1495     }
1496   }
1497   return sig_is_loaded;
1498 }
1499 
1500 bool Method::has_unloaded_classes_in_signature(methodHandle m, TRAPS) {
1501   Handle class_loader(THREAD, m->method_holder()->class_loader());
1502   Handle protection_domain(THREAD, m->method_holder()->protection_domain());
1503   ResourceMark rm(THREAD);
1504   Symbol*  signature = m->signature();
1505   for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
1506     if (ss.type() == T_OBJECT) {
1507       Symbol* name = ss.as_symbol_or_null();
1508       if (name == NULL) return true;
1509       Klass* klass = SystemDictionary::find(name, class_loader, protection_domain, THREAD);
1510       if (klass == NULL) return true;






































1511     }
1512   }
1513   return false;
1514 }
1515 
1516 // Exposed so field engineers can debug VM
1517 void Method::print_short_name(outputStream* st) {
1518   ResourceMark rm;
1519 #ifdef PRODUCT
1520   st->print(" %s::", method_holder()->external_name());
1521 #else
1522   st->print(" %s::", method_holder()->internal_name());
1523 #endif
1524   name()->print_symbol_on(st);
1525   if (WizardMode) signature()->print_symbol_on(st);
1526   else if (MethodHandles::is_signature_polymorphic(intrinsic_id()))
1527     MethodHandles::print_as_basic_type_signature_on(st, signature(), true);
1528 }
1529 
1530 // Comparer for sorting an object array containing




1458   if (id != vmIntrinsics::_none) {
1459     // Set up its iid.  It is an alias method.
1460     set_intrinsic_id(id);
1461     return;
1462   }
1463 }
1464 
1465 // These two methods are static since a GC may move the Method
1466 bool Method::load_signature_classes(methodHandle m, TRAPS) {
1467   if (!THREAD->can_call_java()) {
1468     // There is nothing useful this routine can do from within the Compile thread.
1469     // Hopefully, the signature contains only well-known classes.
1470     // We could scan for this and return true/false, but the caller won't care.
1471     return false;
1472   }
1473   bool sig_is_loaded = true;
1474   Handle class_loader(THREAD, m->method_holder()->class_loader());
1475   Handle protection_domain(THREAD, m->method_holder()->protection_domain());
1476   ResourceMark rm(THREAD);
1477   Symbol*  signature = m->signature();
1478   for (SignatureStream ss(signature); !ss.is_done(); ss.next()) {
1479     if (ss.is_object()) {
1480       Symbol* sym = ss.as_symbol(CHECK_(false));
1481       Symbol*  name  = sym;
1482       Klass* klass = SystemDictionary::resolve_or_null(name, class_loader,
1483                                              protection_domain, THREAD);
1484       // We are loading classes eagerly. If a ClassNotFoundException or
1485       // a LinkageError was generated, be sure to ignore it.
1486       if (HAS_PENDING_EXCEPTION) {
1487         if (PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass()) ||
1488             PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) {
1489           CLEAR_PENDING_EXCEPTION;
1490         } else {
1491           return false;
1492         }
1493       }
1494       if( klass == NULL) { sig_is_loaded = false; }
1495     }
1496   }
1497   return sig_is_loaded;
1498 }
1499 
1500 bool Method::has_unloaded_classes_in_signature(methodHandle m, TRAPS) {
1501   Handle class_loader(THREAD, m->method_holder()->class_loader());
1502   Handle protection_domain(THREAD, m->method_holder()->protection_domain());
1503   ResourceMark rm(THREAD);
1504   Symbol*  signature = m->signature();
1505   for (SignatureStream ss(signature); !ss.is_done(); ss.next()) {
1506     if (ss.type() == T_OBJECT) {
1507       Symbol* name = ss.as_symbol_or_null();
1508       if (name == NULL) return true;
1509       Klass* klass = SystemDictionary::find(name, class_loader, protection_domain, THREAD);
1510       if (klass == NULL) {
1511         if (IgnoreUnloadedAccessConstructorTags &&
1512             ss.is_last_arg() && m->is_synthetic() &&
1513             m->name() == vmSymbols::object_initializer_name()) {
1514           // Check for the "accessConstructorTag" that javac generates merely for
1515           // overload resolution purpose. Ignore it even if it's not loaded, because
1516           // the only value that's going to be passed in is null - thus the class
1517           // never needs to be loaded.
1518           //
1519           // e.g. For java.util.ArrayList.iterator(),
1520           //   return new Itr();
1521           // actually desugars to:
1522           //   return new ArrayList$Itr(this, /*accessConstructorTag*/ null);
1523           // This is because Itr is a private inner class of ArrayList without
1524           // an explicit constructor, so javac synthesizes a default constructor
1525           // for it:
1526           //   private java.util.ArrayList$Itr(java.util.ArrayList);
1527           // But this one follows the accessibility of the class so it's private.
1528           // In order to allow the enclosing class to have access to Itr's
1529           // constructor, javac synthesizes yet another bridge constructor with
1530           // the right accessibility:
1531           //   java.util.ArrayList$Itr(java.util.ArrayList, java.util.ArrayList$1);
1532           // These two constructors would have exactly the same name (<init>),
1533           // the same argument list (the enclosing 'this'), and the same return
1534           // type (void). So, javac introduces a marker argument at the end of
1535           // the bridge constructor's argument list, so that the two constructors
1536           // can be well-formed overloads, and always pass a null to that argument.
1537           // Thus, even when the class of this argument isn't loaded, it's still
1538           // safe to compile/inline this bridge constructor.
1539           //
1540           // javac forms the name of the type 'accessConstructorTag' by appending
1541           // "$1" to the name fo the top-level class. Using a simple heuristic
1542           // here should be good enough.
1543           if (name->ends_with("$1")) continue; // skip this marker arg
1544         } else {
1545           // this is a normal argument whose class isn't loaded
1546           return true;
1547         }
1548       }
1549     }
1550   }
1551   return false;
1552 }
1553 
1554 // Exposed so field engineers can debug VM
1555 void Method::print_short_name(outputStream* st) {
1556   ResourceMark rm;
1557 #ifdef PRODUCT
1558   st->print(" %s::", method_holder()->external_name());
1559 #else
1560   st->print(" %s::", method_holder()->internal_name());
1561 #endif
1562   name()->print_symbol_on(st);
1563   if (WizardMode) signature()->print_symbol_on(st);
1564   else if (MethodHandles::is_signature_polymorphic(intrinsic_id()))
1565     MethodHandles::print_as_basic_type_signature_on(st, signature(), true);
1566 }
1567 
1568 // Comparer for sorting an object array containing


< prev index next >