I can't say why it's doing this, but hopefully the following info might
give someone who knows Java better a pointer to figuring it out.
I tried reproducing it and found that if I don't include the <classpath>
element (ie., if I put the classfile in a jar and put that jar in
$ANT_HOME/lib), it doesn't do the duplication. But if I put the jar in
some other directory and include the <classpath>, then it does the
duplication. However, if I include the <classpath> element and also set
fork="true", then it doesn't do the duplication.
Debug output from the duplicating run shows:
[java] Running in same VM Test ${arg1} ${arg2} ${arg3} ${arg4}
${arg5} ${arg6} ${arg7} ${arg8}
force loading Test
Finding class Test
Class java.lang.Object loaded from parent loader
Class java.lang.System loaded from parent loader
Class java.io.PrintStream loaded from parent loader
[java] Should be here only once
Class java.lang.String loaded from parent loader
[java] Should be here only once
[java] Testing, testing
Diane
--- Sundberg Jukka <[EMAIL PROTECTED]> wrote:
> Running a following target causes ant to create two instances of the
> java
> class:
>
> <!--
>
============================================================================
> = -->
> <!-- for testing
> -->
> <!-- USAGE: BUILD test -Dname=my.package.Test -Darg1=120
> -Darg2=huhuu etc -->
> <!--
>
============================================================================
> = -->
> <target name="test">
> <java classname="${name}">
> <arg value="${arg1}"/>
> <arg value="${arg2}"/>
> <arg value="${arg3}"/>
> <arg value="${arg4}"/>
> <arg value="${arg5}"/>
> <arg value="${arg6}"/>
> <arg value="${arg7}"/>
> <arg value="${arg8}"/>
> <classpath refid="my.classpath"/>
> </java>
> </target>
>
> In here BUILD is .bat file with a following call:
>
> call ant %1 %2 %3 %4 %5 %6 %7 %8 %9 -buildfile
> c:/myBuild/build.xml
>
> Here is the my.package.Test class:
>
> package my.package;
> public class Test{
> public Test(){
> System.out.println("Should be here only once");
> }
> public void testing(){
> System.out.println("Testing, testing");
> }
> public static void main(String[] args){
> Test ts = new Test();
> ts.testing();
> }
> }
>
> And surprise here is the result:
> Should be here only once
> Should be here only once
> Testing, testing
>
> I didn't find any fix in nightly builds, and I didn't find it in bugdb.
> Has
> anyone encountered this feature? How do I get aroung it?
>
> Thanks,
>
> Jukka Sundberg
>
>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
=====
([EMAIL PROTECTED])
__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>