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


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

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


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

示例1: check_shared_class_file_load_hook

// called during initial loading of a shared class
instanceKlassHandle KlassFactory::check_shared_class_file_load_hook(
                                          instanceKlassHandle ik,
                                          Symbol* class_name,
                                          Handle class_loader,
                                          Handle protection_domain, TRAPS) {
#if INCLUDE_CDS && INCLUDE_JVMTI
  assert(ik.not_null(), "sanity");
  assert(ik()->is_shared(), "expecting a shared class");

  if (JvmtiExport::should_post_class_file_load_hook()) {
    assert(THREAD->is_Java_thread(), "must be JavaThread");

    // Post the CFLH
    JvmtiCachedClassFileData* cached_class_file = NULL;
    JvmtiCachedClassFileData* archived_class_data = ik->get_archived_class_data();
    assert(archived_class_data != NULL, "shared class has no archived class data");
    unsigned char* ptr =
        VM_RedefineClasses::get_cached_class_file_bytes(archived_class_data);
    unsigned char* end_ptr =
        ptr + VM_RedefineClasses::get_cached_class_file_len(archived_class_data);
    unsigned char* old_ptr = ptr;
    JvmtiExport::post_class_file_load_hook(class_name,
                                           class_loader,
                                           protection_domain,
                                           &ptr,
                                           &end_ptr,
                                           &cached_class_file);
    if (old_ptr != ptr) {
      // JVMTI agent has modified class file data.
      // Set new class file stream using JVMTI agent modified class file data.
      ClassLoaderData* loader_data =
        ClassLoaderData::class_loader_data(class_loader());
      int path_index = ik->shared_classpath_index();
      SharedClassPathEntry* ent =
        (SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
      ClassFileStream* stream = new ClassFileStream(ptr,
                                                    end_ptr - ptr,
                                                    ent == NULL ? NULL : ent->_name,
                                                    ClassFileStream::verify);
      ClassFileParser parser(stream,
                             class_name,
                             loader_data,
                             protection_domain,
                             NULL,
                             NULL,
                             ClassFileParser::BROADCAST, // publicity level
                             CHECK_NULL);
      instanceKlassHandle new_ik = parser.create_instance_klass(true /* changed_by_loadhook */,
                                                                CHECK_NULL);
      if (cached_class_file != NULL) {
        new_ik->set_cached_class_file(cached_class_file);
      }

      if (class_loader.is_null()) {
        ResourceMark rm;
        ClassLoader::add_package(class_name->as_C_string(), path_index, THREAD);
      }

      return new_ik;
    }
  }
#endif

  return NULL;
}
开发者ID:,项目名称:,代码行数:66,代码来源:


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