Get Generic Super class : Generic « Reflection « Java






Get Generic Super class

     

import java.lang.reflect.Type;
import java.util.ArrayList;

import javax.xml.transform.sax.SAXSource;


public class GetGenericSuperclass {

    public static void main(String[] args) {
        try {
            Class< ? super SAXSource> ts = SAXSource.class.getSuperclass();
            System.out.println(ts);        
        } catch (SecurityException e) {
            e.printStackTrace();
        }  
        try {
            Type t = ArrayList.class.getGenericSuperclass();
            System.out.println(t);        
        } catch (SecurityException e) {
            e.printStackTrace();
        }          
        try {
            Class[] is = SAXSource.class.getInterfaces();
            for(int i=0;i<is.length;i++){
                System.out.println(is[i]);        
            }       
        } catch (SecurityException e) {
            e.printStackTrace();
        }           
    }
}

   
    
    
    
    
  








Related examples in the same category

1.Generic Class reflection
2.Get field type and generic type by field name
3.get Return Type and get Generic Return Type
4.get Exception Types and get Generic Exception Types
5.get Parameter Types and get Generic ParameterTypes
6.Generic method reflection
7.get Generic Parameter Types from Constructor
8.Class Declaration Spy
9.All information about a class
10.Get all implemented generic interfaces
11.If right-hand side type may be assigned to the left-hand side type following the Java generics rules.
12.Get all interface and object classes that are generalizations of the provided class
13.A wrapper around reflection to resolve generics.
14.Get Generic Type
15.Get Parameterized Type
16.Locates generic declaration by index on a class.