1 import java.lang.reflect.Method;
2 import java.lang.reflect.Type;
3 import java.lang.reflect.TypeVariable;
7 import java.util.ArrayList;
8 import java.util.Arrays;
10 public class Reflection {
12 class GenericShort<TUVW,ABCD> {
15 class Generic<TUVW,ABCD,KLM,NOP> extends GenericShort<TUVW,ABCD> {
19 class SampleClass<VWXZ> {
20 private String sampleField;
22 public Generic<Integer,String,Double,Short> setSampleField(Class<VWXZ> clazz, List<String> listString, Map<Integer,String> mapString,
23 Generic<Integer,String,Double,Short> test,
24 String sampleField, int one, short two, double three, Object obj) {
25 this.sampleField = sampleField;
30 /*public String getSampleField() {
34 /*public void setSampleField(String sampleField) {
35 this.sampleField = sampleField;
38 public List<String> setSampleField(List<String> listString) {
43 public static void main(String[] args) {
45 /*Method[] methods = SampleClass.class.getMethods();
46 // Method[] methods = Class.class.getMethods();
48 for(Method meth : methods) {
49 if (meth.getName().equals("setSampleField")) {
53 Type[] parameters = method.getGenericParameterTypes();
54 //Type[] parameters = methods[0].getGenericParameterTypes();
55 for (int i = 0; i < parameters.length; i++) {
56 System.out.println(parameters[i]);
58 System.out.println();*/
59 Type superCls = Generic.class.getGenericSuperclass();
60 //Type superCls = String.class.getGenericSuperclass();
61 System.out.println(superCls);
62 /*Class[] parameterTypes = methods[0].getParameterTypes();
63 for(Class parameterType: parameterTypes){
64 System.out.println(parameterType.getName());
67 System.out.println();*/
68 /*TypeVariable[] typeParameters = Generic.class.getTypeParameters();
69 //TypeVariable[] typeParameters = SampleClass.class.getTypeParameters();
70 for(TypeVariable typeVar: typeParameters){
71 System.out.println(typeVar);
76 Type[] bounds = typeParameters[0].getBounds();
77 for (Type bound : bounds) {
78 System.out.println(bound);
81 Type returnType = methods[0].getGenericReturnType();
82 System.out.println(returnType);