Returns the Type values corresponding to the argument types of the given method descriptor. @param methodDescriptor a method descriptor. @return the Type values corresponding to the argument types of the given method descriptor.
(final String methodDescriptor)
| 273 | * descriptor. |
| 274 | */ |
| 275 | public static Type[] getArgumentTypes(final String methodDescriptor) { |
| 276 | // First step: compute the number of argument types in methodDescriptor. |
| 277 | int numArgumentTypes = 0; |
| 278 | // Skip the first character, which is always a '('. |
| 279 | int currentOffset = 1; |
| 280 | // Parse the argument types, one at a each loop iteration. |
| 281 | while (methodDescriptor.charAt(currentOffset) != ')') { |
| 282 | while (methodDescriptor.charAt(currentOffset) == '[') { |
| 283 | currentOffset++; |
| 284 | } |
| 285 | if (methodDescriptor.charAt(currentOffset++) == 'L') { |
| 286 | while (methodDescriptor.charAt(currentOffset++) != ';') { |
| 287 | // Skip the argument descriptor content. |
| 288 | } |
| 289 | } |
| 290 | ++numArgumentTypes; |
| 291 | } |
| 292 | |
| 293 | // Second step: create a Type instance for each argument type. |
| 294 | Type[] argumentTypes = new Type[numArgumentTypes]; |
| 295 | // Skip the first character, which is always a '('. |
| 296 | currentOffset = 1; |
| 297 | // Parse and create the argument types, one at each loop iteration. |
| 298 | int currentArgumentTypeIndex = 0; |
| 299 | while (methodDescriptor.charAt(currentOffset) != ')') { |
| 300 | final int currentArgumentTypeOffset = currentOffset; |
| 301 | while (methodDescriptor.charAt(currentOffset) == '[') { |
| 302 | currentOffset++; |
| 303 | } |
| 304 | if (methodDescriptor.charAt(currentOffset++) == 'L') { |
| 305 | while (methodDescriptor.charAt(currentOffset++) != ';') { |
| 306 | // Skip the argument descriptor content. |
| 307 | } |
| 308 | } |
| 309 | argumentTypes[currentArgumentTypeIndex++] = |
| 310 | getType(methodDescriptor, currentArgumentTypeOffset, currentOffset); |
| 311 | } |
| 312 | return argumentTypes; |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * Returns the {@link Type} values corresponding to the argument types of the given method. |
no test coverage detected