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. @return the size in bytes of the field_info JVMS structure.
()
| 200 | * @return the size in bytes of the field_info JVMS structure. |
| 201 | */ |
| 202 | int computeFieldInfoSize() { |
| 203 | // The access_flags, name_index, descriptor_index and attributes_count fields use 8 bytes. |
| 204 | int size = 8; |
| 205 | // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. |
| 206 | if (constantValueIndex != 0) { |
| 207 | // ConstantValue attributes always use 8 bytes. |
| 208 | symbolTable.addConstantUtf8(Constants.CONSTANT_VALUE); |
| 209 | size += 8; |
| 210 | } |
| 211 | // Before Java 1.5, synthetic fields are represented with a Synthetic attribute. |
| 212 | if ((accessFlags & Opcodes.ACC_SYNTHETIC) != 0 |
| 213 | && symbolTable.getMajorVersion() < Opcodes.V1_5) { |
| 214 | // Synthetic attributes always use 6 bytes. |
| 215 | symbolTable.addConstantUtf8(Constants.SYNTHETIC); |
| 216 | size += 6; |
| 217 | } |
| 218 | if (signatureIndex != 0) { |
| 219 | // Signature attributes always use 8 bytes. |
| 220 | symbolTable.addConstantUtf8(Constants.SIGNATURE); |
| 221 | size += 8; |
| 222 | } |
| 223 | // ACC_DEPRECATED is ASM specific, the ClassFile format uses a Deprecated attribute instead. |
| 224 | if ((accessFlags & Opcodes.ACC_DEPRECATED) != 0) { |
| 225 | // Deprecated attributes always use 6 bytes. |
| 226 | symbolTable.addConstantUtf8(Constants.DEPRECATED); |
| 227 | size += 6; |
| 228 | } |
| 229 | if (lastRuntimeVisibleAnnotation != null) { |
| 230 | size += |
| 231 | lastRuntimeVisibleAnnotation.computeAnnotationsSize( |
| 232 | Constants.RUNTIME_VISIBLE_ANNOTATIONS); |
| 233 | } |
| 234 | if (lastRuntimeInvisibleAnnotation != null) { |
| 235 | size += |
| 236 | lastRuntimeInvisibleAnnotation.computeAnnotationsSize( |
| 237 | Constants.RUNTIME_INVISIBLE_ANNOTATIONS); |
| 238 | } |
| 239 | if (lastRuntimeVisibleTypeAnnotation != null) { |
| 240 | size += |
| 241 | lastRuntimeVisibleTypeAnnotation.computeAnnotationsSize( |
| 242 | Constants.RUNTIME_VISIBLE_TYPE_ANNOTATIONS); |
| 243 | } |
| 244 | if (lastRuntimeInvisibleTypeAnnotation != null) { |
| 245 | size += |
| 246 | lastRuntimeInvisibleTypeAnnotation.computeAnnotationsSize( |
| 247 | Constants.RUNTIME_INVISIBLE_TYPE_ANNOTATIONS); |
| 248 | } |
| 249 | if (firstAttribute != null) { |
| 250 | size += firstAttribute.computeAttributesSize(symbolTable); |
| 251 | } |
| 252 | return size; |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Puts the content of the field_info JVMS structure generated by this FieldWriter into the given |
no test coverage detected