Top


定義場所(file name)

hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp

名前(function name)

void JvmtiClassFileReconstituter::write_class_file_format() {

本体部(body)

  {- -------------------------------------------
  (1) (地道にクラスファイルを復元している...)
      ---------------------------------------- -}

      ReallocMark();

      // JVMSpec|   ClassFile {
      // JVMSpec|           u4 magic;
      write_u4(0xCAFEBABE);

      // JVMSpec|           u2 minor_version;
      // JVMSpec|           u2 major_version;
      write_u2(ikh()->minor_version());
      u2 major = ikh()->major_version();
      write_u2(major);

      // JVMSpec|           u2 constant_pool_count;
      // JVMSpec|           cp_info constant_pool[constant_pool_count-1];
      write_u2(cpool()->length());
      copy_cpool_bytes(writeable_address(cpool_size()));

      // JVMSpec|           u2 access_flags;
      write_u2(ikh()->access_flags().get_flags() & JVM_RECOGNIZED_CLASS_MODIFIERS);

      // JVMSpec|           u2 this_class;
      // JVMSpec|           u2 super_class;
      write_u2(class_symbol_to_cpool_index(ikh()->name()));
      klassOop super_class = ikh()->super();
      write_u2(super_class == NULL? 0 :  // zero for java.lang.Object
                    class_symbol_to_cpool_index(super_class->klass_part()->name()));

      // JVMSpec|           u2 interfaces_count;
      // JVMSpec|           u2 interfaces[interfaces_count];
      objArrayHandle interfaces(thread(), ikh()->local_interfaces());
      int num_interfaces = interfaces->length();
      write_u2(num_interfaces);
      for (int index = 0; index < num_interfaces; index++) {
        HandleMark hm(thread());
        instanceKlassHandle iikh(thread(), klassOop(interfaces->obj_at(index)));
        write_u2(class_symbol_to_cpool_index(iikh->name()));
      }

      // JVMSpec|           u2 fields_count;
      // JVMSpec|           field_info fields[fields_count];
      write_field_infos();

      // JVMSpec|           u2 methods_count;
      // JVMSpec|           method_info methods[methods_count];
      write_method_infos();

      // JVMSpec|           u2 attributes_count;
      // JVMSpec|           attribute_info attributes[attributes_count];
      // JVMSpec|   } /* end ClassFile 8?
      write_class_attributes();
    }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.