Note: This Java deployment guide describes features released prior to the Java SE 6 update 10 release. See Java Rich Internet Applications Development and Deployment for the latest information.
java.lang.ClassFormatError
Thrown by
ClassLoader
When running an applet in a browser using the Sun Java™
Runtime Environment (JRE™), a
java.lang.ClassFormatError
is thrown by the
ClassLoader
. The same applet runs under the
Microsoft Virtual Machine (VM).
This error is caused by bytecodes generated from old JDK
1.0.2/1.1 compilers, or from a third-party obfuscator. In the past,
many of these compilers and obfuscators generated bytecode that
does not conform to the Sun JRE Specification. Because the
verifiers in recent Java SE releases are much strict about bad
class format, the java.lang.ClassFormatError
is thrown
by the VM when these bad class files are loaded.
Some typical problems in some older class files are the following (note that this list is not exhaustive):
To allow some of the applets with bad class files to run in the Java platform, Java Plug-in contains a bytecode transformer to transform some of the bad class files to good ones. Currently, only bad class files with the following problems may be transformed:
Unfortunately, the bytecode transformer cannot transform the
following problems, which will still result in a
ClassFormatError
:
You can resolve these problems by simply recompiling your Java
classes with the javac
compiler from the JDK. If you
choose to use a third-party obfuscator, be sure to use one that
produces class files that respect proper class-file format.
None.