Bug 50578 - Javac task failes when the "target" attribute is specified as 1.1.
Summary: Javac task failes when the "target" attribute is specified as 1.1.
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.8.2
Hardware: PC All
: P2 normal (vote)
Target Milestone: 1.8.3
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-12 22:02 UTC by tadashi.maemura
Modified: 2011-01-14 00:16 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tadashi.maemura 2011-01-12 22:02:32 UTC
With Ant 1.8.2, Javac task failes when the "target" attribute is specified as 1.1 and source
attribute is not specified.

Exsample of build.xml.
------------------------------------------------------------------------
<?xml version="1.0"?>

<project default="compile">

  <target name="compile">
    <javac destdir = "classes" srcdir = "src" target = "1.1"/>
  </target>

</project>
------------------------------------------------------------------------


Running the build.xml. (Version of javac is 1.6.0_22.)
------------------------------------------------------------------------
% ant
Buildfile: build.xml

compile:
    [javac] build.xml:6: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to classes
    [javac]
    [javac]           WARNING
    [javac]
    [javac] The -source switch defaults to 1.5 in JDK 1.5 and 1.6.
    [javac] If you specify -target 1.2 you now must also specify -source 1.1.
    [javac] Ant will implicitly add -source 1.1 for you.  Please change your build file.
    [javac] javac: invalid source release: 1.1
    [javac] Usage: javac <options> <source files>
    [javac] use -help for a list of possible options

BUILD FAILED
build.xml:6: Compile failed; see the compiler error output for details.
------------------------------------------------------------------------

Please note that the target attribute value is shown as 1.2.

I investigated the problem:  in org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter, 
setImplicitSourceSwitch method is in called as following.

setImplicitSourceSwitch(
	(assumeJava15() || assumeJava16()) ? "1.5 in JDK 1.5 and 1.6" : "1.7 in JDK 1.7",
        cmd,
	s,
	t);

But, setImplicitSourceSwitch method is declared as following.

private void setImplicitSourceSwitch(
	String defaultDetails,
	Commandline cmd,
	String target,
	String source) 

Please note the orders of "target" and "source": the call above passes parameters in wrong order.
Comment 1 Stefan Bodewig 2011-01-14 00:16:08 UTC
mea culpa.

Fixed with svn revision 1058854

The real solution for you is to avoid any implicit manipulations by Ant and
specify source explicitly as well (likely as 1.3).