ClassFormatError: Incompatible magic value 0 in class file

2

My project was working normally. After restarting my machine, running it through the IDE returns the following:

Exception in thread "main" java.lang.ClassFormatError: Incompatible magic value 0 in class file Principal$9
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at Principal.main(Principal.java:707)

Does anyone know why this error occurs?

    
asked by anonymous 19.07.2016 / 21:01

2 answers

2

I updated the version of JDK where I solved the problem.

    
19.07.2016 / 21:09
2

Incompatible magic value happens when a class has been corrupted in some way ( eg, the download of some .class failed or the bytecodes compiler / generator did something it should not). I've seen this happen a few times in Eclipse projects (which use an incremental compiler) and / or in projects with Javassist, ASM, etc.

The class starting with byte 0 (instead of CAFEBABE ) usually implies that a download failed or the compiler did not do what it should and created an empty .class file.

The solution to this type of problem usually involves clearing the class cache, checking the integrity of any class you have downloaded (eg, comparing the checksum ), cleaning and building the project again and review any part of the stack that is handling bytecode

19.07.2016 / 21:47