The structure sections need some work, it is incorrect as is. The "arrays", such as the constant pool, are not arrays in the typical sense (the entries are not
| This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||
| |||||||||||
The structure sections need some work, it is incorrect as is. The "arrays", such as the constant pool, are not arrays in the typical sense (the entries are not all the same size), instead it is more like a stream. Thus the formulas calculating it's size are misleading at best; they don't compute the number of bytes used. Also they don't account for the strange fact that long and double types consume two slots (leaving a phantom unused slot behind) rather than one slot like all other types. It should also be mentioned that the JVM's UTF-8 string type is not quite standard UTF-8; it is a modified non-standard form. The C representation is also by no means able to "fully represent" the file structure as stated. First, one must assume big-endian layout, no padding bytes, and the use of IEEE 754 floating point storage format. And as mentioned the arrays are nothing like C arrays at all (they contain variable-width members), so that part is pseudo code at best. Also the structure shown is only the outermost layer; none of the dependent inner types are shown in the code (so it can not be a complete representation). The table is also just visually cluttered, I'm sure it could be cleaned up a lot. - Dmeranda 05:20, 23 October 2007 (UTC)
The Java Virtual Machine Specification introduces the class file format with a C-like representation rather than a binary table format for a reason. Some find this more readable and easier to comprehend. That is why both are present in this article. @modi 05:06, 8 November 2007 (UTC)
One thing that isn't mentioned in the structure section, and is a very convenient thing to know in practice, is the assurance from JVMS chapter 4 that the concrete representations of various data types in the class file are exactly the representations consumed and produced by java.io.DataInputStream and java.io.DataOutputStream, respectively.--128.210.4.213 (talk) 22:47, 3 January 2008 (UTC)
It might be very useful for the history section to summarize the differences between class file versions in terms of which new attributes become mandatory in 46.0, 49.0, and 50.0 (JSR202 JVMS revised p. 126), and the opcodes to become illegal in 51.0 (p. 166). I haven't said more because I am not sure how much would be disclosable under the annoying EULA I had to accept before reading JSR202, but if others think such a brief summary could be allowed, I think it would be a valuable addition to the page. Also, footnote 1 on revised p. 96 supplies a relationship between class version and JDK version for JDK versions 1.2 and onward.--128.210.4.213 (talk) 22:47, 3 January 2008 (UTC)
What is the source for the description given for the Major version in the class file header?
I checked a number of JDK Java compilers, and found
* 45.3: javac 1.2.2 * 46.0: javac 1.4.2_12,1.4.2_14 * 49.0: javac 1.5.0_11,1.5.0_12 * 50.0: javac 1.6.0_06
So there is some difference to the description text for the major version given in this article, at least some JDK 1.4.x versions seem to be using major 46 instead of 48, and at least some 1.2.x versions use 45 instead of 46.
The article states, "Other integral types appearing in the high-level language, such as boolean, byte, and short must be represented as an integer constant."
While it's true that if you wanted to include a constant of one of these types into the constant pool, an integer entry was needed, a standard compiler will never do so as there are instructions (bipush and sipush) for using small integer values directly without the need for a constant pool entry at all.
Since the Java bytecode makes no difference between these integral types, all int values fitting into the short value range are encoded this way. Only values outside this range or needed for initializing compile-time constants (e.g. static final fields) will end up in the constant pool. —Preceding unsigned comment added by 77.188.94.56 (talk) 15:56, 22 February 2011 (UTC)
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.