Content deleted Content added
Tags: Reverted references removed |
→Representation in a C-like programming language: use more Java-like layout |
||
(8 intermediate revisions by 8 users not shown) | |||
Line 27:
JVMs are available for many [[platform (computing)|platform]]s, and a class file compiled on one platform will execute on a JVM of another platform. This makes Java applications [[cross-platform|platform-independent]].
==History==
On 11 December 2006, the class file format was modified under [[Java Specification Request]] (JSR) 202.<ref>[http://www.jcp.org/en/jsr/detail?id=202 JSR 202] Java Class File Specification Update</ref>
==File layout and structure==
Line 34:
===Sections===
There are 10 basic sections to the Java class file structure:
* '''[[Magic number (programming)|Magic Number]]''': <code>0xCAFEBABE</code>
* '''Version of Class File Format''': the minor and major versions of the class file
* '''Constant Pool''': Pool of constants for the class
Line 95:
| rowspan="2" | 2 bytes
| rowspan="2" | u2
| rowspan="2" | major version number of the class file format being used.<ref>{{Cite web|url=https://docs.oracle.com/javase/specs/jvms/
Java SE 25 = 69 (0x45 hex),<br />
Java SE 24 = 68 (0x44 hex),<br />
Java SE 23 = 67 (0x43 hex),<br />
Java SE 22 = 66 (0x42 hex),<br />
Java SE 21 = 65 (0x41 hex),<br />
Line 229 ⟶ 232:
|}
===Representation
The following is a representation of a {{mono|.class}} file as if it were a C-style struct.
<syntaxhighlight lang="
struct
u4
u2
u2
u2
ConstantPoolInfo[constantPoolCount - 1] constantPool;
u2
u2
u2
u2
u2[interfacesCount] interfaces;
u2
FieldInfo[fieldsCount] fields;
u2
MethodInfo[methodsCount] methods;
u2
AttributeInfo[attributesCount] attributes;
}
</syntaxhighlight>
|