Overview of Class file Structure in Java?

Overview of Class file Structure in Java?

Overview of Class file Structure in Java?

Overview of Class file Structure in Java?

1. Magic Number

  • The first four bytes of the class file is the magic number. This is a predefined value used by JVM to identify a .class file is generated by the valid compiler or not.
  • The value should be “OXCAFEBABE”.
  • Note:- Whenever we are executing a java class if JVM unable to find the valid magic number then we will get runtime exception to say java.lang.classFormateError:- incompatible magic value.

2. Minor_version, major_version

  • Major and minor versions represent .class file version.
  • JVM will use these versions to identify which version of compiler generates the current .class file.
  • Note:- lower version compiler generated .class file can be run by higher version JVM but higher version compiler generated .class files can’t be run by lower version JVMs. If we are trying to run we will get RuntimeException saying  java.lang.unsupportedClassVersionError. 

Constant pool count

  • It represents no of the constant present in the constant pool

Constant pool array[]

  • It represents info. About constant present in the constant pool.

Access_flags

  • It provides info. About modifiers which are declared to the class.

this_class

  • It represents the fully qualified name of the class.

super_class 

  • It represents the fully qualified name of the immediate superclass of the current class.

Interface_count

  • It returns no of interface implemented by the current class.

Interface[]

  • It returns interface information implemented by the current class.

Fields_count

  • It represents no of fields present in the current class.

Fields[]

  • It represents fields of info. Present in the current class.

Method_count

  • It represents no of methods present in current class.

Method[]

  • It provides info. All method present in current class.

Attributes_count

  • It returns no of attribute present in current class.

Attributes[]

  • It provides info. About all attributes present in current class

Leave a Reply

Your email address will not be published. Required fields are marked *

*