本文整理汇总了C++中methodHandle::localvariable_table_start方法的典型用法代码示例。如果您正苦于以下问题:C++ methodHandle::localvariable_table_start方法的具体用法?C++ methodHandle::localvariable_table_start怎么用?C++ methodHandle::localvariable_table_start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类methodHandle
的用法示例。
在下文中一共展示了methodHandle::localvariable_table_start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_local_variable_table_attribute
// Write LocalVariableTable attribute
// JVMSpec| LocalVariableTable_attribute {
// JVMSpec| u2 attribute_name_index;
// JVMSpec| u4 attribute_length;
// JVMSpec| u2 local_variable_table_length;
// JVMSpec| { u2 start_pc;
// JVMSpec| u2 length;
// JVMSpec| u2 name_index;
// JVMSpec| u2 descriptor_index;
// JVMSpec| u2 index;
// JVMSpec| } local_variable_table[local_variable_table_length];
// JVMSpec| }
void JvmtiClassFileReconstituter::write_local_variable_table_attribute(methodHandle method, u2 num_entries) {
write_attribute_name_index("LocalVariableTable");
write_u4(2 + num_entries * (2 + 2 + 2 + 2 + 2));
write_u2(num_entries);
assert(method->localvariable_table_length() == num_entries, "just checking");
LocalVariableTableElement *elem = method->localvariable_table_start();
for (int j=0; j<method->localvariable_table_length(); j++) {
write_u2(elem->start_bci);
write_u2(elem->length);
write_u2(elem->name_cp_index);
write_u2(elem->descriptor_cp_index);
write_u2(elem->slot);
elem++;
}
}
示例2: write_local_variable_type_table_attribute
// Write LocalVariableTypeTable attribute
// JVMSpec| LocalVariableTypeTable_attribute {
// JVMSpec| u2 attribute_name_index;
// JVMSpec| u4 attribute_length;
// JVMSpec| u2 local_variable_type_table_length;
// JVMSpec| { u2 start_pc;
// JVMSpec| u2 length;
// JVMSpec| u2 name_index;
// JVMSpec| u2 signature_index;
// JVMSpec| u2 index;
// JVMSpec| } local_variable_type_table[local_variable_type_table_length];
// JVMSpec| }
void JvmtiClassFileReconstituter::write_local_variable_type_table_attribute(methodHandle method, u2 num_entries) {
write_attribute_name_index("LocalVariableTypeTable");
write_u4(2 + num_entries * (2 + 2 + 2 + 2 + 2));
write_u2(num_entries);
LocalVariableTableElement *elem = method->localvariable_table_start();
for (int j=0; j<method->localvariable_table_length(); j++) {
if (elem->signature_cp_index > 0) {
// Local variable has a generic signature - write LVTT attribute entry
write_u2(elem->start_bci);
write_u2(elem->length);
write_u2(elem->name_cp_index);
write_u2(elem->signature_cp_index);
write_u2(elem->slot);
num_entries--;
}
elem++;
}
assert(num_entries == 0, "just checking");
}
示例3: write_code_attribute
// Write Code attribute
// JVMSpec| Code_attribute {
// JVMSpec| u2 attribute_name_index;
// JVMSpec| u4 attribute_length;
// JVMSpec| u2 max_stack;
// JVMSpec| u2 max_locals;
// JVMSpec| u4 code_length;
// JVMSpec| u1 code[code_length];
// JVMSpec| u2 exception_table_length;
// JVMSpec| { u2 start_pc;
// JVMSpec| u2 end_pc;
// JVMSpec| u2 handler_pc;
// JVMSpec| u2 catch_type;
// JVMSpec| } exception_table[exception_table_length];
// JVMSpec| u2 attributes_count;
// JVMSpec| attribute_info attributes[attributes_count];
// JVMSpec| }
void JvmtiClassFileReconstituter::write_code_attribute(methodHandle method) {
ConstMethod* const_method = method->constMethod();
u2 line_num_cnt = 0;
int stackmap_len = 0;
int local_variable_table_length = 0;
int local_variable_type_table_length = 0;
// compute number and length of attributes
int attr_count = 0;
int attr_size = 0;
if (const_method->has_linenumber_table()) {
line_num_cnt = line_number_table_entries(method);
if (line_num_cnt != 0) {
++attr_count;
// Compute the complete size of the line number table attribute:
// LineNumberTable_attribute {
// u2 attribute_name_index;
// u4 attribute_length;
// u2 line_number_table_length;
// { u2 start_pc;
// u2 line_number;
// } line_number_table[line_number_table_length];
// }
attr_size += 2 + 4 + 2 + line_num_cnt * (2 + 2);
}
}
if (method->has_stackmap_table()) {
stackmap_len = method->stackmap_data()->length();
if (stackmap_len != 0) {
++attr_count;
// Compute the size of the stack map table attribute (VM stores raw):
// StackMapTable_attribute {
// u2 attribute_name_index;
// u4 attribute_length;
// u2 number_of_entries;
// stack_map_frame_entries[number_of_entries];
// }
attr_size += 2 + 4 + stackmap_len;
}
}
if (method->has_localvariable_table()) {
local_variable_table_length = method->localvariable_table_length();
if (local_variable_table_length != 0) {
++attr_count;
// Compute the size of the local variable table attribute (VM stores raw):
// LocalVariableTable_attribute {
// u2 attribute_name_index;
// u4 attribute_length;
// u2 local_variable_table_length;
// {
// u2 start_pc;
// u2 length;
// u2 name_index;
// u2 descriptor_index;
// u2 index;
// }
attr_size += 2 + 4 + 2 + local_variable_table_length * (2 + 2 + 2 + 2 + 2);
// Local variables with generic signatures must have LVTT entries
LocalVariableTableElement *elem = method->localvariable_table_start();
for (int idx = 0; idx < local_variable_table_length; idx++) {
if (elem[idx].signature_cp_index != 0) {
local_variable_type_table_length++;
}
}
if (local_variable_type_table_length != 0) {
++attr_count;
// Compute the size of the local variable type table attribute (VM stores raw):
// LocalVariableTypeTable_attribute {
// u2 attribute_name_index;
// u4 attribute_length;
// u2 local_variable_type_table_length;
// {
// u2 start_pc;
// u2 length;
// u2 name_index;
// u2 signature_index;
// u2 index;
// }
attr_size += 2 + 4 + 2 + local_variable_type_table_length * (2 + 2 + 2 + 2 + 2);
}
}
//.........这里部分代码省略.........