void JvmtiClassFileReconstituter::write_attribute_name_index(const char* name) { TempNewSymbol sym = SymbolTable::probe(name, (int)strlen(name)); assert(sym != NULL, "attribute name symbol not found"); u2 attr_name_index = symbol_to_cpool_index(sym); assert(attr_name_index != 0, "attribute name symbol not in constant pool"); write_u2(attr_name_index); }
// Write SourceFile attribute // JVMSpec| SourceFile_attribute { // JVMSpec| u2 attribute_name_index; // JVMSpec| u4 attribute_length; // JVMSpec| u2 sourcefile_index; // JVMSpec| } void JvmtiClassFileReconstituter::write_source_file_attribute() { assert(ikh()->source_file_name() != NULL, "caller must check"); write_attribute_name_index("SourceFile"); write_u4(2); // always length 2 write_u2(symbol_to_cpool_index(ikh()->source_file_name())); }
// Write the class attributes portion of ClassFile structure // JVMSpec| u2 attributes_count; // JVMSpec| attribute_info attributes[attributes_count]; void JvmtiClassFileReconstituter::write_class_attributes() { u2 inner_classes_length = inner_classes_attribute_length(); Symbol* generic_signature = ikh()->generic_signature(); AnnotationArray* anno = ikh()->class_annotations(); AnnotationArray* type_anno = ikh()->class_type_annotations(); int attr_count = 0; if (generic_signature != NULL) { ++attr_count; } if (ikh()->source_file_name() != NULL) { ++attr_count; } if (ikh()->source_debug_extension() != NULL) { ++attr_count; } if (inner_classes_length > 0) { ++attr_count; } if (anno != NULL) { ++attr_count; // has RuntimeVisibleAnnotations attribute } if (type_anno != NULL) { ++attr_count; // has RuntimeVisibleTypeAnnotations attribute } if (cpool()->operands() != NULL) { ++attr_count; } write_u2(attr_count); if (generic_signature != NULL) { write_signature_attribute(symbol_to_cpool_index(generic_signature)); } if (ikh()->source_file_name() != NULL) { write_source_file_attribute(); } if (ikh()->source_debug_extension() != NULL) { write_source_debug_extension_attribute(); } if (inner_classes_length > 0) { write_inner_classes_attribute(inner_classes_length); } if (anno != NULL) { write_annotations_attribute("RuntimeVisibleAnnotations", anno); } if (type_anno != NULL) { write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); } if (cpool()->operands() != NULL) { write_bootstrapmethod_attribute(); } }
// Write the class attributes portion of ClassFile structure // JVMSpec| u2 attributes_count; // JVMSpec| attribute_info attributes[attributes_count]; void JvmtiClassFileReconstituter::write_class_attributes() { u2 inner_classes_length = inner_classes_attribute_length(); Symbol* generic_signature = ikh()->generic_signature(); typeArrayHandle anno(thread(), ikh()->class_annotations()); int attr_count = 0; if (generic_signature != NULL) { ++attr_count; } if (ikh()->source_file_name() != NULL) { ++attr_count; } if (ikh()->source_debug_extension() != NULL) { ++attr_count; } if (inner_classes_length > 0) { ++attr_count; } if (anno.not_null()) { ++attr_count; // has RuntimeVisibleAnnotations attribute } write_u2(attr_count); if (generic_signature != NULL) { write_signature_attribute(symbol_to_cpool_index(generic_signature)); } if (ikh()->source_file_name() != NULL) { write_source_file_attribute(); } if (ikh()->source_debug_extension() != NULL) { write_source_debug_extension_attribute(); } if (inner_classes_length > 0) { write_inner_classes_attribute(inner_classes_length); } if (anno.not_null()) { write_annotations_attribute("RuntimeVisibleAnnotations", anno); } }