We use reflection for a user defined class Employee as:
Employee e = new Employee();
Class c = e.getClass();
As per my knowledge first JVM loads the bytecode of the class Employee, then it also create an object of Class.class for each loaded class (class Employee here). In the object of Class.class JVM stores meta information about the recently loaded class.
Meta information of a class are "name of methods", "name of fields" etc. Class of these types such as "Method", "Field" etc are defined in java.lang.reflect package.
I seen code of Class.java. I found methods in Class.class which are returning objects or array of objects of these types such as "Method", "Field" etc. But there is not a field in Class.class whose type is "Method", "Field" etc.
If my above statements are wrong, please make me correct. If above statements are not wrong then I have following doubts: 1). In which field of Class.class various information about a class get stored? 2). In which memory area of JVM object of Employee and object of Class.class get stored? 3). In which memory area of JVM bytecode of Employee and bytecode of Class.class get stored?
Aucun commentaire:
Enregistrer un commentaire