Bober02
Bober02

Reputation: 15331

java virtual machine: type information

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.Class is 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?

Upvotes: 0

Views: 255

Answers (1)

Jivings
Jivings

Reputation: 23250

Yes, as it says an instance of java.lang.Class is created. This means an Object representing the class file is placed on the heap, as well as the Class file in the method area.

This is the Class object that is returned when you call getClass() on an Object.

Upvotes: 1

Related Questions