@return the offset in #b of the first ClassFile's 'attributes' array field entry.
()
| 3182 | |
| 3183 | /** @return the offset in {@link #b} of the first ClassFile's 'attributes' array field entry. */ |
| 3184 | final int getFirstAttributeOffset() { |
| 3185 | // Skip the access_flags, this_class, super_class, and interfaces_count fields (using 2 bytes |
| 3186 | // each), as well as the interfaces array field (2 bytes per interface). |
| 3187 | int currentOffset = header + 8 + readUnsignedShort(header + 6) * 2; |
| 3188 | |
| 3189 | // Read the fields_count field. |
| 3190 | int fieldsCount = readUnsignedShort(currentOffset); |
| 3191 | currentOffset += 2; |
| 3192 | // Skip the 'fields' array field. |
| 3193 | while (fieldsCount-- > 0) { |
| 3194 | // Invariant: currentOffset is the offset of a field_info structure. |
| 3195 | // Skip the access_flags, name_index and descriptor_index fields (2 bytes each), and read the |
| 3196 | // attributes_count field. |
| 3197 | int attributesCount = readUnsignedShort(currentOffset + 6); |
| 3198 | currentOffset += 8; |
| 3199 | // Skip the 'attributes' array field. |
| 3200 | while (attributesCount-- > 0) { |
| 3201 | // Invariant: currentOffset is the offset of an attribute_info structure. |
| 3202 | // Read the attribute_length field (2 bytes after the start of the attribute_info) and skip |
| 3203 | // this many bytes, plus 6 for the attribute_name_index and attribute_length fields |
| 3204 | // (yielding the total size of the attribute_info structure). |
| 3205 | currentOffset += 6 + readInt(currentOffset + 2); |
| 3206 | } |
| 3207 | } |
| 3208 | |
| 3209 | // Skip the methods_count and 'methods' fields, using the same method as above. |
| 3210 | int methodsCount = readUnsignedShort(currentOffset); |
| 3211 | currentOffset += 2; |
| 3212 | while (methodsCount-- > 0) { |
| 3213 | int attributesCount = readUnsignedShort(currentOffset + 6); |
| 3214 | currentOffset += 8; |
| 3215 | while (attributesCount-- > 0) { |
| 3216 | currentOffset += 6 + readInt(currentOffset + 2); |
| 3217 | } |
| 3218 | } |
| 3219 | |
| 3220 | // Skip the ClassFile's attributes_count field. |
| 3221 | return currentOffset + 2; |
| 3222 | } |
| 3223 | |
| 3224 | /** |
| 3225 | * Reads a non standard JVMS 'attribute' structure in {@link #b}. |
no test coverage detected