MCPcopy Create free account
hub / github.com/ReadyTalk/avian / genericType

Method genericType

test/Reflection.java:70–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68 public static Hello<Hello<Reflection>>.World<Hello<String>> pinky;
69
70 private static void genericType() throws Exception {
71 Field field = Reflection.class.getDeclaredField("egads");
72 expect(field.getGenericType() == Integer.TYPE);
73
74 field = Reflection.class.getField("pinky");
75 expect("Reflection$Hello$World".equals(field.getType().getName()));
76 expect(field.getGenericType() instanceof ParameterizedType);
77 ParameterizedType type = (ParameterizedType) field.getGenericType();
78
79 expect(type.getRawType() instanceof Class);
80 Class<?> clazz = (Class<?>) type.getRawType();
81 expect("Reflection$Hello$World".equals(clazz.getName()));
82
83 expect(type.getOwnerType() instanceof ParameterizedType);
84 ParameterizedType owner = (ParameterizedType) type.getOwnerType();
85 clazz = (Class<?>) owner.getRawType();
86 expect(clazz == Hello.class);
87
88 Type[] args = type.getActualTypeArguments();
89 expect(1 == args.length);
90 expect(args[0] instanceof ParameterizedType);
91
92 ParameterizedType arg = (ParameterizedType) args[0];
93 expect(arg.getRawType() instanceof Class);
94 clazz = (Class<?>) arg.getRawType();
95 expect("Reflection$Hello".equals(clazz.getName()));
96
97 args = arg.getActualTypeArguments();
98 expect(1 == args.length);
99 expect(args[0] == String.class);
100 }
101
102 public static void throwOOME() {
103 throw new OutOfMemoryError();

Callers 1

mainMethod · 0.95

Calls 10

expectMethod · 0.95
getGenericTypeMethod · 0.95
getTypeMethod · 0.95
getRawTypeMethod · 0.95
getOwnerTypeMethod · 0.95
getDeclaredFieldMethod · 0.80
getFieldMethod · 0.80
equalsMethod · 0.65
getNameMethod · 0.65

Tested by

no test coverage detected