/// <summary> /// Returns the size of the Runtime[In]Visible[Type]Annotations attributes containing the given /// annotations and all their <i>predecessors</i> (see /// <see cref="previousAnnotation" /> /// . Also adds the /// attribute names to the constant pool of the class (if not null). /// </summary> /// <param name="lastRuntimeVisibleAnnotation"> /// The last runtime visible annotation of a field, method or /// class. The previous ones can be accessed with the /// <see cref="previousAnnotation" /> /// field. May be /// <literal>null</literal> /// . /// </param> /// <param name="lastRuntimeInvisibleAnnotation"> /// The last runtime invisible annotation of this a field, /// method or class. The previous ones can be accessed with the /// <see cref="previousAnnotation" /> /// field. May be /// <literal>null</literal> /// . /// </param> /// <param name="lastRuntimeVisibleTypeAnnotation"> /// The last runtime visible type annotation of this a /// field, method or class. The previous ones can be accessed with the /// <see cref="previousAnnotation" /> /// field. May be /// <literal>null</literal> /// . /// </param> /// <param name="lastRuntimeInvisibleTypeAnnotation"> /// The last runtime invisible type annotation of a /// field, method or class field. The previous ones can be accessed with the /// <see cref="previousAnnotation" /> /// field. May be /// <literal>null</literal> /// . /// </param> /// <returns> /// the size in bytes of a Runtime[In]Visible[Type]Annotations attribute containing the /// given annotations and all their predecessors. This includes the size of the /// attribute_name_index and attribute_length fields. /// </returns> internal static int ComputeAnnotationsSize(AnnotationWriter lastRuntimeVisibleAnnotation , AnnotationWriter lastRuntimeInvisibleAnnotation, AnnotationWriter lastRuntimeVisibleTypeAnnotation , AnnotationWriter lastRuntimeInvisibleTypeAnnotation) { var size = 0; if (lastRuntimeVisibleAnnotation != null) { size += lastRuntimeVisibleAnnotation.ComputeAnnotationsSize(Constants.Runtime_Visible_Annotations ); } if (lastRuntimeInvisibleAnnotation != null) { size += lastRuntimeInvisibleAnnotation.ComputeAnnotationsSize(Constants.Runtime_Invisible_Annotations ); } if (lastRuntimeVisibleTypeAnnotation != null) { size += lastRuntimeVisibleTypeAnnotation.ComputeAnnotationsSize( Constants.Runtime_Visible_Type_Annotations ); } if (lastRuntimeInvisibleTypeAnnotation != null) { size += lastRuntimeInvisibleTypeAnnotation.ComputeAnnotationsSize( Constants.Runtime_Invisible_Type_Annotations ); } return(size); }
// Nothing to do. // ----------------------------------------------------------------------------------------------- // Utility methods // ----------------------------------------------------------------------------------------------- /// <summary> /// Returns the size of the record component JVMS structure generated by this /// RecordComponentWriter. /// </summary> /// <remarks> /// Returns the size of the record component JVMS structure generated by this /// RecordComponentWriter. Also adds the names of the attributes of this record component in the /// constant pool. /// </remarks> /// <returns>the size in bytes of the record_component_info of the Record attribute.</returns> internal int ComputeRecordComponentInfoSize() { // name_index, descriptor_index and attributes_count fields use 6 bytes. var size = 6; size += Attribute.ComputeAttributesSize(symbolTable, accessFlags & AccessFlags.Deprecated, signatureIndex); size += AnnotationWriter.ComputeAnnotationsSize(lastRuntimeVisibleAnnotation, lastRuntimeInvisibleAnnotation , lastRuntimeVisibleTypeAnnotation, lastRuntimeInvisibleTypeAnnotation); if (firstAttribute != null) { size += firstAttribute.ComputeAttributesSize(symbolTable); } return(size); }
// Nothing to do. // ----------------------------------------------------------------------------------------------- // Utility methods // ----------------------------------------------------------------------------------------------- /// <summary> /// Returns the size of the field_info JVMS structure generated by this FieldWriter. /// </summary> /// <remarks> /// Returns the size of the field_info JVMS structure generated by this FieldWriter. Also adds the /// names of the attributes of this field in the constant pool. /// </remarks> /// <returns>the size in bytes of the field_info JVMS structure.</returns> internal int ComputeFieldInfoSize() { // The access_flags, name_index, descriptor_index and attributes_count fields use 8 bytes. var size = 8; // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. if (constantValueIndex != 0) { // ConstantValue attributes always use 8 bytes. symbolTable.AddConstantUtf8(Constants.Constant_Value); size += 8; } size += Attribute.ComputeAttributesSize(symbolTable, accessFlags, signatureIndex); size += AnnotationWriter.ComputeAnnotationsSize(lastRuntimeVisibleAnnotation, lastRuntimeInvisibleAnnotation , lastRuntimeVisibleTypeAnnotation, lastRuntimeInvisibleTypeAnnotation); if (firstAttribute != null) { size += firstAttribute.ComputeAttributesSize(symbolTable); } return(size); }