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




  37 #include "oops/fieldStreams.hpp"
  38 #include "oops/instanceKlass.hpp"
  39 #include "oops/instanceMirrorKlass.hpp"
  40 #include "oops/klass.hpp"
  41 #include "oops/method.hpp"
  42 #include "oops/objArrayOop.inline.hpp"
  43 #include "oops/oop.inline.hpp"
  44 #include "oops/symbol.hpp"
  45 #include "oops/typeArrayOop.hpp"
  46 #include "prims/jvmtiRedefineClassesTrace.hpp"
  47 #include "runtime/fieldDescriptor.hpp"
  48 #include "runtime/handles.inline.hpp"
  49 #include "runtime/interfaceSupport.hpp"
  50 #include "runtime/java.hpp"
  51 #include "runtime/javaCalls.hpp"
  52 #include "runtime/safepoint.hpp"
  53 #include "runtime/thread.inline.hpp"
  54 #include "runtime/vframe.hpp"
  55 #include "utilities/preserveException.hpp"
  56 




  57 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  58 
  59 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
  60   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
  61 
  62 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
  63   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
  64 
  65 InjectedField JavaClasses::_injected_fields[] = {
  66   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
  67 };
  68 
  69 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
  70   return _injected_fields[id].compute_offset();
  71 }
  72 
  73 
  74 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
  75   *field_count = 0;
  76 


