< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page

        

@@ -821,16 +821,17 @@
     } else {
       k->set_java_mirror_handle(NULL);
       k->clear_has_raw_archived_mirror();
     }
   }
-  create_mirror(k, Handle(), Handle(), Handle(), CHECK);
+  create_mirror(k, Handle(), Handle(), Handle(), Handle(), CHECK);
 }
 
 void java_lang_Class::initialize_mirror_fields(Klass* k,
                                                Handle mirror,
                                                Handle protection_domain,
+                                               Handle classData,
                                                TRAPS) {
   // Allocate a simple java object for a lock.
   // This needs to be a java object because during class initialization
   // it can be held across a java call.
   typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK);

@@ -839,10 +840,13 @@
   // Set protection domain also
   set_protection_domain(mirror(), protection_domain());
 
   // Initialize static fields
   InstanceKlass::cast(k)->do_local_static_fields(&initialize_static_field, mirror, CHECK);
+
+ // Set classData
+  set_class_data(mirror(), classData());
 }
 
 // Set the java.lang.Module module field in the java_lang_Class mirror
 void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle module, TRAPS) {
   if (module.is_null()) {

@@ -892,11 +896,12 @@
     new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
   set_fixup_module_field_list(module_list);
 }
 
 void java_lang_Class::create_mirror(Klass* k, Handle class_loader,
-                                    Handle module, Handle protection_domain, TRAPS) {
+                                    Handle module, Handle protection_domain,
+                                    Handle classData, TRAPS) {
   assert(k != NULL, "Use create_basic_type_mirror for primitive types");
   assert(k->java_mirror() == NULL, "should only assign mirror once");
 
   // Use this moment of initialization to cache modifier_flags also,
   // to support Class.getModifiers().  Instance classes recalculate

@@ -939,11 +944,11 @@
       // See below for ordering dependencies between field array_klass in component mirror
       // and java_mirror in this klass.
     } else {
       assert(k->is_instance_klass(), "Must be");
 
-      initialize_mirror_fields(k, mirror, protection_domain, THREAD);
+      initialize_mirror_fields(k, mirror, protection_domain, classData, THREAD);
       if (HAS_PENDING_EXCEPTION) {
         // If any of the fields throws an exception like OOM remove the klass field
         // from the mirror so GC doesn't follow it after the klass has been deallocated.
         // This mirror looks like a primitive type, which logically it is because it
         // it represents no class.

@@ -1337,10 +1342,19 @@
 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
   assert(_signers_offset != 0, "must be set");
   java_class->obj_field_put(_signers_offset, (oop)signers);
 }
 
+oop java_lang_Class::class_data(oop java_class) {
+  assert(_classData_offset != 0, "must be set");
+  return java_class->obj_field(_classData_offset);
+}
+void java_lang_Class::set_class_data(oop java_class, oop class_data) {
+  assert(_classData_offset != 0, "must be set");
+  java_class->obj_field_put(_classData_offset, class_data);
+}
+
 
 void java_lang_Class::set_class_loader(oop java_class, oop loader) {
   // jdk7 runs Queens in bootstrapping and jdk8-9 has no coordinated pushes yet.
   if (_class_loader_offset != 0) {
     java_class->obj_field_put(_class_loader_offset, loader);

@@ -1712,51 +1726,89 @@
   return java_thread->obj_field(_inheritedAccessControlContext_offset);
 }
 
 
 jlong java_lang_Thread::stackSize(oop java_thread) {
-  return java_thread->long_field(_stackSize_offset);
+  if (_stackSize_offset > 0) {
+    return java_thread->long_field(_stackSize_offset);
+  } else {
+    return 0;
+  }
 }
 
 // Write the thread status value to threadStatus field in java.lang.Thread java class.
 void java_lang_Thread::set_thread_status(oop java_thread,
                                          java_lang_Thread::ThreadStatus status) {
-  java_thread->int_field_put(_thread_status_offset, status);
+  // The threadStatus is only present starting in 1.5
+  if (_thread_status_offset > 0) {
+    java_thread->int_field_put(_thread_status_offset, status);
+  }
 }
 
 // Read thread status value from threadStatus field in java.lang.Thread java class.
 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
   // Make sure the caller is operating on behalf of the VM or is
   // running VM code (state == _thread_in_vm).
   assert(Threads_lock->owned_by_self() || Thread::current()->is_VM_thread() ||
          JavaThread::current()->thread_state() == _thread_in_vm,
          "Java Thread is not running in vm");
-  return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
+  // The threadStatus is only present starting in 1.5
+  if (_thread_status_offset > 0) {
+    return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
+  } else {
+    // All we can easily figure out is if it is alive, but that is
+    // enough info for a valid unknown status.
+    // These aren't restricted to valid set ThreadStatus values, so
+    // use JVMTI values and cast.
+    JavaThread* thr = java_lang_Thread::thread(java_thread);
+    if (thr == NULL) {
+      // the thread hasn't run yet or is in the process of exiting
+      return NEW;
+    }
+    return (java_lang_Thread::ThreadStatus)JVMTI_THREAD_STATE_ALIVE;
+  }
 }
 
 
 jlong java_lang_Thread::thread_id(oop java_thread) {
-  return java_thread->long_field(_tid_offset);
+  // The thread ID field is only present starting in 1.5
+  if (_tid_offset > 0) {
+    return java_thread->long_field(_tid_offset);
+  } else {
+    return 0;
+  }
 }
 
 oop java_lang_Thread::park_blocker(oop java_thread) {
-  assert(JDK_Version::current().supports_thread_park_blocker(),
-         "Must support parkBlocker field");
+  assert(JDK_Version::current().supports_thread_park_blocker() &&
+         _park_blocker_offset != 0, "Must support parkBlocker field");
 
-  return java_thread->obj_field(_park_blocker_offset);
+  if (_park_blocker_offset > 0) {
+    return java_thread->obj_field(_park_blocker_offset);
+  }
+
+  return NULL;
 }
 
 jlong java_lang_Thread::park_event(oop java_thread) {
-  return java_thread->long_field(_park_event_offset);
+  if (_park_event_offset > 0) {
+    return java_thread->long_field(_park_event_offset);
+  }
+  return 0;
 }
 
 bool java_lang_Thread::set_park_event(oop java_thread, jlong ptr) {
-  java_thread->long_field_put(_park_event_offset, ptr);
-  return true;
+  if (_park_event_offset > 0) {
+    java_thread->long_field_put(_park_event_offset, ptr);
+    return true;
+  }
+  return false;
 }
 
+
 const char* java_lang_Thread::thread_status_name(oop java_thread) {
+  assert(_thread_status_offset != 0, "Must have thread status");
   ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
   switch (status) {
     case NEW                      : return "NEW";
     case RUNNABLE                 : return "RUNNABLE";
     case SLEEPING                 : return "TIMED_WAITING (sleeping)";

@@ -3595,52 +3647,27 @@
 void java_lang_invoke_ResolvedMethodName::set_vmtarget(oop resolved_method, Method* m) {
   assert(is_instance(resolved_method), "wrong type");
   resolved_method->address_field_put(_vmtarget_offset, (address)m);
 }
 
-void java_lang_invoke_ResolvedMethodName::set_vmholder(oop resolved_method, oop holder) {
-  assert(is_instance(resolved_method), "wrong type");
-  resolved_method->obj_field_put(_vmholder_offset, holder);
-}
-
 oop java_lang_invoke_ResolvedMethodName::find_resolved_method(const methodHandle& m, TRAPS) {
-  const Method* method = m();
-
   // lookup ResolvedMethod oop in the table, or create a new one and intern it
-  oop resolved_method = ResolvedMethodTable::find_method(method);
-  if (resolved_method != NULL) {
-    return resolved_method;
-  }
-
-  InstanceKlass* k = SystemDictionary::ResolvedMethodName_klass();
-  if (!k->is_initialized()) {
-    k->initialize(CHECK_NULL);
+  oop resolved_method = ResolvedMethodTable::find_method(m());
+  if (resolved_method == NULL) {
+    InstanceKlass* k = SystemDictionary::ResolvedMethodName_klass();
+    if (!k->is_initialized()) {
+      k->initialize(CHECK_NULL);
+    }
+    oop new_resolved_method = k->allocate_instance(CHECK_NULL);
+    new_resolved_method->address_field_put(_vmtarget_offset, (address)m());
+    // Add a reference to the loader (actually mirror because unsafe anonymous classes will not have
+    // distinct loaders) to ensure the metadata is kept alive.
+    // This mirror may be different than the one in clazz field.
+    new_resolved_method->obj_field_put(_vmholder_offset, m->method_holder()->java_mirror());
+    resolved_method = ResolvedMethodTable::add_method(m, Handle(THREAD, new_resolved_method));
   }
-
-  oop new_resolved_method = k->allocate_instance(CHECK_NULL);
-
-  NoSafepointVerifier nsv;
-
-  if (method->is_old()) {
-    method = (method->is_deleted()) ? Universe::throw_no_such_method_error() :
-                                      method->get_new_method();
-  }
-
-  InstanceKlass* holder = method->method_holder();
-
-  set_vmtarget(new_resolved_method, const_cast<Method*>(method));
-  // Add a reference to the loader (actually mirror because unsafe anonymous classes will not have
-  // distinct loaders) to ensure the metadata is kept alive.
-  // This mirror may be different than the one in clazz field.
-  set_vmholder(new_resolved_method, holder->java_mirror());
-
-  // Set flag in class to indicate this InstanceKlass has entries in the table
-  // to avoid walking table during redefinition if none of the redefined classes
-  // have any membernames in the table.
-  holder->set_has_resolved_methods();
-
-  return ResolvedMethodTable::add_method(method, Handle(THREAD, new_resolved_method));
+  return resolved_method;
 }
 
 oop java_lang_invoke_LambdaForm::vmentry(oop lform) {
   assert(is_instance(lform), "wrong type");
   return lform->obj_field(_vmentry_offset);

@@ -4052,10 +4079,11 @@
 int java_lang_Class::_component_mirror_offset;
 int java_lang_Class::_init_lock_offset;
 int java_lang_Class::_signers_offset;
 int java_lang_Class::_name_offset;
 int java_lang_Class::_source_file_offset;
+int java_lang_Class::_classData_offset;
 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
 GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = NULL;
 int java_lang_Throwable::backtrace_offset;
 int java_lang_Throwable::detailMessage_offset;
 int java_lang_Throwable::stackTrace_offset;
< prev index next >