()
| 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(); |
no test coverage detected