简体   繁体   中英

Identify Object Type(i.e. Class)

I am trying to identify the Type of an Object from the class definition :

For example,

class MyCustomClass{

    Class1 obj1 = new Class1();

    public void method(HttpServletRequest request){
        String s1="Hello";
        request.setAttribute(s1);
        request.setAttribute(obj1);     

    }       



    public void method2(HttpServletRequest request){
        Class2 obj2 = new Class2();
        request.setAttribute(obj1);     
        request.setAttribute(obj2);
    }

    .
    .
    .

}

In this I need to identify the Type of all those Object which are getting set in request.setAttribute() whether it is primary on not along with scanning the whole Java File. I tried reading Java File using FileReader but in that case I am not able to fetch the Object Type. Any solution to this will be of great help.

Thanks

Reference Post(Asking Further) : Read Complete Java Class Implementation

I guess this is not possible as mentioned by @Joakim and @Luftbaum. The way I have done that is by multiple scan.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM