Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incompatible magic value 1768713317 in class file

Tags:

java

I have a class file and when I'm on the website the following message comes:

Incompatible magic value 1768713317 in class file "spectrum".

What does this magic value mean? Please help :)

like image 323
narf Avatar asked Sep 01 '12 19:09

narf


2 Answers

The first four bytes of .class file (compiled Java binary) should be 0xCAFEBABE - so called magic value.

In your case these are 1768713317 or 0x696C6C65 or "ille" (ille...gal?) in ASCII. Most likely some JVM tries to open a file thinking that this is bytecode, while it is actually a text file. Maybe class was suppose to be downloaded but the server returns some error instead?

like image 192
Tomasz Nurkiewicz Avatar answered Oct 31 '22 23:10

Tomasz Nurkiewicz


Magic number is the first 4 bytes in each compiled Java class. This is the structure of a compiled Java class:

ClassFile {
    u4             magic;
    u2             minor_version;
    u2             major_version;
    u2             constant_pool_count;
    cp_info        constant_pool[constant_pool_count-1];
    u2             access_flags;
    u2             this_class;
    u2             super_class;
    u2             interfaces_count;
    u2             interfaces[interfaces_count];
    u2             fields_count;
    field_info     fields[fields_count];
    u2             methods_count;
    method_info    methods[methods_count];
    u2             attributes_count;
    attribute_info attributes[attributes_count];
}

'magic' should always be equal to: 0xCAFEBABE. It tells the JVM: "Hey you! I'm a Java class, you can execute my code!". When JVM reads a file and the magic number is not valid it won't execute it.

like image 29
Adam Sznajder Avatar answered Nov 01 '22 01:11

Adam Sznajder