ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <flo...@mindspring.com>
Subject Re: AW: a problem compiling a Java 5 project with generics
Date Tue, 17 Oct 2006 15:39:28 GMT
Failed for me using Fedora Core 5, sun JDK 1.5_08

I don't think its javac as I was able to do this:

touch src/test/Test3.java
javac -d bin -sourcepath src -classpath bin src/test/Test3.java

Javac seems to find everything correctly...but the javac task in ant is 
having difficulties.  One thing to note is that the generics referred to 
by the inner classes are defined in terms of the outer class.

James Abley wrote:
> Fails for me:
>
> Ubuntu Dapper, Ant 1.6.5, Sun JDK 1.5.0_07
>
> <project>
>     <javac srcdir="." destdir="."/>
> </project>
>
> bash:$ ant -v
> bash:$ touch test/Test3.java
> bash:$ ant -v
>
>     [javac]     /work/ant-test/ant-generics/test/Test3.java
>     [javac] /work/ant-test/ant-generics/test/Test3.java:8: 
> incompatible types
>     [javac] found   : test.Base
>     [javac] required: test.Sub
>     [javac]         public Sub p() {return this.getV();}
>
> Is this a javac issue rather than ANT issue? I can provide more 
> information if required.
>
> James
>
> Jan.Materne@rzf.fin-nrw.de wrote:
>> Also no problems .... on WinXP, Ant 1.6.5 and Java 1.5.0_06-b05.
>>
>>> setant 165
>> Apache Ant version 1.6.5 compiled on June 2 2005
>>
>>> setjava 15
>> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
>> Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
>>
>>> del test\*.class
>>
>>> ant -v
>> Project base dir set to: C:\tmp\ant-generics
>>     [javac] build.xml skipped - don't know how to handle it
>>     [javac] test\Base.java added as test/Base.class doesn't exist.
>>     [javac] test\Sub.java added as test/Sub.class doesn't exist.
>>     [javac] test\Test1.java added as test/Test1.class doesn't exist.
>>     [javac] test\Test2.java added as test/Test2.class doesn't exist.
>>     [javac] test\Test3.java added as test/Test3.class doesn't exist.
>>     [javac] Compiling 5 source files to C:\tmp\ant-generics
>>     [javac] Using modern compiler
>>     [javac] Compilation arguments:
>>     [javac] '-d'
>>     [javac] 'C:\tmp\ant-generics'
>>     [javac] '-classpath'
>>     [javac] ' LOT-OF-LIBS-FROM-ANT '
>>     [javac] '-sourcepath'
>>     [javac] 'C:\tmp\ant-generics'
>>     [javac] '-g:none'
>>     [javac]
>>     [javac] The ' characters around the executable and arguments are
>>     [javac] not part of the command.
>>     [javac] Files to be compiled:
>>     [javac]     C:\tmp\ant-generics\test\Base.java
>>     [javac]     C:\tmp\ant-generics\test\Sub.java
>>     [javac]     C:\tmp\ant-generics\test\Test1.java
>>     [javac]     C:\tmp\ant-generics\test\Test2.java
>>     [javac]     C:\tmp\ant-generics\test\Test3.java
>> BUILD SUCCESSFUL
>>
>>> ant -v
>> NOTHING-TO-COMPILE
>>
>>> touch test\Test3.java   (using Cygwin)
>>
>>> ant -v
>> Project base dir set to: C:\tmp\ant-generics
>>     [javac] build.xml skipped - don't know how to handle it
>>     [javac] test\Base.class skipped - don't know how to handle it
>>     [javac] test\Base.java omitted as test/Base.class is up to date.
>>     [javac] test\Sub.class skipped - don't know how to handle it
>>     [javac] test\Sub.java omitted as test/Sub.class is up to date.
>>     [javac] test\Test1$Inner1.class skipped - don't know how to 
>> handle it
>>     [javac] test\Test1.class skipped - don't know how to handle it
>>     [javac] test\Test1.java omitted as test/Test1.class is up to date.
>>     [javac] test\Test2$Inner2.class skipped - don't know how to 
>> handle it
>>     [javac] test\Test2.class skipped - don't know how to handle it
>>     [javac] test\Test2.java omitted as test/Test2.class is up to date.
>>     [javac] test\Test3$Inner3.class skipped - don't know how to 
>> handle it
>>     [javac] test\Test3.class skipped - don't know how to handle it
>>     [javac] test\Test3.java added as test/Test3.class is outdated.
>>     [javac] Compiling 1 source file to C:\tmp\ant-generics
>>     [javac] Using modern compiler
>>     [javac] Compilation arguments:
>>     [javac] '-d'
>>     [javac] 'C:\tmp\ant-generics'
>>     [javac] '-classpath'
>>     [javac] ' LOT-OF-LIBS-FROM-ANT '
>>     [javac] '-sourcepath'
>>     [javac] 'C:\tmp\ant-generics'
>>     [javac] '-g:none'
>>     [javac]
>>     [javac] The ' characters around the executable and arguments are
>>     [javac] not part of the command.
>>     [javac] File to be compiled:
>>     [javac]     C:\tmp\ant-generics\test\Test3.java
>>
>> BUILD SUCCESSFUL
>>
>>
>>
>> build.xml:
>> <project>
>>     <javac srcdir="." destdir="."/>
>> </project>
>>
>>
>>
>> Jan
>>
>>
>>> -----Urspr√ľngliche Nachricht-----
>>> Von: Peter Reilly [mailto:peter.kitt.reilly@gmail.com] Gesendet: 
>>> Dienstag, 17. Oktober 2006 16:44
>>> An: Ant Users List
>>> Betreff: Re: a problem compiling a Java 5 project with generics
>>>
>>> On 10/17/06, Jan.Materne@rzf.fin-nrw.de <Jan.Materne@rzf.fin-nrw.de> 
>>> wrote:
>>>> Works for me with Ant 1.6.5 and 1.7beta2 and the given java 
>>> sources (with and without the commented line).
>>>> <project>
>>>>     <delete dir="." includes="**/*.class"/>
>>>>     <javac srcdir="." destdir="."/>
>>>> </project>
>>> This works by itself, but touch Test3.java and run again.
>>> Peter
>>>>
>>>>
>>>> Jan
>>>>
>>>>> -----Urspr√ľngliche Nachricht-----
>>>>> Von: Peter Reilly [mailto:peter.kitt.reilly@gmail.com]
>>>>> Gesendet: Dienstag, 17. Oktober 2006 11:39
>>>>> An: Ant Users List
>>>>> Betreff: Re: a problem compiling a Java 5 project with generics
>>>>>
>>>>> Can you enter a bugzilla report about this.
>>>>> It is very strange.
>>>>>
>>>>> I tried on the commandline:
>>>>>
>>>>> javac -target 1.5 -g -source  1.5 -sourcepath src -d build\classes 
>>>>> src\org\test\Test3.java
>>>>>
>>>>> which works fine - and looks very like the command used by ant.
>>>>>
>>>>> Peter
>>>>>
>>>>>
>>>>> On 10/17/06, Chavdar Botev <cbotev@gmail.com> wrote:
>>>>>> Hi
>>>>>>
>>>>>> For some reason, the mailing server included only the first 
>>>>>> attachment. Since this is the fourth or the fifth time I am
>>>>> trying to
>>>>>> send the java files, I give up. I'll inline them in the message.
>>>>>>
>>>>>> // src/test/Base.java
>>>>>> package test;
>>>>>> public class Base {}
>>>>>>
>>>>>>
>>>>>> // src/test/Sub.java
>>>>>> package test;
>>>>>> public class Sub extends Base {}
>>>>>>
>>>>>> // src/test/Test1.java
>>>>>> package test;
>>>>>> public class Test1<T extends Base> {
>>>>>>         public class Inner1 {
>>>>>>                 protected T v;
>>>>>>                 public Inner1(T v) {this.v = v;}
>>>>>>                 public T getV() {return this.v;}
>>>>>>         }
>>>>>>         public Inner1 getInner(T v) {return new Inner1(v);} }
>>>>>>
>>>>>> // src/test/Test2.java
>>>>>> package test;
>>>>>> public class Test2<T extends Base> extends Test1<T> {
>>>>>>         public class Inner2 extends Inner1 {
>>>>>>                 public Inner2(T v) {super(v);}
>>>>>>                 //public T getV() {return this.v;}
>>>>>>         }
>>>>>> }
>>>>>>
>>>>>> // src/test/Test3.java
>>>>>> package test;
>>>>>> public class Test3 extends Test2<Sub> {
>>>>>>         public class Inner3 extends Inner2 {
>>>>>>                 public Inner3(Sub v) {super(v);}
>>>>>>                 public Sub p() {return this.getV();}
>>>>>>         }
>>>>>>
>>>>>>         public Inner3 g() {
>>>>>>                 return new Inner3(new Sub());
>>>>>>         }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> HTH,
>>>>>> Chavdar
>>>>>>
>>>>>>
>>>>>> On 10/16/06, Petar Tahchiev <paranoiabla@gmail.com> wrote:
>>>>>>> On 17/10/06, Chavdar Botev <cbotev@gmail.com> wrote:
>>>>>>>> Hi!
>>>>>>>>
>>>>>>>> I've come accross the following problem trying to 
>>> compile Java
>>>>>>>> 5 classes with generics using Ant 1.6.5. I've attached
>>>>> project with
>>>>>>>> sample Java classes and a build.xml file.
>>>>>>>>
>>>>>>>> NOTE: Please create a src/test subdirectory and save the
>>>>> attached
>>>>>>>> .java files into it. The mailing list server gave me a hard

>>>>>>>> time acepting an email with the archived project files. :(
>>>>>>>>
>>>>>>>> A clean build of the above project works just fine 
>>> and compiles
>>>>>>>> without a problem. If after that, I touch the Test3.java
>>>>> file the
>>>>>>>> build fails with the following error:
>>>>>>>>
>>>>>>> [javac] C:\src\appforge\test\src\test\Test3.java:5: 
>>> incompatible
>>>>>>> types
>>>>>>>> [javac] found   : test.Base
>>>>>>>> [javac] required: test.Sub
>>>>>>>> [javac] public Sub p() {return this.getV();} [javac] 
>>> ^ [javac]
>>>>>>>> 1 error
>>>>>>>
>>>>>>> I must admit that this behaviour is really strange. I am
>>>>> interested
>>>>>>> in helping you but the problem is that I didn't receive 
>>> any .java
>>>>>>> files. Please try to prvide them again.
>>>>>>>
>>>>>>>
>>>>>>> Initially, I thought that this was a problem with the Java
>>>>> compiler.
>>>>>>>> After touching Test3.java, I tried running javac manually:
>>>>>>>>
>>>>>>>> javac -sourcepath src -d bin -g -source 1.5 -target 1.5 
>>>>>>>> src\test\*.java
>>>>>>>>
>>>>>>>> It turned out that with the above command-line the project

>>>>>>>> compiled OK. The project also compiles without a problem
>>>>> in Eclipse 3.2.1.
>>>>>>>> Am I missing anything? It is my understanding that the
>>>>> build file
>>>>>>>> and the command line should produce the same results.
>>>>>>>>
>>>>>>>> Upon further experimentation, if I uncomment the method in

>>>>>>>> Test2.java fixes the problem. Touching Test3.java does
>>>>> not break the build.
>>>>>>>> Thanks,
>>>>>>>> Chavdar
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>> ------------------------------------------------------------------
>>>>>>>> --- To unsubscribe, e-mail: 
>>> user-unsubscribe@ant.apache.org For
>>>>>>>> additional commands, e-mail: user-help@ant.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> -- 
>>>>>>> Regards, Petar!
>>>>>>> Karlovo, Bulgaria.
>>>>>>>
>>>>>>>
>>>>>>
>>> -------------------------------------------------------------------
>>>>>> -- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For
>>>>> additional
>>>>>> commands, e-mail: user-help@ant.apache.org
>>>>>>
>>>>>>
>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>>>>> additional commands, e-mail: user-help@ant.apache.org
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>>> additional
>>>> commands, e-mail: user-help@ant.apache.org
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>>> additional commands, e-mail: user-help@ant.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message