Skip to content

Commit

Permalink
Fix a couple of bugs in parsing array type arguments in type signatur…
Browse files Browse the repository at this point in the history
…es (#1477)

We forgot to increment a variable, and we didn't handle all the
primitive types.
  • Loading branch information
msridhar authored Dec 24, 2024
1 parent aa5280a commit ac47859
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,14 @@ static String[] parseForTypeSignatures(String typeSigs) throws IllegalArgumentEx
switch (typeSigs.charAt(i)) {
case TypeReference.BooleanTypeCode:
case TypeReference.ByteTypeCode:
case TypeReference.ShortTypeCode:
case TypeReference.IntTypeCode:
case TypeReference.LongTypeCode:
case TypeReference.FloatTypeCode:
case TypeReference.DoubleTypeCode:
case TypeReference.CharTypeCode:
sigs.add(typeSigs.substring(i - 1, i + 1));
i++;
break;
case 'T':
case TypeReference.ClassTypeCode:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,21 @@ void getArguments() {
void getVoidReturn() {
assertThat(MethodTypeSignature.make("(I)V").getReturnType(), is(TypeSignature.make("V")));
}

@Test
void arrayArgumentType() {
assertThat(
MethodTypeSignature.make("([I)V").getArguments(),
arrayContaining(is(TypeSignature.make("[I"))));
assertThat(
MethodTypeSignature.make("([J[DB)V").getArguments(),
arrayContaining(
is(TypeSignature.make("[J")),
is(TypeSignature.make("[D")),
is(TypeSignature.make("B"))));
assertThat(
MethodTypeSignature.make("([Ljava/lang/String;B)V").getArguments(),
arrayContaining(
is(TypeSignature.make("[Ljava/lang/String;")), is(TypeSignature.make("B"))));
}
}

0 comments on commit ac47859

Please sign in to comment.