article 01





java.lang.ClassFormatError ...






Documentation Contents
p, li {font-family: arial; font-size: 10pt;}


java.lang.ClassFormatError Thrown by ClassLoader

Symptoms

When running an applet in a browser using the Sun JavaTM Runtime Environment (JRETM), a java.lang.ClassFormatError
is thrown by the ClassLoader. The same applet runs under the
Microsoft  Virtual Machine (VM).

Cause

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):

There are extra bytes at the end of the class file.
The class file contains method or field names that do not begin with
a letter.
The class attempts to access private members of another class.
The class file has other format errors, including illegal constant pool
indices and illegal UTF-8 strings.
The class file produced by an early (third-party) bytecode obfuscator
violates proper class-file format.


Resolution

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:

Local variable name with a bad constant pool index
Extra bytes at the end of the class file
Code segment of the wrong length
Illegal field/method name
Illegal field/method modifiers
Invalid start_pc/length in local var table

Unfortunately, the bytecode transformer cannot transform the following
problems, which will still result in a ClassFormatError:

Illegal use of nonvirtual function call
Arguments can not fit into locals
Unsorted lookup switch
Truncated class file

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.

Related Information
        None.
 





Copyright © 1995-2010 Sun Microsystems, Inc. All Rights Reserved. Please send comments using this Feedback page.

Java Technology








Wyszukiwarka

Podobne podstrony:
NeHe Productions OpenGL Article #01
t informatyk12[01] 02 101
r11 01
2570 01
introligators4[02] z2 01 n
Biuletyn 01 12 2014
beetelvoiceXL?? 01
01
2007 01 Web Building the Aptana Free Developer Environment for Ajax
9 01 07 drzewa binarne
01 In der Vergangenheit ein geteiltes Land Lehrerkommentar
L Sprague De Camp Novaria 01 The Fallible Fiend

więcej podobnych podstron