Commit bb8eb912 authored by Eric Bruneton's avatar Eric Bruneton
Browse files

Merge branch 'justinblank/asm-provide_descriptor_in_type_exception'

parents 7f3b2d0e 4a30c739
......@@ -440,7 +440,7 @@ public final class Type {
case '(':
return new Type(METHOD, descriptorBuffer, descriptorBegin, descriptorEnd);
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException("Invalid descriptor: " + descriptorBuffer);
}
}
......
......@@ -126,7 +126,8 @@ class TypeTest implements Opcodes {
void testGetTypeFromDescriptor_invalid() {
Executable getType = () -> Type.getType("-");
assertThrows(IllegalArgumentException.class, getType);
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, getType);
assertEquals("Invalid descriptor: -", exception.getMessage());
}
@ParameterizedTest
......@@ -187,6 +188,15 @@ class TypeTest implements Opcodes {
Duration.ofMillis(100), () -> assertThrows(RuntimeException.class, getArgumentTypes));
}
@Test
void testGetArgumentTypesInvalidArgumentDescriptor() {
Executable getArgumentTypes = () -> Type.getArgumentTypes("(Ljava/lang/String;-)V");
IllegalArgumentException exception =
assertThrows(IllegalArgumentException.class, getArgumentTypes);
assertEquals("Invalid descriptor: (Ljava/lang/String;-)V", exception.getMessage());
}
@Test
void testGetReturnTypeFromDescriptor() {
assertEquals(Type.INT_TYPE, Type.getReturnType("()I"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment