File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
src/test/java/org/scijava/util Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .scijava .util ;
2+
3+ import static org .junit .Assert .assertEquals ;
4+
5+ import java .lang .reflect .Field ;
6+ import java .lang .reflect .Type ;
7+ import java .util .List ;
8+
9+ import org .junit .Test ;
10+
11+ public class GenericTypesTest {
12+
13+ @ Test
14+ public void testArrayFields () throws NoSuchFieldException , SecurityException {
15+ Field rawField = Types .field (ClassWithFields .class , "rawListArray" );
16+ Field genericField = Types .field (ClassWithFields .class , "genericListArray" );
17+
18+ Type rawFieldType = Types .fieldType (rawField , ClassWithFields .class );
19+ Type genericFieldType = Types .fieldType (genericField , ClassWithFields .class );
20+
21+ assertEquals (new List [0 ].getClass (), rawFieldType );
22+ assertEquals (new List <?>[0 ].getClass (), genericFieldType );
23+
24+ assertEquals (List [].class , Types .raw (rawFieldType ));
25+ assertEquals (List [].class , Types .raw (genericFieldType ));
26+ }
27+
28+ @ SuppressWarnings ({ "rawtypes" , "unused" })
29+ private static class ClassWithFields {
30+ public List [] rawListArray ;
31+ public List <?>[] genericListArray ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments