Jump to content
  • Advertisement
Sign in to follow this  
plywood

Java VM specification question

This topic is 3838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am reading Chapter 4 from the JVM specification which concerns classfile structure, and have a question regarding attributes. First of all I'm a little confused as to what purpose attributes serve to begin with, whereas I understand the purpose behind field and method access flags, etc. But beyond purpose, the specification seems to be a little ambiguous. It starts off by saying that all attributes have the following format:
// NOTE: u2 = 2 bytes unsigned, u4 = 4 bytes unsigned
attribute_info {
    u2 attrib_name_index;
    u4 attrib_length;
    u2 info[attrib_length];
}

However about two paragraphs later the specification begins describing a completely different struct format for the Exceptions attribute:
Exceptions_attribute {
    u2 attrib_name_index;
    u4 attrib_length;
    u2 number_of_exceptions;
    u2 exception_index_table[number_of_exceptions];
}

Beyond that there are about 8 other attributes, each of which has an entirely different format that the originally-proposed attribute_info struct... How do each of these specific variations of attributes (e.g. Exceptions, Code, ConstantValue) "tie in" with the attribute_info struct? And again what purpose do they serve for the JVM? Thanks for any help here, ply

Share this post


Link to post
Share on other sites
Advertisement
You'll notice that every attribute starts with the same two headers:

u2 attrib_name_index;
u4 attrib_length;

In the general attribute_info case the u2 info[attrib_length] acts as a placeholder for the rest of the attribute data for the individual attribute types.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!