How JVM processes classes?
Question : Instances of the class "Class" represent classes and interfaces in a running Java application. does that mean whenever there is class or interface in a java application there will be an instance of class "Class" and if it is true then does it implies that our classes , interfaces ,object are all handled by JVM through their respective instances of class "Class".
Answer : java.lang.Class represent classes and interfaces in running java application, it means that there will be an instance of java.lang.Class class always. i.e. For every type a Java Virtual Machine loads, it creates an instance of class java.lang.Class to represent that type. And like all objects, ClassLoader objects and instances of Class class reside on the heap and data for loaded types reside in method area.
If JVM is loading a class and there is super class being refered or, instance of other class is being used inside it, then JVM uses Class object otherwise JVM uses object of its type to perform any custom operation on it.
|All times are GMT +5.5. The time now is 02:58.|