| Author |
.class and Compiler Version?
|
Guy Allard
Ranch Hand
Joined: Nov 24, 2000
Posts: 776
|
|
Yes, .class files begin with the magic number 0xcafebabe. Is there a magic marker identifying the version of the compiler that produced the .class file? If so, how do I easily find it? Thanks, Guy
|
 |
Jessica Sant
Sheriff
Joined: Oct 17, 2001
Posts: 4313
|
|
Check out the Virtual Machine Spec: 4.1 ClassFile
The items in the ClassFile structure are as follows: magic The magic item supplies the magic number identifying the class file format; it has the value 0xCAFEBABE. minor_version, major_version The values of the minor_version and major_version items are the minor and major version numbers of the compiler that produced this class file. An implementation of the Java Virtual Machine normally supports class files having a given major version number and minor version numbers 0 through some particular minor_version. .......
|
- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
|
 |
Guy Allard
Ranch Hand
Joined: Nov 24, 2000
Posts: 776
|
|
OK, read the reply, looked at the spec link, I assume for now that 'u2' is an unsigned 2 bytes, big-endian. java -version shows me:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06) Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
I use javac to compile, and in the .class file following 0xcafebabe I see: 0x0000002e Do you know how I can interpret that? Thanks, Guy
|
 |
Guy Allard
Ranch Hand
Joined: Nov 24, 2000
Posts: 776
|
|
Sorry I am not being precise. My object here is to determine if a .class was produced by a 1.3.x compiler or a 1.4.x compiler. Thanks, Guy
|
 |
Guy Allard
Ranch Hand
Joined: Nov 24, 2000
Posts: 776
|
|
Interesting. When I compile with: 1.3.1_08-b03 following 0xcafebabe I get: 0x0003002d Speculation: The low order nibble is the key: -d=13 -e=14 Regards, Guy
|
 |
Julian Kennedy
Ranch Hand
Joined: Aug 02, 2004
Posts: 823
|
|
Try it with Tiger and see if you get an F. I guess that theory would require modifying for Mustang or you'll need a bigger nibble! Jules
|
 |
Stefan Wagner
Ranch Hand
Joined: Jun 02, 2003
Posts: 1923
|
|
00 00 00 31 for tiger. But compiler have switches, so you may specify -target 1.4 or -target 1.3 with a 1.5 or 1.4 compiler. So you should check this too.
|
http://home.arcor.de/hirnstrom/bewerbung
|
 |
Jessica Sant
Sheriff
Joined: Oct 17, 2001
Posts: 4313
|
|
so that spec I linked to before says "In Sun's Java Developer's Kit (JDK) 1.0.2 release, documented by this book, the value of major_version is 45. The value of minor_version is 3. Only Sun may define the meaning of new class file version numbers." So, I guess if you can find the magic list of numbers to JDK versios -- then you're good to go!
|
 |
 |
|
|
subject: .class and Compiler Version?
|
|
|