< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page

 257   tty->print_cr("Error: find_field called on a klass oop."
 258                 " Likely error: reflection method does not correctly"
 259                 " wrap return value in a mirror object.");
 260 #endif
 261   ShouldNotReachHere();
 262   return nullptr;
 263 }
 264 
 265 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
 266                                       OverpassLookupMode overpass_mode,
 267                                       PrivateLookupMode private_mode) const {
 268 #ifdef ASSERT
 269   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
 270                 " Likely error: reflection method does not correctly"
 271                 " wrap return value in a mirror object.");
 272 #endif
 273   ShouldNotReachHere();
 274   return nullptr;
 275 }
 276 
 277 static markWord make_prototype(const Klass* kls) {
 278   markWord prototype = markWord::prototype();
 279 #ifdef _LP64
 280   if (UseCompactObjectHeaders) {
 281     // With compact object headers, the narrow Klass ID is part of the mark word.
 282     // We therfore seed the mark word with the narrow Klass ID.
 283     // Note that only those Klass that can be instantiated have a narrow Klass ID.
 284     // For those who don't, we leave the klass bits empty and assert if someone
 285     // tries to use those.
 286     const narrowKlass nk = CompressedKlassPointers::is_encodable(kls) ?
 287         CompressedKlassPointers::encode(const_cast<Klass*>(kls)) : 0;
 288     prototype = prototype.set_narrow_klass(nk);
 289   }
 290 #endif
 291   return prototype;
 292 }
 293 
 294 Klass::Klass() : _kind(UnknownKlassKind) {
 295   assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
 296 }
 297 
 298 // "Normal" instantiation is preceded by a MetaspaceObj allocation
 299 // which zeros out memory - calloc equivalent.
 300 // The constructor is also used from CppVtableCloner,
 301 // which doesn't zero out the memory before calling the constructor.
 302 Klass::Klass(KlassKind kind) : _kind(kind),
 303                                _prototype_header(make_prototype(this)),
 304                                _shared_class_path_index(-1) {

 305   CDS_ONLY(_shared_class_flags = 0;)
 306   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
 307   _primary_supers[0] = this;
 308   set_super_check_offset(in_bytes(primary_supers_offset()));
 309 }
 310 
 311 jint Klass::array_layout_helper(BasicType etype) {
 312   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 313   // Note that T_ARRAY is not allowed here.
 314   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 315   int  esize = type2aelembytes(etype);
 316   bool isobj = (etype == T_OBJECT);
 317   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
 318   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
 319 
 320   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
 321   assert(layout_helper_is_array(lh), "correct kind");
 322   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
 323   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
 324   assert(layout_helper_header_size(lh) == hsize, "correct decode");
 325   assert(layout_helper_element_type(lh) == etype, "correct decode");
 326   assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
 327 
 328   return lh;
 329 }
 330 
 331 int Klass::modifier_flags() const {
 332   int mods = java_lang_Class::modifiers(java_mirror());
 333   assert(mods == compute_modifier_flags(), "should be same");
 334   return mods;
 335 }
 336 
 337 bool Klass::can_be_primary_super_slow() const {
 338   if (super() == nullptr)
 339     return true;
 340   else if (super()->super_depth() >= primary_super_limit()-1)
 341     return false;
 342   else

1019 void Klass::print_on(outputStream* st) const {
1020   ResourceMark rm;
1021   // print title
1022   st->print("%s", internal_name());
1023   print_address_on(st);
1024   st->cr();
1025 }
1026 
1027 #define BULLET  " - "
1028 
1029 // Caller needs ResourceMark
1030 void Klass::oop_print_on(oop obj, outputStream* st) {
1031   // print title
1032   st->print_cr("%s ", internal_name());
1033   obj->print_address_on(st);
1034 
1035   if (WizardMode) {
1036      // print header
1037      obj->mark().print_on(st);
1038      st->cr();
1039      if (UseCompactObjectHeaders) {
1040        st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
1041        st->cr();
1042      }
1043   }
1044 
1045   // print class
1046   st->print(BULLET"klass: ");
1047   obj->klass()->print_value_on(st);
1048   st->print(BULLET"flags: "); _misc_flags.print_on(st); st->cr();
1049   st->cr();
1050 }
1051 
1052 void Klass::oop_print_value_on(oop obj, outputStream* st) {
1053   // print title
1054   ResourceMark rm;              // Cannot print in debug mode without this
1055   st->print("%s", internal_name());
1056   obj->print_address_on(st);
1057 }
1058 
1059 // Verification
1060 
1061 void Klass::verify_on(outputStream* st) {
1062 

 257   tty->print_cr("Error: find_field called on a klass oop."
 258                 " Likely error: reflection method does not correctly"
 259                 " wrap return value in a mirror object.");
 260 #endif
 261   ShouldNotReachHere();
 262   return nullptr;
 263 }
 264 
 265 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
 266                                       OverpassLookupMode overpass_mode,
 267                                       PrivateLookupMode private_mode) const {
 268 #ifdef ASSERT
 269   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
 270                 " Likely error: reflection method does not correctly"
 271                 " wrap return value in a mirror object.");
 272 #endif
 273   ShouldNotReachHere();
 274   return nullptr;
 275 }
 276 

















 277 Klass::Klass() : _kind(UnknownKlassKind) {
 278   assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
 279 }
 280 
 281 // "Normal" instantiation is preceded by a MetaspaceObj allocation
 282 // which zeros out memory - calloc equivalent.
 283 // The constructor is also used from CppVtableCloner,
 284 // which doesn't zero out the memory before calling the constructor.
 285 Klass::Klass(KlassKind kind, markWord prototype_header) : _kind(kind),

 286                                _shared_class_path_index(-1) {
 287   set_prototype_header(make_prototype_header(this, prototype_header));
 288   CDS_ONLY(_shared_class_flags = 0;)
 289   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
 290   _primary_supers[0] = this;
 291   set_super_check_offset(in_bytes(primary_supers_offset()));
 292 }
 293 
 294 jint Klass::array_layout_helper(BasicType etype) {
 295   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 296   // Note that T_ARRAY is not allowed here.
 297   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 298   int  esize = type2aelembytes(etype);
 299   bool isobj = (etype == T_OBJECT);
 300   int  tag   =  isobj ? _lh_array_tag_ref_value : _lh_array_tag_type_value;
 301   int lh = array_layout_helper(tag, false, hsize, etype, exact_log2(esize));
 302 
 303   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
 304   assert(layout_helper_is_array(lh), "correct kind");
 305   assert(layout_helper_is_refArray(lh) == isobj, "correct kind");
 306   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
 307   assert(layout_helper_header_size(lh) == hsize, "correct decode");
 308   assert(layout_helper_element_type(lh) == etype, "correct decode");
 309   assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
 310 
 311   return lh;
 312 }
 313 
 314 int Klass::modifier_flags() const {
 315   int mods = java_lang_Class::modifiers(java_mirror());
 316   assert(mods == compute_modifier_flags(), "should be same");
 317   return mods;
 318 }
 319 
 320 bool Klass::can_be_primary_super_slow() const {
 321   if (super() == nullptr)
 322     return true;
 323   else if (super()->super_depth() >= primary_super_limit()-1)
 324     return false;
 325   else

1002 void Klass::print_on(outputStream* st) const {
1003   ResourceMark rm;
1004   // print title
1005   st->print("%s", internal_name());
1006   print_address_on(st);
1007   st->cr();
1008 }
1009 
1010 #define BULLET  " - "
1011 
1012 // Caller needs ResourceMark
1013 void Klass::oop_print_on(oop obj, outputStream* st) {
1014   // print title
1015   st->print_cr("%s ", internal_name());
1016   obj->print_address_on(st);
1017 
1018   if (WizardMode) {
1019      // print header
1020      obj->mark().print_on(st);
1021      st->cr();
1022      st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
1023      st->cr();


1024   }
1025 
1026   // print class
1027   st->print(BULLET"klass: ");
1028   obj->klass()->print_value_on(st);
1029   st->print(BULLET"flags: "); _misc_flags.print_on(st); st->cr();
1030   st->cr();
1031 }
1032 
1033 void Klass::oop_print_value_on(oop obj, outputStream* st) {
1034   // print title
1035   ResourceMark rm;              // Cannot print in debug mode without this
1036   st->print("%s", internal_name());
1037   obj->print_address_on(st);
1038 }
1039 
1040 // Verification
1041 
1042 void Klass::verify_on(outputStream* st) {
1043 
< prev index next >