summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Bruneton <ebruneton@free.fr>2022-04-03 08:52:32 +0200
committerEric Bruneton <ebruneton@free.fr>2022-04-03 08:52:32 +0200
commitbb8eb9129e07a7dc16f1be6cbd46c8eb6744997f (patch)
tree16af404487059c56d5f3404a4d57f3ebfa821462
parent7f3b2d0e1cdad6c2083fa504865db31416027824 (diff)
parent4a30c739a7c1d8feee5e31fb064aa0ab0a44a65e (diff)
downloadow2-asm-bb8eb9129e07a7dc16f1be6cbd46c8eb6744997f.tar.gz
Merge branch 'justinblank/asm-provide_descriptor_in_type_exception'
-rw-r--r--asm/src/main/java/org/objectweb/asm/Type.java2
-rw-r--r--asm/src/test/java/org/objectweb/asm/TypeTest.java12
2 files changed, 12 insertions, 2 deletions
diff --git a/asm/src/main/java/org/objectweb/asm/Type.java b/asm/src/main/java/org/objectweb/asm/Type.java
index 01c68b46..85a43547 100644
--- a/asm/src/main/java/org/objectweb/asm/Type.java
+++ b/asm/src/main/java/org/objectweb/asm/Type.java
@@ -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);
}
}
diff --git a/asm/src/test/java/org/objectweb/asm/TypeTest.java b/asm/src/test/java/org/objectweb/asm/TypeTest.java
index fbeeced6..bf52bcd2 100644
--- a/asm/src/test/java/org/objectweb/asm/TypeTest.java
+++ b/asm/src/test/java/org/objectweb/asm/TypeTest.java
@@ -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
@@ -188,6 +189,15 @@ class TypeTest implements Opcodes {
}
@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"));
assertEquals(Type.INT_TYPE, Type.getReturnType("(Lpkg/classMethod();)I"));