当前位置: 首页>>代码示例>>C++>>正文


C++ instanceKlassHandle::fields_annotations方法代码示例

本文整理汇总了C++中instanceKlassHandle::fields_annotations方法的典型用法代码示例。如果您正苦于以下问题:C++ instanceKlassHandle::fields_annotations方法的具体用法?C++ instanceKlassHandle::fields_annotations怎么用?C++ instanceKlassHandle::fields_annotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在instanceKlassHandle的用法示例。


在下文中一共展示了instanceKlassHandle::fields_annotations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: redefine_single_class

// Install the redefinition of a class --
// The original instanceKlass object (k_h) always represents the latest 
// version of the respective class. However, during class redefinition we swap
// or replace much of its content with that of the instanceKlass object created
// from the bytes of the redefine (k_h_new). Specifically, k_h points to the new
// constantpool and methods objects, which we take from k_h_new. k_h_new, in turn,
// assumes the role of the previous class version, with the old constantpool and
// methods (taken from k_h) attached to it. k_h links to k_h_new to create a 
// linked list of class versions. 
void VM_RedefineClasses::redefine_single_class(jclass j_clazz, instanceKlassHandle k_h_new, TRAPS) {

  oop mirror = JNIHandles::resolve_non_null(j_clazz);
  klassOop k_oop = java_lang_Class::as_klassOop(mirror);
  instanceKlassHandle k_h = instanceKlassHandle(THREAD, k_oop);

  // Remove all breakpoints in methods of this class
  JvmtiBreakpoints& jvmti_breakpoints = JvmtiCurrentBreakpoints::get_jvmti_breakpoints();
  jvmti_breakpoints.clearall_in_class_at_safepoint(k_oop); 

  // Deoptimize all compiled code that depends on this class
  NOT_CORE(Universe::flush_evol_dependents_on(k_h));

  _old_methods = k_h->methods();
  _new_methods = k_h_new->methods();
  _evolving_koop = k_oop;
  _old_constants = k_h->constants();

  // flush the cached jmethodID fields for _old_methods
  flush_method_jmethod_id_cache();

  // Patch the indexes into the constantpool from the array of fields of the evolving
  // class. This is required, because the layout of the new constantpool can be different,
  // so old indexes corresponding to field names and signatures can become invalid.
  patch_indexes_for_fields(k_h, k_h_new);

  // Make new constantpool object (and methodOops via it) point to the original class object
  k_h_new->constants()->set_pool_holder(k_h());

  // Replace methods and constantpool
  k_h->set_methods(_new_methods);
  k_h_new->set_methods(_old_methods);     // To prevent potential GCing of the old methods, 
                                          // and to be able to undo operation easily.

  constantPoolOop old_constants = k_h->constants();
  k_h->set_constants(k_h_new->constants());
  k_h_new->set_constants(old_constants);  // See the previous comment.

  check_methods_and_mark_as_old();
  transfer_old_native_function_registrations();

  // Replace inner_classes
  typeArrayOop old_inner_classes = k_h->inner_classes();
  k_h->set_inner_classes(k_h_new->inner_classes());
  k_h_new->set_inner_classes(old_inner_classes);

  // Initialize the vtable and interface table after
  // methods have been rewritten
  { ResourceMark rm(THREAD);
  k_h->vtable()->initialize_vtable(THREAD); // No exception can happen here
  k_h->itable()->initialize_itable();
  }

  // Copy the "source file name" attribute from new class version
  k_h->set_source_file_name(k_h_new->source_file_name());

  // Copy the "source debug extension" attribute from new class version
  k_h->set_source_debug_extension(k_h_new->source_debug_extension());

  // Use of javac -g could be different in the old and the new
  if (k_h_new->access_flags().has_localvariable_table() !=
      k_h->access_flags().has_localvariable_table()) {

    AccessFlags flags = k_h->access_flags();
    if (k_h_new->access_flags().has_localvariable_table()) {
      flags.set_has_localvariable_table();
    } else {
      flags.clear_has_localvariable_table();
    }
    k_h->set_access_flags(flags);
  }

  // Replace class annotation fields values
  typeArrayOop old_class_annotations = k_h->class_annotations();
  k_h->set_class_annotations(k_h_new->class_annotations());
  k_h_new->set_class_annotations(old_class_annotations);

  // Replace fields annotation fields values
  objArrayOop old_fields_annotations = k_h->fields_annotations();
  k_h->set_fields_annotations(k_h_new->fields_annotations());
  k_h_new->set_fields_annotations(old_fields_annotations);

  // Replace methods annotation fields values
  objArrayOop old_methods_annotations = k_h->methods_annotations();
  k_h->set_methods_annotations(k_h_new->methods_annotations());
  k_h_new->set_methods_annotations(old_methods_annotations);

  // Replace methods parameter annotation fields values
  objArrayOop old_methods_parameter_annotations = k_h->methods_parameter_annotations();
  k_h->set_methods_parameter_annotations(k_h_new->methods_parameter_annotations());
  k_h_new->set_methods_parameter_annotations(old_methods_parameter_annotations);
//.........这里部分代码省略.........
开发者ID:subxiang,项目名称:jdk-source-code,代码行数:101,代码来源:jvmtiRedefineClasses.cpp


注:本文中的instanceKlassHandle::fields_annotations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。