I recently read about JVM specification according to Artima Inside the JVM 2-nd Ed. One of the chapters mentioned type storing in the Java runtime and it said that:
An instance of class
java.lang.Classis created by the Java virtual machine for every type it loads. The virtual machine must in some way associate a reference to the Class instance for a type with the type’s data in the method area.
I am a little bit confused, as I always thought that Class files where places on the method area that contained type information. Is there some other place that Java stores type info?
Yes, as it says
an instance of java.lang.Classis created. This means an Object representing the class file is placed on the heap, as well as theClassfile in the method area.This is the
Classobject that is returned when you callgetClass()on an Object.