What is the Class file specification?

The focus of this article

We said earlier that the JVM is the specification implementation of the class, so what exactly is the class specification? This article introduces in detail

class file

First of all, we need to know that when javac compiles the file into a class file, the class file at this time is actually binary (either 0 or 1), but if we convert it into hexadecimal, its form will be clearer, as follows Show.

That is to say, the class file is the content above. These contents are not written casually. The structure of the class is strictly restricted. Which byte represents what meaning, what is the length, and what is the order, all are not allowed to be changed. Let's briefly introduce the meaning of each part in the class file?

meaning

The class file contains the following:

  • Magic Number——Magic Number: Determine whether this file is a Class file that can be accepted by the virtual machine (cafe babe)
  • Minor Version - the version number of the class file (0000)
  • Major Version - the version number of the class file (0034)
  • constant_pool_count——The constant pool capacity count value. The constant pool can be understood as the resource warehouse (0010) in the Class file. There are constant_pool_count-1 constants. For this example, it is 16-1=15 constants.
  • constant_pool - the specific content of the constant pool, the length is constant_pool_c

Guess you like

Origin blog.csdn.net/huanfeng_AI/article/details/131970567