Puts the content of the method_info JVMS structure generated by this MethodWriter into the given ByteVector. @param output where the method_info structure must be put.
(final ByteVector output)
| 2178 | * @param output where the method_info structure must be put. |
| 2179 | */ |
| 2180 | void putMethodInfo(final ByteVector output) { |
| 2181 | boolean useSyntheticAttribute = symbolTable.getMajorVersion() < Opcodes.V1_5; |
| 2182 | int mask = useSyntheticAttribute ? Opcodes.ACC_SYNTHETIC : 0; |
| 2183 | output.putShort(accessFlags & ~mask).putShort(nameIndex).putShort(descriptorIndex); |
| 2184 | // If this method_info must be copied from an existing one, copy it now and return early. |
| 2185 | if (sourceOffset != 0) { |
| 2186 | output.putByteArray(symbolTable.getSource().b, sourceOffset, sourceLength); |
| 2187 | return; |
| 2188 | } |
| 2189 | // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. |
| 2190 | int attributeCount = 0; |
| 2191 | if (code.length > 0) { |
| 2192 | ++attributeCount; |
| 2193 | } |
| 2194 | if (numberOfExceptions > 0) { |
| 2195 | ++attributeCount; |
| 2196 | } |
| 2197 | if ((accessFlags & Opcodes.ACC_SYNTHETIC) != 0 && useSyntheticAttribute) { |
| 2198 | ++attributeCount; |
| 2199 | } |
| 2200 | if (signatureIndex != 0) { |
| 2201 | ++attributeCount; |
| 2202 | } |
| 2203 | if ((accessFlags & Opcodes.ACC_DEPRECATED) != 0) { |
| 2204 | ++attributeCount; |
| 2205 | } |
| 2206 | if (lastRuntimeVisibleAnnotation != null) { |
| 2207 | ++attributeCount; |
| 2208 | } |
| 2209 | if (lastRuntimeInvisibleAnnotation != null) { |
| 2210 | ++attributeCount; |
| 2211 | } |
| 2212 | if (lastRuntimeVisibleParameterAnnotations != null) { |
| 2213 | ++attributeCount; |
| 2214 | } |
| 2215 | if (lastRuntimeInvisibleParameterAnnotations != null) { |
| 2216 | ++attributeCount; |
| 2217 | } |
| 2218 | if (lastRuntimeVisibleTypeAnnotation != null) { |
| 2219 | ++attributeCount; |
| 2220 | } |
| 2221 | if (lastRuntimeInvisibleTypeAnnotation != null) { |
| 2222 | ++attributeCount; |
| 2223 | } |
| 2224 | if (defaultValue != null) { |
| 2225 | ++attributeCount; |
| 2226 | } |
| 2227 | if (parameters != null) { |
| 2228 | ++attributeCount; |
| 2229 | } |
| 2230 | if (firstAttribute != null) { |
| 2231 | attributeCount += firstAttribute.getAttributeCount(); |
| 2232 | } |
| 2233 | // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. |
| 2234 | output.putShort(attributeCount); |
| 2235 | if (code.length > 0) { |
| 2236 | // 2, 2, 4 and 2 bytes respectively for max_stack, max_locals, code_length and |
| 2237 | // attributes_count, plus the bytecode and the exception table. |
no test coverage detected