Topic
1 reply Latest Post - ‏2007-10-15T06:29:32Z by SystemAdmin
SystemAdmin
SystemAdmin
235 Posts
ACCEPTED ANSWER

Pinned topic parsing java class file and unknown attribute

‏2007-10-11T12:56:54Z |
Hello List,

While parsing a java class file in JVM's bootstrap class loader, what should be the size(in bytes) by which the "current" pointer should be incremented especially while the parser encounters an unknown attribute.

Something like,

u1 *pcur = BEGINING_OF_CLASS_FILE;

if(parsed_attribute == UNKNOWN_ATTRIBUTE) {
pcur = (u4)(pcur) + sizeof((pcur)->code_atr.attribute_name_index);
}
Updated on 2007-10-15T06:29:32Z at 2007-10-15T06:29:32Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    235 Posts
    ACCEPTED ANSWER

    Re: parsing java class file and unknown attribute

    ‏2007-10-15T06:29:32Z  in response to SystemAdmin
    Hello List,

    Ok, I found the way out. As per JVM specs. the "attribute_length" follows the "attribute_name_index". That makes it possible to decide as to "how-many-bytes-to-skip" before trying to identify the next field while class file reader encounters an "unknown attribute".
    Hello List,

    While parsing a java class file in JVM's bootstrap
    class loader, what should be the size(in bytes) by
    which the "current" pointer should be incremented
    especially while the parser encounters an unknown
    attribute.

    Something like,

    u1 *pcur = BEGINING_OF_CLASS_FILE;

    if(parsed_attribute == UNKNOWN_ATTRIBUTE) {
    pcur = (u4)(pcur) +
    + sizeof((pcur)->code_atr.attribute_name_index);
    }