src/share/vm/classfile/javaClasses.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/classfile

src/share/vm/classfile/javaClasses.cpp

Print this page




 517               break;
 518       case T_SHORT:
 519         mirror()->short_field_put(fd->offset(), fd->int_initial_value());
 520               break;
 521       case T_INT:
 522         mirror()->int_field_put(fd->offset(), fd->int_initial_value());
 523         break;
 524       case T_FLOAT:
 525         mirror()->float_field_put(fd->offset(), fd->float_initial_value());
 526         break;
 527       case T_DOUBLE:
 528         mirror()->double_field_put(fd->offset(), fd->double_initial_value());
 529         break;
 530       case T_LONG:
 531         mirror()->long_field_put(fd->offset(), fd->long_initial_value());
 532         break;
 533       case T_OBJECT:
 534         {
 535           #ifdef ASSERT
 536           TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
 537           assert(fd->signature() == sym, "just checking");
 538           #endif
 539           oop string = fd->string_initial_value(CHECK);
 540           mirror()->obj_field_put(fd->offset(), string);
 541         }
 542         break;
 543       default:
 544         THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
 545                   "Illegal ConstantValue attribute in class file");
 546     }
 547   }
 548 }
 549 
 550 
 551 void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
 552   assert(InstanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
 553 
 554   // If the offset was read from the shared archive, it was fixed up already
 555   if (!k->is_shared()) {
 556     if (k->oop_is_instance()) {
 557       // During bootstrap, java.lang.Class wasn't loaded so static field


1689         }
1690       }
1691     }
1692 #ifdef ASSERT
1693     assert(st_method() == method && st.bci() == bci,
1694            "Wrong stack trace");
1695     st.next();
1696     // vframeStream::method isn't GC-safe so store off a copy
1697     // of the Method* in case we GC.
1698     if (!st.at_end()) {
1699       st_method = st.method();
1700     }
1701 #endif
1702 
1703     // the format of the stacktrace will be:
1704     // - 1 or more fillInStackTrace frames for the exception class (skipped)
1705     // - 0 or more <init> methods for the exception class (skipped)
1706     // - rest of the stack
1707 
1708     if (!skip_fillInStackTrace_check) {
1709       if ((method->name() == vmSymbols::fillInStackTrace_name() ||
1710            method->name() == vmSymbols::fillInStackTrace0_name()) &&
1711           throwable->is_a(method->method_holder())) {
1712         continue;
1713       }
1714       else {
1715         skip_fillInStackTrace_check = true; // gone past them all
1716       }
1717     }
1718     if (!skip_throwableInit_check) {
1719       assert(skip_fillInStackTrace_check, "logic error in backtrace filtering");
1720 
1721       // skip <init> methods of the exception class and superclasses
1722       // This is simlar to classic VM.
1723       if (method->name() == vmSymbols::object_initializer_name() &&
1724           throwable->is_a(method->method_holder())) {
1725         continue;
1726       } else {
1727         // there are none or we've seen them all - either way stop checking
1728         skip_throwableInit_check = true;
1729       }
1730     }
1731     if (method->is_hidden()) {
1732       if (skip_hidden)  continue;
1733     }
1734     bt.push(method, bci, CHECK);
1735     total_count++;
1736   }
1737 
1738   // Put completed stack trace into throwable object
1739   set_backtrace(throwable(), bt.backtrace());
1740 }
1741 
1742 void java_lang_Throwable::fill_in_stack_trace(Handle throwable, methodHandle method) {
1743   // No-op if stack trace is disabled


2914     compute_offset(_ptypes_offset, k, vmSymbols::ptypes_name(), vmSymbols::class_array_signature());
2915   }
2916 }
2917 
2918 void java_lang_invoke_MethodType::print_signature(oop mt, outputStream* st) {
2919   st->print("(");
2920   objArrayOop pts = ptypes(mt);
2921   for (int i = 0, limit = pts->length(); i < limit; i++) {
2922     java_lang_Class::print_signature(pts->obj_at(i), st);
2923   }
2924   st->print(")");
2925   java_lang_Class::print_signature(rtype(mt), st);
2926 }
2927 
2928 Symbol* java_lang_invoke_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAPS) {
2929   ResourceMark rm;
2930   stringStream buffer(128);
2931   print_signature(mt, &buffer);
2932   const char* sigstr =       buffer.base();
2933   int         siglen = (int) buffer.size();
2934   Symbol *name;
2935   if (!intern_if_not_found) {
2936     name = SymbolTable::probe(sigstr, siglen);
2937   } else {
2938     name = SymbolTable::new_symbol(sigstr, siglen, THREAD);
2939   }
2940   return name;
2941 }
2942 
2943 bool java_lang_invoke_MethodType::equals(oop mt1, oop mt2) {
2944   if (mt1 == mt2)
2945     return true;
2946   if (rtype(mt1) != rtype(mt2))
2947     return false;
2948   if (ptype_count(mt1) != ptype_count(mt2))
2949     return false;
2950   for (int i = ptype_count(mt1) - 1; i >= 0; i--) {
2951     if (ptype(mt1, i) != ptype(mt2, i))
2952       return false;
2953   }
2954   return true;


3596     const char* sig = "[Ljava/lang/String;";
3597     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classes, sig);
3598     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classEnabled, "[Z");
3599     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, packages, sig);
3600     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, packageEnabled, "[Z");
3601     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, deflt, "Z");
3602   }
3603 
3604   if (!valid) vm_exit_during_initialization("Hard-coded field offset verification failed");
3605 }
3606 
3607 #endif // PRODUCT
3608 
3609 int InjectedField::compute_offset() {
3610   Klass* klass_oop = klass();
3611   for (AllFieldStream fs(InstanceKlass::cast(klass_oop)); !fs.done(); fs.next()) {
3612     if (!may_be_java && !fs.access_flags().is_internal()) {
3613       // Only look at injected fields
3614       continue;
3615     }
3616     if (fs.name() == name() && fs.signature() == signature()) {
3617       return fs.offset();
3618     }
3619   }
3620   ResourceMark rm;
3621   tty->print_cr("Invalid layout of %s at %s/%s%s", InstanceKlass::cast(klass_oop)->external_name(), name()->as_C_string(), signature()->as_C_string(), may_be_java ? " (may_be_java)" : "");
3622 #ifndef PRODUCT
3623   klass_oop->print();
3624   tty->print_cr("all fields:");
3625   for (AllFieldStream fs(InstanceKlass::cast(klass_oop)); !fs.done(); fs.next()) {
3626     tty->print_cr("  name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int());
3627   }
3628 #endif //PRODUCT
3629   fatal("Invalid layout of preloaded class");
3630   return -1;
3631 }
3632 
3633 void javaClasses_init() {
3634   JavaClasses::compute_offsets();
3635   JavaClasses::check_offsets();
3636   FilteredFieldsMap::initialize();  // must be done after computing offsets.


 517               break;
 518       case T_SHORT:
 519         mirror()->short_field_put(fd->offset(), fd->int_initial_value());
 520               break;
 521       case T_INT:
 522         mirror()->int_field_put(fd->offset(), fd->int_initial_value());
 523         break;
 524       case T_FLOAT:
 525         mirror()->float_field_put(fd->offset(), fd->float_initial_value());
 526         break;
 527       case T_DOUBLE:
 528         mirror()->double_field_put(fd->offset(), fd->double_initial_value());
 529         break;
 530       case T_LONG:
 531         mirror()->long_field_put(fd->offset(), fd->long_initial_value());
 532         break;
 533       case T_OBJECT:
 534         {
 535           #ifdef ASSERT
 536           TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
 537           assert(fd->signature()->equals(sym), "just checking");
 538           #endif
 539           oop string = fd->string_initial_value(CHECK);
 540           mirror()->obj_field_put(fd->offset(), string);
 541         }
 542         break;
 543       default:
 544         THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
 545                   "Illegal ConstantValue attribute in class file");
 546     }
 547   }
 548 }
 549 
 550 
 551 void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
 552   assert(InstanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
 553 
 554   // If the offset was read from the shared archive, it was fixed up already
 555   if (!k->is_shared()) {
 556     if (k->oop_is_instance()) {
 557       // During bootstrap, java.lang.Class wasn't loaded so static field


1689         }
1690       }
1691     }
1692 #ifdef ASSERT
1693     assert(st_method() == method && st.bci() == bci,
1694            "Wrong stack trace");
1695     st.next();
1696     // vframeStream::method isn't GC-safe so store off a copy
1697     // of the Method* in case we GC.
1698     if (!st.at_end()) {
1699       st_method = st.method();
1700     }
1701 #endif
1702 
1703     // the format of the stacktrace will be:
1704     // - 1 or more fillInStackTrace frames for the exception class (skipped)
1705     // - 0 or more <init> methods for the exception class (skipped)
1706     // - rest of the stack
1707 
1708     if (!skip_fillInStackTrace_check) {
1709       if ((method->name()->equals(vmSymbols::fillInStackTrace_name()) ||
1710            method->name()->equals(vmSymbols::fillInStackTrace0_name())) &&
1711           throwable->is_a(method->method_holder())) {
1712         continue;
1713       }
1714       else {
1715         skip_fillInStackTrace_check = true; // gone past them all
1716       }
1717     }
1718     if (!skip_throwableInit_check) {
1719       assert(skip_fillInStackTrace_check, "logic error in backtrace filtering");
1720 
1721       // skip <init> methods of the exception class and superclasses
1722       // This is simlar to classic VM.
1723       if (method->name()->equals(vmSymbols::object_initializer_name()) &&
1724           throwable->is_a(method->method_holder())) {
1725         continue;
1726       } else {
1727         // there are none or we've seen them all - either way stop checking
1728         skip_throwableInit_check = true;
1729       }
1730     }
1731     if (method->is_hidden()) {
1732       if (skip_hidden)  continue;
1733     }
1734     bt.push(method, bci, CHECK);
1735     total_count++;
1736   }
1737 
1738   // Put completed stack trace into throwable object
1739   set_backtrace(throwable(), bt.backtrace());
1740 }
1741 
1742 void java_lang_Throwable::fill_in_stack_trace(Handle throwable, methodHandle method) {
1743   // No-op if stack trace is disabled


2914     compute_offset(_ptypes_offset, k, vmSymbols::ptypes_name(), vmSymbols::class_array_signature());
2915   }
2916 }
2917 
2918 void java_lang_invoke_MethodType::print_signature(oop mt, outputStream* st) {
2919   st->print("(");
2920   objArrayOop pts = ptypes(mt);
2921   for (int i = 0, limit = pts->length(); i < limit; i++) {
2922     java_lang_Class::print_signature(pts->obj_at(i), st);
2923   }
2924   st->print(")");
2925   java_lang_Class::print_signature(rtype(mt), st);
2926 }
2927 
2928 Symbol* java_lang_invoke_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAPS) {
2929   ResourceMark rm;
2930   stringStream buffer(128);
2931   print_signature(mt, &buffer);
2932   const char* sigstr =       buffer.base();
2933   int         siglen = (int) buffer.size();
2934   Symbol* name;
2935   if (!intern_if_not_found) {
2936     name = SymbolTable::probe(sigstr, siglen);
2937   } else {
2938     name = SymbolTable::new_symbol(sigstr, siglen, THREAD);
2939   }
2940   return name;
2941 }
2942 
2943 bool java_lang_invoke_MethodType::equals(oop mt1, oop mt2) {
2944   if (mt1 == mt2)
2945     return true;
2946   if (rtype(mt1) != rtype(mt2))
2947     return false;
2948   if (ptype_count(mt1) != ptype_count(mt2))
2949     return false;
2950   for (int i = ptype_count(mt1) - 1; i >= 0; i--) {
2951     if (ptype(mt1, i) != ptype(mt2, i))
2952       return false;
2953   }
2954   return true;


3596     const char* sig = "[Ljava/lang/String;";
3597     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classes, sig);
3598     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classEnabled, "[Z");
3599     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, packages, sig);
3600     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, packageEnabled, "[Z");
3601     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, deflt, "Z");
3602   }
3603 
3604   if (!valid) vm_exit_during_initialization("Hard-coded field offset verification failed");
3605 }
3606 
3607 #endif // PRODUCT
3608 
3609 int InjectedField::compute_offset() {
3610   Klass* klass_oop = klass();
3611   for (AllFieldStream fs(InstanceKlass::cast(klass_oop)); !fs.done(); fs.next()) {
3612     if (!may_be_java && !fs.access_flags().is_internal()) {
3613       // Only look at injected fields
3614       continue;
3615     }
3616     if (fs.name()->equals(name()) && fs.signature()->equals(signature())) {
3617       return fs.offset();
3618     }
3619   }
3620   ResourceMark rm;
3621   tty->print_cr("Invalid layout of %s at %s/%s%s", InstanceKlass::cast(klass_oop)->external_name(), name()->as_C_string(), signature()->as_C_string(), may_be_java ? " (may_be_java)" : "");
3622 #ifndef PRODUCT
3623   klass_oop->print();
3624   tty->print_cr("all fields:");
3625   for (AllFieldStream fs(InstanceKlass::cast(klass_oop)); !fs.done(); fs.next()) {
3626     tty->print_cr("  name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int());
3627   }
3628 #endif //PRODUCT
3629   fatal("Invalid layout of preloaded class");
3630   return -1;
3631 }
3632 
3633 void javaClasses_init() {
3634   JavaClasses::compute_offsets();
3635   JavaClasses::check_offsets();
3636   FilteredFieldsMap::initialize();  // must be done after computing offsets.
src/share/vm/classfile/javaClasses.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File