ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: AW: a problem compiling a Java 5 project with generics
Date Wed, 18 Oct 2006 11:58:19 GMT
On 10/18/06, Steve Loughran <stevel@apache.org> wrote:
> Peter Reilly wrote:
> > On 10/17/06, Chavdar Botev <cbotev@gmail.com> wrote:
> >> Peter,
> >>
> >> I repeated the steps you described and I can confirm that with the
> >> -classpath argument the compilation fails and without it the
> >> compilation succeeds. I also tried running javac on "src/test/*.java"
> >> instead of "src/test/Test3.java". In this case, the compilation
> >> succeeds with or without -classpath.
> >>
> >> I think it looks like some dependency problem.
> >
> > I have just checked the <javac> revision history,
> > since the initial checkin (6 years, 9 months), <javac> has always added
> > the destination path to the classpath for the javac command.
> >
> > It does not seem to be necessary? but I do not know if
> > we can remove it without something failing.
> > Perhaps we can use (yet another) attribute to javac to
> > disable this behaviour.
> >
>
> It is probably needed for incremental builds in which all source files
> are not in the source tree you specify, such as when you have multiple
> <javac> tasks building into the same place.

Ah, of course, it is needed for that, it is also needed if
we do not want javac to compile the dependent classes that
are already compiled.


>
> I think we have caused a java generics bug to surface here. If
> -classpath triggers it on the command line, it is probably a sun
> problem. Question is, how to report it,

fill out a bug report with sun.
note the bug happens also if the classes are
in a jar file.

The probable source of the javac bug
is that the generics implemenation of java losses type information
when placed in class (erasure I think they call it) so the javac
only sees test.Base and not test.Sub,


> and how to work around it in ant?

I do not know - document the fact in the javac manual page?
Optionally not setting classpath may solve some of the symtoms

here is a shell script that shows the problem:

function makedir() {
    rm -rf $1
    mkdir -p $1
}

makedir classes

echo compiling all the java files
javac -sourcepath src -d classes src/test/*.java
echo jaring the classes
cd classes
jar cf ../jar.jar .
cd ..
echo compiling Test3 with jar.jar in the classpath
makedir classes
javac -classpath jar.jar -sourcepath src -d classes src/test/Test3.java
echo compiling Test3 without jar.jar in the classpath
makedir classes
javac -sourcepath src -d classes src/test/Test3.java
ls -rtla classes/test


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


Mime
View raw message