I searched a lot but I couldn't find the answer for where do objects of java.lang.Class
class reside - is it the Heap or Metaspace/PermGen. My own understanding is that objects of java.lang.Class
represents the class metadata so they should reside on Metaspace (or PermGen for pre-Java8).
Could someone please confirm, and I need some official documentation which clearly mentions the same.
CodePudding user response:
IMHO, objects of java.lang.Class
class can't be considered as class metadata. Class metadata is nothing but JVM's internal representation of Java classes - basically when JVM loads .class
file then it doesn't store all the bytecode present in that .class
file, but creates an internal data structure that holds everything which is needed from that .class
file and that gets stored in Metaspace or PermGen.
So, based on my knowledge I would say objects of java.lang.Class
class will reside on heap and class metadata of java.lang.Class
class will reside on Metaspace or PermGen. However, I can't give any official doc about first part of my statement, and offical doc for second part can be read over