Skip to content

Instantly share code, notes, and snippets.

@ivanpierre
Created January 19, 2014 21:57
Show Gist options
  • Save ivanpierre/8511518 to your computer and use it in GitHub Desktop.
Save ivanpierre/8511518 to your computer and use it in GitHub Desktop.
Root structure of a JVM file
(def structures
"Definition of class structures"
'{
; http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1
:class {:struct [:magic :u4
:minor-version :u2
:major-version :u2
:constant-pool (:cp-info)
:access-flags (:access-flags :class)
:this-class (:const :cst-class)
:super-class (:const :cst-class)
:interfaces (:interface-info)
:fields (:struct-array :fields)
:methodss (:struct-array :methods)
:attributes (:attribute-info :class)]
}
; http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.5
:fields {:struct [:access-flags (:acces-flags :field)
:name-index (:const :cst-utf8)
:descriptor (:const :cst-type)
:attributes (:attribute-info :field)]
}
; http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.6
:methods {:struct [:access-flags (:acces-flags :method)
:name-index (:const :cst-utf8)
:descriptor (:const :cst-type)
:attributes (:attribute-info :method)]
}
; In Code Attribute http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.3
:exceptions {:struct [:start-pc :u2
:end-pc :u2
:handler-pc :u2
:catch-type (:const :cst-class)]
}
; In exceptions Attribute http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.5
:throws {:struct (:const :cst-class)}
; In innerClass Atribute http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.6
:inner-classes {:struct [:inner-class (:const :cst-class)
:outer-class (:const :cst-class)
:inner-name (:const :cst-utf8)
:access-flags (:access-flags :class)]
}
; In LineNumberTable Attribute http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.12
:line-numbers {:struct [:start-pc :u2
:line-number :u2]
}
; In LocalVariableTable http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.13
:local-variables {:struct [:start-pc :u2
:length :u2
:name (:const :cst-utf8)
:descriptor (:const :cst-utf8)
:index :u2]
}
; In LocalVariableTypeTable http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.14
:local-variables-types {:struct [:start-pc :u2
:length :u2
:name (:const :cst-utf8)
:signature (:const :cst-utf8)
:index :u2]
}
; RuntimeVisibleAnnotations http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.16
:annotations {:struct [:type (:const :cst-utf8)
:value-pairs (:struct-array :value-pairs)]
}
; RuntimeVisibleAnnotations http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.16
:value-pairs {:struct [:element-name (:const :cst-utf8)
:element-value (:element-value)]
} ; element-value is more complicated,union
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment