Searching for version issues, I had a closer look at the *.class files
generated by Maven2 with the default compiler settings and found that
the first bytes of them are "cafe babe 0003 002D ...", which is byte
code version 45.3 = Java 1.1.
First I was believing that I had this (target 1.1) configured somewhere
by accident. However, I didn't find any such configuration, therefore I
dug into the plexus-compiler source and found the following in
plexus-site/plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java:
// TODO: this could be much improved
if ( StringUtils.isEmpty( config.getTargetVersion() ) )
{
// Required, or it defaults to the target of your JDK (eg 1.5)
args.add( "-target" );
args.add( "1.1" );
}
else
{
args.add( "-target" );
args.add( config.getTargetVersion() );
}
if ( !suppressSource( config ) && StringUtils.isEmpty(
config.getSourceVersion() ) )
{
// If omitted, later JDKs complain about a 1.1 target
args.add( "-source" );
args.add( "1.3" );
}
Is there any particular reason why target is set to 1.1 here? IMHO, it
breaks the rule of least surprise for I am certainly expecting that the
generated byte code by default has the version of the JDK I'm using the
compiler of. The comment "Required, or it defaults to the target of your
JDK" doesn't give any reason. Does anybody know, why this default is set?
At least it should be mentioned on
http://maven.apache.org/plugins/maven-compiler-plugin/howto.html to make
it obvious to users. Otherwise people might have problems and need a
long time to find out what's going on (see
http://www.nabble.com/Odd-Compilation-Issue-tf1566644s177.html#a4287495
for an example).
Regards,
Gisbert
--
Gisbert Amm
Softwareentwickler Infrastruktur
WEB.DE GmbH
Brauerstraße 48 · D-76135 Karlsruhe
Tel. +49-721-91374-4224 · Fax +49-721-91374-2740
[EMAIL PROTECTED] · http://www.web.de/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]