[JVM Parsing series] [eight] Method table collection, Code property and exceptions property, where does your bytecode exist?

Source: Internet
Author: User
Tags field table try catch

According to the overall composition of our fifth chapter, we are going to talk about the collection of method tables in this chapter:

You might notice that declaring a method in Java is similar to declaring a variable, public int a = 0, and public int A () {}; So it is similar in the Method table collection to the Field table collection.

The structure of a method table should be the same as:


The Comparison field table should find almost the same. The options in the access_flags are slightly different.

Access_flags:


In this way we should understand the comparison between the method table and the Field table. A chunk of the content for the property sheet. Last time we talked about the structure of the property sheet.

And it says the property sheet that is used in the field table. Same today we put out several important attribute tables in the method table and explain in detail

Here we've posted two more common attributes:

1. Code

The code in the Java program method is Javac compiled, and the bytecode exists within a code attribute

The Code attribute table is structured as follows:


Looking at the Max_stack property from the graph, we have said that the execution of a byte code depends on the stack, so max_stack is the maximum depth of the stack.

Max_locals represents the required space for a local variable table, in which the slot is the smallest unit used by the virtual machine to allocate memory for local variables.

Code is really used to store bytecode instructions, each code occupies the U1 type, that is, 0~255, that is, Java can express up to 256 instructions, currently Java only about 200 instructions

Exception to some methods can have, some methods can be no, not a must table, exception table of sister Oh shares as shown (note with the exception attribute separate)


It's obvious that he corresponds to a try catch, start_pc and end_pc divide try{}, and Catch_type represents that parameter exception in catch (Exception), and if you catch an exception, go to Handler_. PC processing.

Sorry everyone I need to go out, in the afternoon back to continue to update. Has returned, continue to update.

With the exception of the code attribute, the next step is the exceptions property , which has the following table structure:


The first two don't have to explain.

The third number_of_exceptions indicates that this method may throw number_of_exceptions species, each of which is represented by exception_index_table, and he only thinks of the constant pool Constant_ The index of the Class_info type.

[JVM Parsing series] [eight] Method table collection, Code property and exceptions property, where does your bytecode exist?

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.