Here you can find the source of getGenericType(Field field)
public static Type getGenericType(Field field)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Robert "Unlogic" Olofsson (unlogic@unlogic.se). * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0-standalone.html ******************************************************************************/ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.WildcardType; public class Main { public static Type getGenericType(Field field) { Type type = ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; if (type instanceof WildcardType) { //TODO do a little bit more research on this part... return ((WildcardType) type).getUpperBounds()[0]; } else {// ww w. j a v a2s .c o m return type; } } public static Object getGenericType(Method method) { return method.getGenericParameterTypes()[0]; } }