mercredi 24 avril 2019

how to get local variables of a method from another class

I have two classes A and B A class contains a method which has some of the local variables. now I want to fetch their name and data type in the B class. can you please help me with this.

I researched about java reflection. but I found that I can not achieve this by using reflection, as local variables are stored in stack at the runtime. And reflection can only fetch instance or class variables.

for example,

class A{
     method1(){
         variable1;
     }
}
class B{
      method 2(){
           fetch variable1;
       }
}

I want the data type of variable1 as a result.





Aucun commentaire:

Enregistrer un commentaire