http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1362
*** shadow/1362 Tue Apr 17 09:19:13 2001
--- shadow/1362.tmp.11800 Tue Apr 17 09:19:13 2001
***************
*** 0 ****
--- 1,124 ----
+ +============================================================================+
+ | class initialisation for task java is not well done |
+ +----------------------------------------------------------------------------+
+ | Bug #: 1362 Product: Ant |
+ | Status: NEW Version: 1.3 |
+ | Resolution: Platform: PC |
+ | Severity: Normal OS/Version: Windows NT/2K |
+ | Priority: Medium Component: Core tasks |
+ +----------------------------------------------------------------------------+
+ | Assigned To: [EMAIL PROTECTED] |
+ | Reported By: [EMAIL PROTECTED] |
+ | CC list: Cc: |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ It seems that the java-task doesn't initialize the class the same way as the
+ java tool.
+
+ Here is a use case:
+ u.A and t.B are two classes.
+ main is defined only in A.
+ java t.B should call t.B class initialisation
+ but when used inside a ant buildfile it doesn't work this way :
+ ---------------------------------------------------------------
+ U:\test>ant
+ Buildfile: build.xml
+
+ compile:
+
+ run:
+ A CLASS INITIALIZATION<<<<<< hey what about B!
+ MAIN
+ I am a A.
+
+ all:
+
+ BUILD SUCCESSFUL
+
+ Total time: 1 second
+
+ U:\test>java -classpath build t.B
+ A CLASS INITIALIZATION
+ B CLASS INITIALIZATION<<<< Ok that is better!
+ MAIN
+ I am a B.
+
+ Here is a list of files and contents :
+
+ build.xml
+ -------------------------------
+ <?xml version="1.0" encoding="ISO-8859-1"?>
+
+ <project name="test" default="all">
+ <target name="all" depends="run" />
+
+ <target name="run" depends="compile">
+ <java className="t.B">
+ <classpath>
+ <pathelement path="build"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="compile">
+ <javac destdir="build" srcdir=".">
+ <patternset>
+ <include name="**/*.java"/>
+ </patternset>
+ <classpath>
+ <pathelement path="."/>
+ </classpath>
+ </javac>
+ </target>
+ <target name="init">
+ <mkdir dir="build"/>
+ </target>
+ </project>
+ ------------------------------
+ t/B.java:
+ ------------------------------
+ package t;
+ public class B extends u.A
+ {
+ static
+ {
+ System.out.println("B CLASS INITIALIZATION");
+ setA(new B());
+ }
+ public String toString()
+ {
+ return "I am a B.";
+ }
+ }
+ ------------------------------
+ u/A.java:
+ ------------------------------
+ package u;
+ public class A
+ {
+ public static void main(String [] args){
+ System.out.println("MAIN");
+ System.out.println(a);
+ }
+ static A a=new A();
+
+ static
+ {
+ System.out.println("A CLASS INITIALIZATION");
+ }
+
+ protected static void setA(A oa)
+ {
+ a=oa;
+ }
+
+ public String toString()
+ {
+ return "I am a A.";
+ }
+
+ }
+
+ Any clue of what is wrong?