1563 void java_lang_Throwable::print_stack_element(outputStream *st, methodHandle method, int bci) {
1564   Handle mirror = method->method_holder()->java_mirror();
1565   int method_id = method->orig_method_idnum();
1566   int version = method->constants()->version();
1567   int cpref = method->name_index();
1568   print_stack_element(st, mirror, method_id, version, bci, cpref);
1569 }
1570 
1571 const char* java_lang_Throwable::no_stack_trace_message() {
1572   return "\t<<no stack trace available>>";
1573 }
1574 
1575 
1576 // Currently used only for exceptions occurring during startup
1577 void java_lang_Throwable::print_stack_trace(oop throwable, outputStream* st) {
1578   Thread *THREAD = Thread::current();
1579   Handle h_throwable(THREAD, throwable);
1580   while (h_throwable.not_null()) {
1581     objArrayHandle result (THREAD, objArrayOop(backtrace(h_throwable())));
1582     if (result.is_null()) {
1583       st->print_cr("%s", no_stack_trace_message());
1584       return;
1585     }
1586 
1587     while (result.not_null()) {
1588 
1589       // Get method id, bci, version and mirror from chunk
1590       typeArrayHandle methods (THREAD, BacktraceBuilder::get_methods(result));
1591       typeArrayHandle bcis (THREAD, BacktraceBuilder::get_bcis(result));
1592       objArrayHandle mirrors (THREAD, BacktraceBuilder::get_mirrors(result));
1593       typeArrayHandle cprefs (THREAD, BacktraceBuilder::get_cprefs(result));
1594 
1595       int length = methods()->length();
1596       for (int index = 0; index < length; index++) {
1597         Handle mirror(THREAD, mirrors->obj_at(index));
1598         // NULL mirror means end of stack trace
1599         if (mirror.is_null()) goto handle_cause;
1600         int method = methods->short_at(index);
1601         int version = version_at(bcis->int_at(index));
1602         int bci = bci_at(bcis->int_at(index));
1603         int cpref = cprefs->short_at(index);


3638     if (fs.name() == name() && fs.signature() == signature()) {
3639       return fs.offset();
3640     }
3641   }
3642   ResourceMark rm;
3643   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)" : "");
3644 #ifndef PRODUCT
3645   klass_oop->print();
3646   tty->print_cr("all fields:");
3647   for (AllFieldStream fs(InstanceKlass::cast(klass_oop)); !fs.done(); fs.next()) {
3648     tty->print_cr("  name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int());
3649   }
3650 #endif //PRODUCT
3651   vm_exit_during_initialization("Invalid layout of preloaded class: use -XX:+TraceClassLoading to see the origin of the problem class");
3652   return -1;
3653 }
3654 
3655 void javaClasses_init() {
3656   JavaClasses::compute_offsets();
3657   JavaClasses::check_offsets();





3658   FilteredFieldsMap::initialize();  // must be done after computing offsets.
3659 }


  37 #include "oops/fieldStreams.hpp"
  38 #include "oops/instanceKlass.hpp"
  39 #include "oops/instanceMirrorKlass.hpp"
  40 #include "oops/klass.hpp"
  41 #include "oops/method.hpp"
  42 #include "oops/objArrayOop.inline.hpp"
  43 #include "oops/oop.inline.hpp"
  44 #include "oops/symbol.hpp"
  45 #include "oops/typeArrayOop.hpp"
  46 #include "prims/jvmtiRedefineClassesTrace.hpp"
  47 #include "runtime/fieldDescriptor.hpp"
  48 #include "runtime/handles.inline.hpp"
  49 #include "runtime/interfaceSupport.hpp"
  50 #include "runtime/java.hpp"
  51 #include "runtime/javaCalls.hpp"
  52 #include "runtime/safepoint.hpp"
  53 #include "runtime/thread.inline.hpp"
  54 #include "runtime/vframe.hpp"
  55 #include "utilities/preserveException.hpp"
  56 
  57 #if INCLUDE_JVMCI
  58 #include "jvmci/jvmciJavaClasses.hpp"
  59 #endif
  60 
  61 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  62 
  63 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
  64   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
  65 
  66 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
  67   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
  68 
  69 InjectedField JavaClasses::_injected_fields[] = {
  70   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
  71 };
  72 
  73 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
  74   return _injected_fields[id].compute_offset();
  75 }
  76 
  77 
  78 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
  79   *field_count = 0;
  80 


1567 void java_lang_Throwable::print_stack_element(outputStream *st, methodHandle method, int bci) {
1568   Handle mirror = method->method_holder()->java_mirror();
1569   int method_id = method->orig_method_idnum();
1570   int version = method->constants()->version();
1571   int cpref = method->name_index();
1572   print_stack_element(st, mirror, method_id, version, bci, cpref);
1573 }
1574 
1575 const char* java_lang_Throwable::no_stack_trace_message() {
1576   return "\t<<no stack trace available>>";
1577 }
1578 
1579 
1580 // Currently used only for exceptions occurring during startup
1581 void java_lang_Throwable::print_stack_trace(oop throwable, outputStream* st) {
1582   Thread *THREAD = Thread::current();
1583   Handle h_throwable(THREAD, throwable);
1584   while (h_throwable.not_null()) {
1585     objArrayHandle result (THREAD, objArrayOop(backtrace(h_throwable())));
1586     if (result.is_null()) {
1587       st->print_raw_cr(no_stack_trace_message());
1588       return;
1589     }
1590 
1591     while (result.not_null()) {
1592 
1593       // Get method id, bci, version and mirror from chunk
1594       typeArrayHandle methods (THREAD, BacktraceBuilder::get_methods(result));
1595       typeArrayHandle bcis (THREAD, BacktraceBuilder::get_bcis(result));
1596       objArrayHandle mirrors (THREAD, BacktraceBuilder::get_mirrors(result));
1597       typeArrayHandle cprefs (THREAD, BacktraceBuilder::get_cprefs(result));
1598 
1599       int length = methods()->length();
1600       for (int index = 0; index < length; index++) {
1601         Handle mirror(THREAD, mirrors->obj_at(index));
1602         // NULL mirror means end of stack trace
1603         if (mirror.is_null()) goto handle_cause;
1604         int method = methods->short_at(index);
1605         int version = version_at(bcis->int_at(index));
1606         int bci = bci_at(bcis->int_at(index));
1607         int cpref = cprefs->short_at(index);


3642     if (fs.name() == name() && fs.signature() == signature()) {
3643       return fs.offset();
3644     }
3645   }
3646   ResourceMark rm;
3647   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)" : "");
3648 #ifndef PRODUCT
3649   klass_oop->print();
3650   tty->print_cr("all fields:");
3651   for (AllFieldStream fs(InstanceKlass::cast(klass_oop)); !fs.done(); fs.next()) {
3652     tty->print_cr("  name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int());
3653   }
3654 #endif //PRODUCT
3655   vm_exit_during_initialization("Invalid layout of preloaded class: use -XX:+TraceClassLoading to see the origin of the problem class");
3656   return -1;
3657 }
3658 
3659 void javaClasses_init() {
3660   JavaClasses::compute_offsets();
3661   JavaClasses::check_offsets();
3662 #if INCLUDE_JVMCI
3663   if (EnableJVMCI) {
3664     JVMCIJavaClasses::compute_offsets();
3665   }
3666 #endif
3667   FilteredFieldsMap::initialize();  // must be done after computing offsets.
3668 }
src/share/vm/classfile/javaClasses.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File