Java-machine executable (class file)(cla.rfh):
Class: Executable and Object, Status: Almost Complete, Last change: 05.03.2008 18:32:06

set byteorder rev
type
  u1 num +(1)
  u2 num +(2)
  u4 num +(4)

data
0 u4 magic

assert magic=0xCAFEBABE;

descr ('CLASS file (Java VM executable).',NL,
  'Info Source: The JavaTM Virtual Machine Specification',NL,
  '  by Tim Lindholm and Frank Yellin',NL,
  '  at http://java.sun.com',NL)

type
  TCPInfoTag enum u1 (
    C_Class = 7,
    C_Fieldref = 9,
    C_Methodref = 10,
    C_InterfaceMethodref = 11,
    C_String = 8,
    C_Integer = 3,
    C_Float = 4,
    C_Long = 5,
    C_Double = 6,
    C_NameAndType = 12,
    C_Utf8 = 1
  )

//  TConstNDX1 u1()
//  TConstNDX u2()
  TUtf8NDX u2()
  TClassNDX u2()
  TNameTypeNDX u2()

  TRefInfo struc
    TClassNDX class_index
    TNameTypeNDX NameTypeNdx
  ends

  TLongInfo struc
    u4 high_bytes
    u4 low_bytes
  ends

  TNameTypeInfo struc
    TUtf8NDX nameNdx %Utf8
    TUtf8NDX descrNdx %Utf8
  ends

  TUtf8Str struc
    u2 len
    array[@.len] of Char val %in fact Utf-8 encoding
  ends

  cp_info struc
    TCPInfoTag Tag
    case @.Tag of
      C_Class: TUtf8NDX %name_index,Utf8
      C_Fieldref,
      C_Methodref,
      C_InterfaceMethodref: TRefInfo
      C_String: TUtf8NDX %string_index,Utf8
      C_Integer: u4 %Bytes
      C_Float: u4 %Bytes,IEEE 754
      C_Long: TLongInfo
      C_Double: TLongInfo
      C_NameAndType: TNameTypeInfo
      C_Utf8: TUtf8Str
    endc info
  ends

  attribute_info forward
/*
  attribute_info struc
    TConstNDX name_index,Ult8
    u4 len
    array[@.len]of u1 info
  ends
*/
  TFieldAccessFlags set 16 of (
  //Flag Name    Value   Meaning                        Used By
    ACC_PUBLIC =    0, //Is public; may be accessed
                       //from outside its package.      Any field
    ACC_PRIVATE =   1, //Is private; usable only within
                       //the defining class.            Class field
    ACC_PROTECTED = 2, //Is protected; may be accessed
                       //within subclasses.             Class field
    ACC_STATIC =    3, //Is static.                     Any field
    ACC_FINAL =     4, //Is final; no further
                       //overriding or assignment after
                       //initialization.                Any field
    ACC_VOLATILE =  6, //Is volatile; cannot be cached. Class field
    ACC_TRANSIENT = 7  //Is transient; not written or
                       //read by a persistent object
                       //manager.                       Class field
  )

  field_info struc
    TFieldAccessFlags access_flags
    TUtf8NDX nameNdx
    TUtf8NDX descrNdx
    u2 attr_count
    array[@.attr_count]of attribute_info attributes
  ends

  TMethodAccessFlags set 16 of (
  //Flag Name    Value   Meaning                        Used By
    ACC_PUBLIC =    0, //Is public; may be accessed
                       //from outside its package.      Any method
    ACC_PRIVATE =   1, //Is private; usable only within
                       //the defining class.            Class/instance
    ACC_PROTECTED = 2, //Is protected; may be accessed
                       //within subclasses.             Class/instance
    ACC_STATIC =    3, //Is static.                     Class/instance
    ACC_FINAL =     4, //Is final; no overriding
                       //allowed.                       Class
    ACC_SYNCHRONIZED=5,//Is synchronized; wrap use in
                       //monitor lock.                  Class/instance
    ACC_NATIVE=     8, //Is native; implemented in a
                       //language other than Java.      Class/instance
    ACC_ABSTRACT = 10  //Is abstract; no implementation
                       //is provided.                   Any method
  )

  method_info struc
    TMethodAccessFlags access_flags
    TUtf8NDX nameNdx
    TUtf8NDX descrNdx
    u2 attr_count
    array[@.attr_count]of attribute_info attributes
  ends

  TClassAccessFlags set 16 of (
  //Flag Name    Value   Meaning                        Used By
    ACC_PUBLIC =    0, //Is public; may be accessed     Class,
                       //from outside its package.      interface
    ACC_FINAL =     4, //Is final; no subclasses
                       //allowed.                       Class
    ACC_SUPER =     5, //Treat superclass methods       Class,
                       //specially in invokespecial.    interface
    ACC_INTERFACE = 9, //Is an interface.               Interface
    ACC_ABSTRACT = 10  //Is abstract; may not be        Class,
                       //instantiated.                  interface
  )

  TClassFile struc
    u2 minor_version
    u2 major_version
    u2 C_pool_count
    array[@.C_pool_count-1]of cp_info TAKES 2 when(
      (@.Tag=TCPInfoTag.C_Long)or(@.Tag=TCPInfoTag.C_Double)); C_pool
    TClassAccessFlags access_flags
    TClassNDX this_class
    TClassNDX super_class
    u2 interfaces_count
    array[@.interfaces_count]of TClassNDX interfaces
    u2 fields_count
    array[@.fields_count] of field_info fields
    u2 methods_count
    array[@.methods_count]of method_info methods
    u2 attr_count
    array[@.attr_count]of attribute_info attributes
  ends

