Please see the java source file and build.xml that follow. Running java
1.4.1_01 under linux as shown by
onofre:2:138 % java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
ant 1.5.1 as shown by
onofre:2:140 % ant -version
Apache Ant version 1.5.1 compiled on October 2 2002
and junit 3.7.
When I run the small test program (included below) directly
onofre:2:145 % java -classpath junit.jar:. myTest
OK (6 tests)
it runs successfully. Also, when I run it under ant with fork="true", it
runs successfully. When I run it under ant with fork="false", it
generates a
[java] java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl
error. The build.xml included belowe runs both the unforked and the
forked cases in that order as seen below.
onofre:2:141 % ant
Buildfile: build.xml
compile:
testNoFork:
[java] java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl
testFork:
[java] OK (6 tests)
test:
BUILD SUCCESSFUL
Total time: 2 seconds
I have also found that when I comment out any one of the six test cases,
it runs fine either forked or unforked. Finally, when I switch back to
jdk 1.3, it also runs without error.
I've run out of ideas about what to try and am hoping somebody else
recognizes this or has suggestions.
--Steve
"Perhaps God gave man free will so he
could choose to stop those who had chosen evil."
<James Lileks>
==========================myTest.java=======================================
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.framework.TestResult;
public class myTest extends TestCase {
public myTest(String name) {
super(name);
}
public static Test suite() throws ClassNotFoundException {
return new TestSuite(Class.forName("myTest"));
}
public void test0() { }
public void test1() { }
public void test2() { }
public void test3() { }
public void test4() { }
public void test5() { }
public static void main(String[] argv) throws Exception {
Test suite = suite();
junit.textui.TestRunner runner = new junit.textui.TestRunner();
TestResult result = new TestResult();
suite.run(result);
runner.print(result);
}
}
=============================build.xml=====================================
<?xml version="1.0"?>
<project name="Test" default="test" basedir=".">
<property name="JUnitJar" value="junit.jar"/>
<target name="compile">
<javac srcdir=".">
<include name="myTest.java"/>
<classpath>
<pathelement location="${JUnitJar}"/>
<pathelement path="."/>
</classpath>
</javac>
</target>
<target name="testNoFork" depends="compile">
<java classname="myTest" fork="false">
<classpath>
<pathelement location="${JUnitJar}"/>
<pathelement path="." />
</classpath>
</java>
</target>
<target name="testFork" depends="compile">
<java classname="myTest" fork="true">
<classpath>
<pathelement location="${JUnitJar}"/>
<pathelement path="." />
</classpath>
</java>
</target>
<target name="test" depends="testNoFork,testFork"/>
</project>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>