On Tuesday 16 May 2006 02:28, "wu chuanwen" <[EMAIL PROTECTED]> wrote 
about 'Re: [gentoo-user] cause jdk1.5 emerge tomcat error!':
> 2006/5/15, Boyd Stephen Smith Jr. <[EMAIL PROTECTED]>:
> > On Sunday 14 May 2006 13:32, "wu chuanwen" <[EMAIL PROTECTED]> wrote
> >
> > about 'Re: [gentoo-user] cause jdk1.5 emerge tomcat error!':
> > > java.lang.UnsupportedClassVersionError:
> >
> > A 1.4 vm refuses to load the output from a 1.5 javac because of the
> > classfile format bump.  A 1.5 vm will load both 1.4 and 1.5
> > classfiles. Try running w/ 1.5.
>
> what does this mean?

javac compiles .java files into (one or more) .class files.  Multiple class 
files plus metadata files are zip'd into a .jar file.

.class files have a very specific format.  In particular there's the 
classfile "magic" (0xCAFEBABE) that "confirms" that a file with the .class 
extension is really in the classfile format, and can be used to identify 
un- or mis-named classfiles.

Further on in the classfile header (before the data specific to the .java 
file) is a classfile version.  Different versions of javac write out 
different classfile versions.  Presumably to make sure a vm can /safely/ 
load a class.  In particular, there've been at least 2 version bumps.  One 
from somewhere between 1.0 and 1.2 and one between 1.4 and 1.5.  I'm not 
sure on the /exact/ chanages associated with each of those bumps.

Each vm has a whitelist of classfile versions it will load.  The default 
version output by a 1.5 javac is not on the whitelist for a 1.4 vm.  You 
can change the classfile version output with the --target argument to 
javac.

Also, javac actually runs inside a vm, and will attempt to load classfiles 
that are used by your program, but not available on the source path, in an 
attempt to ensure you are using those classes correctly.  The classfiles 
must have a version loadable by javac's vm or you get the same error.

-- 
"If there's one thing we've established over the years,
it's that the vast majority of our users don't have the slightest
clue what's best for them in terms of package stability."
-- Gentoo Developer Ciaran McCreesh

Attachment: pgp40SSjzUNog.pgp
Description: PGP signature

Reply via email to