hotspot/src/share/vm/classfile/javaClasses.cpp
changeset 25057 f38210f84f8c
parent 24429 4efc66ee325c
child 25326 85b2f2e63e3e
equal deleted inserted replaced
25056:5ad92b0d1beb 25057:f38210f84f8c
   855 
   855 
   856   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
   856   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
   857 }
   857 }
   858 
   858 
   859 int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
   859 int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
   860   if (!JDK_Version::is_gte_jdk15x_version()
   860   if (classRedefinedCount_offset == -1) {
   861       || classRedefinedCount_offset == -1) {
       
   862     // The classRedefinedCount field is only present starting in 1.5.
       
   863     // If we don't have an offset for it then just return -1 as a marker.
   861     // If we don't have an offset for it then just return -1 as a marker.
   864     return -1;
   862     return -1;
   865   }
   863   }
   866 
   864 
   867   return the_class_mirror->int_field(classRedefinedCount_offset);
   865   return the_class_mirror->int_field(classRedefinedCount_offset);
   868 }
   866 }
   869 
   867 
   870 void java_lang_Class::set_classRedefinedCount(oop the_class_mirror, int value) {
   868 void java_lang_Class::set_classRedefinedCount(oop the_class_mirror, int value) {
   871   if (!JDK_Version::is_gte_jdk15x_version()
   869   if (classRedefinedCount_offset == -1) {
   872       || classRedefinedCount_offset == -1) {
       
   873     // The classRedefinedCount field is only present starting in 1.5.
       
   874     // If we don't have an offset for it then nothing to set.
   870     // If we don't have an offset for it then nothing to set.
   875     return;
   871     return;
   876   }
   872   }
   877 
   873 
   878   the_class_mirror->int_field_put(classRedefinedCount_offset, value);
   874   the_class_mirror->int_field_put(classRedefinedCount_offset, value);
   998   return java_thread->obj_field(_inheritedAccessControlContext_offset);
   994   return java_thread->obj_field(_inheritedAccessControlContext_offset);
   999 }
   995 }
  1000 
   996 
  1001 
   997 
  1002 jlong java_lang_Thread::stackSize(oop java_thread) {
   998 jlong java_lang_Thread::stackSize(oop java_thread) {
  1003   // The stackSize field is only present starting in 1.4
       
  1004   if (_stackSize_offset > 0) {
   999   if (_stackSize_offset > 0) {
  1005     assert(JDK_Version::is_gte_jdk14x_version(), "sanity check");
       
  1006     return java_thread->long_field(_stackSize_offset);
  1000     return java_thread->long_field(_stackSize_offset);
  1007   } else {
  1001   } else {
  1008     return 0;
  1002     return 0;
  1009   }
  1003   }
  1010 }
  1004 }
  1076   return false;
  1070   return false;
  1077 }
  1071 }
  1078 
  1072 
  1079 
  1073 
  1080 const char* java_lang_Thread::thread_status_name(oop java_thread) {
  1074 const char* java_lang_Thread::thread_status_name(oop java_thread) {
  1081   assert(JDK_Version::is_gte_jdk15x_version() && _thread_status_offset != 0, "Must have thread status");
  1075   assert(_thread_status_offset != 0, "Must have thread status");
  1082   ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
  1076   ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
  1083   switch (status) {
  1077   switch (status) {
  1084     case NEW                      : return "NEW";
  1078     case NEW                      : return "NEW";
  1085     case RUNNABLE                 : return "RUNNABLE";
  1079     case RUNNABLE                 : return "RUNNABLE";
  1086     case SLEEPING                 : return "TIMED_WAITING (sleeping)";
  1080     case SLEEPING                 : return "TIMED_WAITING (sleeping)";
  1215 void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) {
  1209 void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) {
  1216   throwable->obj_field_put(stackTrace_offset, st_element_array);
  1210   throwable->obj_field_put(stackTrace_offset, st_element_array);
  1217 }
  1211 }
  1218 
  1212 
  1219 void java_lang_Throwable::clear_stacktrace(oop throwable) {
  1213 void java_lang_Throwable::clear_stacktrace(oop throwable) {
  1220   assert(JDK_Version::is_gte_jdk14x_version(), "should only be called in >= 1.4");
       
  1221   set_stacktrace(throwable, NULL);
  1214   set_stacktrace(throwable, NULL);
  1222 }
  1215 }
  1223 
  1216 
  1224 
  1217 
  1225 void java_lang_Throwable::print(oop throwable, outputStream* st) {
  1218 void java_lang_Throwable::print(oop throwable, outputStream* st) {
  1546   ResourceMark rm(THREAD);
  1539   ResourceMark rm(THREAD);
  1547 
  1540 
  1548   // Start out by clearing the backtrace for this object, in case the VM
  1541   // Start out by clearing the backtrace for this object, in case the VM
  1549   // runs out of memory while allocating the stack trace
  1542   // runs out of memory while allocating the stack trace
  1550   set_backtrace(throwable(), NULL);
  1543   set_backtrace(throwable(), NULL);
  1551   if (JDK_Version::is_gte_jdk14x_version()) {
  1544   // Clear lazily constructed Java level stacktrace if refilling occurs
  1552     // New since 1.4, clear lazily constructed Java level stacktrace if
  1545   // This is unnecessary in 1.7+ but harmless
  1553     // refilling occurs
  1546   clear_stacktrace(throwable());
  1554     // This is unnecessary in 1.7+ but harmless
       
  1555     clear_stacktrace(throwable());
       
  1556   }
       
  1557 
  1547 
  1558   int max_depth = MaxJavaStackTraceDepth;
  1548   int max_depth = MaxJavaStackTraceDepth;
  1559   JavaThread* thread = (JavaThread*)THREAD;
  1549   JavaThread* thread = (JavaThread*)THREAD;
  1560   BacktraceBuilder bt(CHECK);
  1550   BacktraceBuilder bt(CHECK);
  1561 
  1551 
  1737 
  1727 
  1738     // Bail-out for deep stacks
  1728     // Bail-out for deep stacks
  1739     if (chunk_count >= max_chunks) break;
  1729     if (chunk_count >= max_chunks) break;
  1740   }
  1730   }
  1741 
  1731 
  1742   // For Java 7+ we support the Throwable immutability protocol defined for Java 7. This support
  1732   // We support the Throwable immutability protocol defined for Java 7.
  1743   // was missing in 7u0 so in 7u0 there is a workaround in the Throwable class. That workaround
  1733   java_lang_Throwable::set_stacktrace(throwable(), java_lang_Throwable::unassigned_stacktrace());
  1744   // can be removed in a JDK using this JVM version
  1734   assert(java_lang_Throwable::unassigned_stacktrace() != NULL, "not initialized");
  1745   if (JDK_Version::is_gte_jdk17x_version()) {
       
  1746       java_lang_Throwable::set_stacktrace(throwable(), java_lang_Throwable::unassigned_stacktrace());
       
  1747       assert(java_lang_Throwable::unassigned_stacktrace() != NULL, "not initialized");
       
  1748   }
       
  1749 }
  1735 }
  1750 
  1736 
  1751 
  1737 
  1752 int java_lang_Throwable::get_stack_trace_depth(oop throwable, TRAPS) {
  1738 int java_lang_Throwable::get_stack_trace_depth(oop throwable, TRAPS) {
  1753   if (throwable == NULL) {
  1739   if (throwable == NULL) {
  3020 
  3006 
  3021 // For class loader classes, parallelCapable defined
  3007 // For class loader classes, parallelCapable defined
  3022 // based on non-null field
  3008 // based on non-null field
  3023 // Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it
  3009 // Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it
  3024 bool java_lang_ClassLoader::parallelCapable(oop class_loader) {
  3010 bool java_lang_ClassLoader::parallelCapable(oop class_loader) {
  3025   if (!JDK_Version::is_gte_jdk17x_version()
  3011   if (parallelCapable_offset == -1) {
  3026      || parallelCapable_offset == -1) {
       
  3027      // Default for backward compatibility is false
  3012      // Default for backward compatibility is false
  3028      return false;
  3013      return false;
  3029   }
  3014   }
  3030   return (class_loader->obj_field(parallelCapable_offset) != NULL);
  3015   return (class_loader->obj_field(parallelCapable_offset) != NULL);
  3031 }
  3016 }
  3217 }
  3202 }
  3218 
  3203 
  3219 void java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(TRAPS) {
  3204 void java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(TRAPS) {
  3220   if (_owner_offset != 0) return;
  3205   if (_owner_offset != 0) return;
  3221 
  3206 
  3222   assert(JDK_Version::is_gte_jdk16x_version(), "Must be JDK 1.6 or later");
       
  3223   SystemDictionary::load_abstract_ownable_synchronizer_klass(CHECK);
  3207   SystemDictionary::load_abstract_ownable_synchronizer_klass(CHECK);
  3224   Klass* k = SystemDictionary::abstract_ownable_synchronizer_klass();
  3208   Klass* k = SystemDictionary::abstract_ownable_synchronizer_klass();
  3225   compute_offset(_owner_offset, k,
  3209   compute_offset(_owner_offset, k,
  3226                  vmSymbols::exclusive_owner_thread_name(), vmSymbols::thread_signature());
  3210                  vmSymbols::exclusive_owner_thread_name(), vmSymbols::thread_signature());
  3227 }
  3211 }
  3307   // point we defer computation of these offsets until now.
  3291   // point we defer computation of these offsets until now.
  3308   java_lang_reflect_AccessibleObject::compute_offsets();
  3292   java_lang_reflect_AccessibleObject::compute_offsets();
  3309   java_lang_reflect_Method::compute_offsets();
  3293   java_lang_reflect_Method::compute_offsets();
  3310   java_lang_reflect_Constructor::compute_offsets();
  3294   java_lang_reflect_Constructor::compute_offsets();
  3311   java_lang_reflect_Field::compute_offsets();
  3295   java_lang_reflect_Field::compute_offsets();
  3312   if (JDK_Version::is_gte_jdk14x_version()) {
  3296   java_nio_Buffer::compute_offsets();
  3313     java_nio_Buffer::compute_offsets();
  3297   sun_reflect_ConstantPool::compute_offsets();
  3314   }
  3298   sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
  3315   if (JDK_Version::is_gte_jdk15x_version()) {
  3299   java_lang_reflect_Parameter::compute_offsets();
  3316     sun_reflect_ConstantPool::compute_offsets();
       
  3317     sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
       
  3318   }
       
  3319   if (JDK_Version::is_gte_jdk18x_version())
       
  3320     java_lang_reflect_Parameter::compute_offsets();
       
  3321 
  3300 
  3322   // generated interpreter code wants to know about the offsets we just computed:
  3301   // generated interpreter code wants to know about the offsets we just computed:
  3323   AbstractAssembler::update_delayed_values();
  3302   AbstractAssembler::update_delayed_values();
  3324 }
  3303 }
  3325 
  3304 
  3500   // The CheckAssertionStatusDirectives boolean can be removed from here and
  3479   // The CheckAssertionStatusDirectives boolean can be removed from here and
  3501   // globals.hpp after the AssertionStatusDirectives class has been integrated
  3480   // globals.hpp after the AssertionStatusDirectives class has been integrated
  3502   // into merlin "for some time."  Without it, the vm will fail with early
  3481   // into merlin "for some time."  Without it, the vm will fail with early
  3503   // merlin builds.
  3482   // merlin builds.
  3504 
  3483 
  3505   if (CheckAssertionStatusDirectives && JDK_Version::is_gte_jdk14x_version()) {
  3484   if (CheckAssertionStatusDirectives) {
  3506     const char* nm = "java/lang/AssertionStatusDirectives";
  3485     const char* nm = "java/lang/AssertionStatusDirectives";
  3507     const char* sig = "[Ljava/lang/String;";
  3486     const char* sig = "[Ljava/lang/String;";
  3508     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classes, sig);
  3487     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classes, sig);
  3509     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classEnabled, "[Z");
  3488     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classEnabled, "[Z");
  3510     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, packages, sig);
  3489     CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, packages, sig);