Java class file structure and Classreader class interpretation of Javac

Source: Internet
Author: User

Let's take a look at Classfile, which reads as follows:

A JVM class file.

Generic Java Classfiles has one additional attribute for classes,
methods and fields:

"Signature" (U4 Attr-length, U2 signature-index)


a signature gives the full Java type of a method or field. when
used as a class attribute, it indicates type parameters, followed
by Supertype, followed by all interfaces.

methodorfieldsignature:: = Type
classsignature:: = [Typeparams] supertype {InterfaceType}

The type syntax in signatures is extended as follows:

type:: = ... | classtype | methodtype | Typevar
ClassType:: = classsig {'. ' Classsig}
classig:: = ' L ' name [Typeargs] '; '
methodtype:: = [Typeparams] ' (' {type} ') ' type '
Typevar:: = ' T ' name '; '
typeargs:: = ' < ' type {type} ' > '
typeparams:: = ' < ' typeparam {typeparam} ' > '
typeparam:: = Name ': ' Type

This class defines constants used in class files as well
As routines to convert between internal "." and external "
separators in class names.

Some constant definitions (strictly defined by the virtual machine) are as follows:

Public final static int java_magic = 0xCAFEBABE;    Magic number//constant pool 14 constant entries public final static int constant_utf8 = 1;    Public final static int constant_unicode = 2;    Public final static int constant_integer = 3;    Public final static int constant_float = 4;    Public final static int constant_long = 5;    Public final static int constant_double = 6;    Public final static int constant_class = 7;    Public final static int constant_string = 8;    Public final static int constant_fieldref = 9;    Public final static int constant_methodref = 10;    Public final static int constant_interfacemethodref = 11;    Public final static int constant_nameandtype = 12;    Public final static int constant_methodhandle = 15;    Public final static int constant_methodtype = 16;    Public final static int constant_invokedynamic = 18; Public final static int max_parameters = 0xFF; Max_parameters public final static int max_dimensions = 0xFF; Max_dimensions public final static int MAX_code = 0xFFFF; Max_code public final static int max_locals = 0xFFFF; Max_locals public final static int max_stack = 0xFFFF; Max_stack

The comments for the Classreader class are as follows:

This class provides operations to read a classfile into an internal
representation. The internal representation is anchored in (based on) a
Classsymbol which contains in its scope symbol representations
For all and definitions in the classfile.

top-level Classes themselves appear as members of the scopes of Packagesymbols.

Error diagnoses
Buffer Access
Constant Pool Access
Reading Types
Reading Attributes
Reading java-language Annotations
Reading Symbols
Adjusting Flags
Loading Classes
Loading Packages
 

Reference article:

Http://blog.csdn.net/column/details/jvm-principle.html

Java class file structure and Classreader class interpretation of Javac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.