Have a Question?

If you have any question you can ask below or enter what you are looking for!

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

  • In Java .class file structure contains 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.
  • Overview of Class file Structure in Java?

Constant pool count

  • In Java .class file structure constant pool count represents no of the constant present in the constant pool

Constant pool array[]

  • In Java .class file structure constant pool aarays represents info. About constant present in the constant pool.

Access_flags

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

this_class

  • Java .class file structure 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

  • In Java .class file structure interface_count 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[]

What is Hashtable in Java with Example?
What is a Collection class in Java?

Leave a Reply

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