File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
main/java/net/bytebuddy/pool
test/java/net/bytebuddy/pool Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -587,9 +587,13 @@ public Resolution describe(String name) {
587
587
}
588
588
if (arity > 0 ) {
589
589
String primitiveName = PRIMITIVE_DESCRIPTORS .get (name );
590
- name = primitiveName == null
591
- ? name .substring (1 , name .length () - 1 )
592
- : primitiveName ;
590
+ if (primitiveName != null ) {
591
+ name = primitiveName ;
592
+ } else if (name .startsWith ("L" ) && name .endsWith (";" )) {
593
+ name = name .substring (1 , name .length () - 1 );
594
+ } else {
595
+ throw new IllegalArgumentException ("Not a legitimate array type descriptor: " + name );
596
+ }
593
597
}
594
598
TypeDescription typeDescription = PRIMITIVE_TYPES .get (name );
595
599
Resolution resolution = typeDescription == null
Original file line number Diff line number Diff line change @@ -33,6 +33,21 @@ public void testNameCannotContainSlash() throws Exception {
33
33
typePool .describe ("/" );
34
34
}
35
35
36
+ @ Test (expected = IllegalArgumentException .class )
37
+ public void testArrayNameMustBeDescriptorUnlessPrimitive () throws Exception {
38
+ typePool .describe ("[abc" );
39
+ }
40
+
41
+ @ Test
42
+ public void testPrimitiveType () throws Exception {
43
+ assertThat (typePool .describe ("int" ).resolve ().represents (int .class ), is (true ));
44
+ }
45
+
46
+ @ Test
47
+ public void testPrimitiveTypeArray () throws Exception {
48
+ assertThat (typePool .describe ("[I" ).resolve ().represents (int [].class ), is (true ));
49
+ }
50
+
36
51
@ Test (expected = IllegalStateException .class )
37
52
public void testCannotFindClass () throws Exception {
38
53
TypePool .Resolution resolution = typePool .describe ("foo" );
You can’t perform that action at this time.
0 commit comments