data
0004 TClassFile Hdr


type
  TUtf8NDX enum TUtf8NDX
     Hdr.C_pool[@-1].info.C_Utf8.val;
  TClassNDX enum TClassNDX
     Hdr.C_pool[@-1].info.C_Class;
  TNameTypeNDX enum TNameTypeNDX
     Hdr.C_pool[@-1].info.C_NameAndType.nameNdx;
  TRefNDX enum u2
     Hdr.C_pool[@-1].info.C_Fieldref.NameTypeNdx;
  TFldRefNdx TRefNDX
  TMethRefNdx TRefNDX
  TIMethRefNdx TRefNDX

//  TConstNDX1 enum TConstNDX1 = Hdr.C_pool[@-1]
//  TConstNDX enum TConstNDX = Hdr.C_pool[@-1]
  TConstNDX1 num+(1):displ=(Hdr.C_pool[@-1],'{',@,'}')
  TConstNDX num+(2):displ=(Hdr.C_pool[@-1],'{',@,'}')

include java_cod.rfi

type
  TAttrData raw[]

  TCodeExcRec struc
    u2 start_pc
    u2 end_pc
    u2 handler_pc
    TClassNDX catch_type
  ends

  TCodeAttr struc
    u2 max_stack
    u2 max_locals
    u4 CodeLen
    TOpSeries code
  %  raw[@.CodeLen] code
    u2 ExcTblLen
    array[@.ExcTblLen]of TCodeExcRec exc_tbl
    u2 AttrCnt
    array[@.AttrCnt]of attribute_info attributes
  ends:[@.code:Size=@.CodeLen]

  TExcAttr struc
    u2 NumExc
    array[@.NumExc]of TClassNDX ExcNdxTbl
  ends

  TLinNumRec struc
    u2 pc
    u2 l
  ends

  TLinNumAttr struc
    u2 Len
    array[@.Len]of TLinNumRec LinNumTbl
  ends

  TLocVarRec struc
    u2 start_pc
    u2 len
    TUtf8NDX name_index
    TUtf8NDX descr_index
    u2 index
  ends

  TLocVarTblAttr struc
    u2 Len
    array[@.Len]of TLocVarRec LocVarTbl
  ends

  attribute_info struc
    TUtf8NDX name_index %Ult8
    u4 len
    case Hdr.C_pool[@.name_index-1].
         info.C_Utf8.val of
      'SourceFile': TUtf8NDX
      'ConstantValue': TConstNDX
      'Code': TCodeAttr
      'Exceptions': TExcAttr
      'LineNumberTable': TLinNumAttr
      'LocalVariableTable': TLocVarTblAttr
    else
      TAttrData
    endc info
  ends:[@.info:Size=@.len]



Other specifications.


FlexT home page, Author`s home page.