hotspot/src/share/vm/oops/constantPool.cpp
changeset 14391 df0a1573d5bd
parent 14385 959bbcc16725
child 14588 8ec26d2d9339
equal deleted inserted replaced
14390:bd0d881cf1c5 14391:df0a1573d5bd
   226       if (this_oop->tag_at(which).is_unresolved_klass_in_error()) {
   226       if (this_oop->tag_at(which).is_unresolved_klass_in_error()) {
   227         in_error = true;
   227         in_error = true;
   228       } else {
   228       } else {
   229         do_resolve = true;
   229         do_resolve = true;
   230         name   = this_oop->unresolved_klass_at(which);
   230         name   = this_oop->unresolved_klass_at(which);
   231         loader = Handle(THREAD, InstanceKlass::cast(this_oop->pool_holder())->class_loader());
   231         loader = Handle(THREAD, this_oop->pool_holder()->class_loader());
   232       }
   232       }
   233     }
   233     }
   234   } // unlocking constantPool
   234   } // unlocking constantPool
   235 
   235 
   236 
   236 
   245     THROW_MSG_0(error, className);
   245     THROW_MSG_0(error, className);
   246   }
   246   }
   247 
   247 
   248   if (do_resolve) {
   248   if (do_resolve) {
   249     // this_oop must be unlocked during resolve_or_fail
   249     // this_oop must be unlocked during resolve_or_fail
   250     oop protection_domain = Klass::cast(this_oop->pool_holder())->protection_domain();
   250     oop protection_domain = this_oop->pool_holder()->protection_domain();
   251     Handle h_prot (THREAD, protection_domain);
   251     Handle h_prot (THREAD, protection_domain);
   252     Klass* k_oop = SystemDictionary::resolve_or_fail(name, loader, h_prot, true, THREAD);
   252     Klass* k_oop = SystemDictionary::resolve_or_fail(name, loader, h_prot, true, THREAD);
   253     KlassHandle k;
   253     KlassHandle k;
   254     if (!HAS_PENDING_EXCEPTION) {
   254     if (!HAS_PENDING_EXCEPTION) {
   255       k = KlassHandle(THREAD, k_oop);
   255       k = KlassHandle(THREAD, k_oop);
   313       if (JavaThread::current()->has_last_Java_frame()) {
   313       if (JavaThread::current()->has_last_Java_frame()) {
   314         // try to identify the method which called this function.
   314         // try to identify the method which called this function.
   315         vframeStream vfst(JavaThread::current());
   315         vframeStream vfst(JavaThread::current());
   316         if (!vfst.at_end()) {
   316         if (!vfst.at_end()) {
   317           line_number = vfst.method()->line_number_from_bci(vfst.bci());
   317           line_number = vfst.method()->line_number_from_bci(vfst.bci());
   318           Symbol* s = InstanceKlass::cast(vfst.method()->method_holder())->source_file_name();
   318           Symbol* s = vfst.method()->method_holder()->source_file_name();
   319           if (s != NULL) {
   319           if (s != NULL) {
   320             source_file = s->as_C_string();
   320             source_file = s->as_C_string();
   321           }
   321           }
   322         }
   322         }
   323       }
   323       }
   324       if (k() != this_oop->pool_holder()) {
   324       if (k() != this_oop->pool_holder()) {
   325         // only print something if the classes are different
   325         // only print something if the classes are different
   326         if (source_file != NULL) {
   326         if (source_file != NULL) {
   327           tty->print("RESOLVE %s %s %s:%d\n",
   327           tty->print("RESOLVE %s %s %s:%d\n",
   328                      InstanceKlass::cast(this_oop->pool_holder())->external_name(),
   328                      this_oop->pool_holder()->external_name(),
   329                      InstanceKlass::cast(k())->external_name(), source_file, line_number);
   329                      InstanceKlass::cast(k())->external_name(), source_file, line_number);
   330         } else {
   330         } else {
   331           tty->print("RESOLVE %s %s\n",
   331           tty->print("RESOLVE %s %s\n",
   332                      InstanceKlass::cast(this_oop->pool_holder())->external_name(),
   332                      this_oop->pool_holder()->external_name(),
   333                      InstanceKlass::cast(k())->external_name());
   333                      InstanceKlass::cast(k())->external_name());
   334         }
   334         }
   335       }
   335       }
   336       return k();
   336       return k();
   337     } else {
   337     } else {
   338       MonitorLockerEx ml(this_oop->lock());
   338       MonitorLockerEx ml(this_oop->lock());
   339       // Only updated constant pool - if it is resolved.
   339       // Only updated constant pool - if it is resolved.
   340       do_resolve = this_oop->tag_at(which).is_unresolved_klass();
   340       do_resolve = this_oop->tag_at(which).is_unresolved_klass();
   341       if (do_resolve) {
   341       if (do_resolve) {
   342         ClassLoaderData* this_key = InstanceKlass::cast(this_oop->pool_holder())->class_loader_data();
   342         ClassLoaderData* this_key = this_oop->pool_holder()->class_loader_data();
   343         if (!this_key->is_the_null_class_loader_data()) {
   343         if (!this_key->is_the_null_class_loader_data()) {
   344           this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM
   344           this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM
   345         }
   345         }
   346         this_oop->klass_at_put(which, k());
   346         this_oop->klass_at_put(which, k());
   347       }
   347       }
   365     return entry.get_klass();
   365     return entry.get_klass();
   366   } else {
   366   } else {
   367     assert(entry.is_unresolved(), "must be either symbol or klass");
   367     assert(entry.is_unresolved(), "must be either symbol or klass");
   368     Thread *thread = Thread::current();
   368     Thread *thread = Thread::current();
   369     Symbol* name = entry.get_symbol();
   369     Symbol* name = entry.get_symbol();
   370     oop loader = InstanceKlass::cast(this_oop->pool_holder())->class_loader();
   370     oop loader = this_oop->pool_holder()->class_loader();
   371     oop protection_domain = Klass::cast(this_oop->pool_holder())->protection_domain();
   371     oop protection_domain = this_oop->pool_holder()->protection_domain();
   372     Handle h_prot (thread, protection_domain);
   372     Handle h_prot (thread, protection_domain);
   373     Handle h_loader (thread, loader);
   373     Handle h_loader (thread, loader);
   374     Klass* k = SystemDictionary::find(name, h_loader, h_prot, thread);
   374     Klass* k = SystemDictionary::find(name, h_loader, h_prot, thread);
   375 
   375 
   376     if (k != NULL) {
   376     if (k != NULL) {
   407     assert(entry.get_klass()->is_klass(), "must be");
   407     assert(entry.get_klass()->is_klass(), "must be");
   408     return entry.get_klass();
   408     return entry.get_klass();
   409   } else {
   409   } else {
   410     assert(entry.is_unresolved(), "must be either symbol or klass");
   410     assert(entry.is_unresolved(), "must be either symbol or klass");
   411     Symbol*  name  = entry.get_symbol();
   411     Symbol*  name  = entry.get_symbol();
   412     oop loader = InstanceKlass::cast(this_oop->pool_holder())->class_loader();
   412     oop loader = this_oop->pool_holder()->class_loader();
   413     oop protection_domain = Klass::cast(this_oop->pool_holder())->protection_domain();
   413     oop protection_domain = this_oop->pool_holder()->protection_domain();
   414     Handle h_loader(THREAD, loader);
   414     Handle h_loader(THREAD, loader);
   415     Handle h_prot  (THREAD, protection_domain);
   415     Handle h_prot  (THREAD, protection_domain);
   416     KlassHandle k(THREAD, SystemDictionary::find(name, h_loader, h_prot, THREAD));
   416     KlassHandle k(THREAD, SystemDictionary::find(name, h_loader, h_prot, THREAD));
   417 
   417 
   418     // Do access check for klasses
   418     // Do access check for klasses
  1788   // Ensure that all the patches have been used.
  1788   // Ensure that all the patches have been used.
  1789   for (int index = 0; index < cp_patches->length(); index++) {
  1789   for (int index = 0; index < cp_patches->length(); index++) {
  1790     assert(cp_patches->at(index).is_null(),
  1790     assert(cp_patches->at(index).is_null(),
  1791            err_msg("Unused constant pool patch at %d in class file %s",
  1791            err_msg("Unused constant pool patch at %d in class file %s",
  1792                    index,
  1792                    index,
  1793                    InstanceKlass::cast(pool_holder())->external_name()));
  1793                    pool_holder()->external_name()));
  1794   }
  1794   }
  1795 #endif // ASSERT
  1795 #endif // ASSERT
  1796 }
  1796 }
  1797 
  1797 
  1798 #ifndef PRODUCT
  1798 #ifndef PRODUCT
  1946   if (operands() != NULL)  st->print("/operands[%d]", operands()->length());
  1946   if (operands() != NULL)  st->print("/operands[%d]", operands()->length());
  1947   print_address_on(st);
  1947   print_address_on(st);
  1948   st->print(" for ");
  1948   st->print(" for ");
  1949   pool_holder()->print_value_on(st);
  1949   pool_holder()->print_value_on(st);
  1950   if (pool_holder() != NULL) {
  1950   if (pool_holder() != NULL) {
  1951     bool extra = (InstanceKlass::cast(pool_holder())->constants() != this);
  1951     bool extra = (pool_holder()->constants() != this);
  1952     if (extra)  st->print(" (extra)");
  1952     if (extra)  st->print(" (extra)");
  1953   }
  1953   }
  1954   if (cache() != NULL) {
  1954   if (cache() != NULL) {
  1955     st->print(" cache=" PTR_FORMAT, cache());
  1955     st->print(" cache=" PTR_FORMAT, cache());
  1956   }
  1956   }