0

Having some trouble with ant build scripts (the project and code is not written by me, I am trying to do some third party library debugging which requires building this project). I'm trying to see if I can get to the bottom of the ant script errors. I do this by trying to compile a single java class using the arguments retrieved from the debugged ant script, which is currently failing. The errors on compiling a single class match when the failing ant script is run. When the file is compiled without the -d flag (which specifies where to place the generated class files), the compilation is successful and the class files are generated. e.g.:

javac -classpath C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\build\classes1.5;C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\build\tests;C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\lib\junit4.4\junit-4.4.jar;C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\lib\hyperic-sigar-1.6.3\sigar.jar -sourcepath C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5 C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java -g -O

It is also successful when -d is pointing to a folder that doesn't exist (it will be newly created, and the class files will go there). e.g.

javac -classpath C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\build\classes1.5;C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\build\tests;C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\lib\junit4.4\junit-4.4.jar;C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\lib\hyperic-sigar-1.6.3\sigar.jar -sourcepath C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5 C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java -g -O -d C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\build\classes1.555test

However, when it is specified to a folder which is also included in the class path

javac -classpath C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\build\classes1.5;C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\build\tests;C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\lib\junit4.4\junit-4.4.jar;C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\lib\hyperic-sigar-1.6.3\sigar.jar -sourcepath C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5 C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java -g -O -d C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\build\classes1.5

I get a whole lot of errors, which suggests the classpaths are now being ignored. Can anyone shed some light as to what might be going on? The errors are as follows:

C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:21: error: package junit.framework does not exist
import junit.framework.TestCase;
                      ^
C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:46: error: cannot find symbol
public class TestUtils extends TestCase {
                               ^
  symbol: class TestCase
C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:772: error: cannot find symbol
                assertNotNull(errbuf.toString());
                ^
  symbol:   method assertNotNull(String)
  location: class TestUtils
C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:803: error: cannot find symbol
                                                assertNotNull(packet);
                                                ^
  symbol: method assertNotNull(PcapPacket)
C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:876: error: cannot find symbol
                        assertNotNull(errbuf.toString(), pcap);
                        ^
  symbol:   method assertNotNull(String,Pcap)
  location: class TestUtils
C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:1013: error: cannot find symbol
                        fail(errbuf.toString());
                        ^
  symbol:   method fail(String)
  location: class TestUtils
C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:1067: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:1073: error: cannot find symbol
                super.setUp();
                ^
  symbol:   variable super
  location: class TestUtils
C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:1080: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java:1085: error: cannot find symbol
                super.tearDown();
                ^
  symbol:   variable super
  location: class TestUtils
Note: C:\Users\xxx\IdeaProjects\jnetpcap-code\jnetpcap\branches\branch-1.5-dev\tests\java1.5\org\jnetpcap\packet\TestUtils.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
10 errors```

1 Answers1

1

I think it's a pathological case that shouldn't exist (and theoretically shouldn't work) - there may have been an error in the original build.xml script by the authors. I'm not 100% sure about this because the build.xml has been the same for all versions of their releases over the last decade, the repository is no longer active, and no previous issue regarding this has been raised, so I don't know how it was ever built using this script. The modification I made is as follows (commented out is original, with its replacement below):

<target name="comp-test" depends="prep-test,comp-java,comp-jni">

<!--   <javac includeantruntime="false" srcdir="${test.dir}" destdir="${build.classes.dir}1.5" debug="${compiler.debug}" deprecation="${compiler.deprecate}" optimize="${compiler.optimize}" classpathref="test.classpath" /> -->

<javac includeantruntime="false" srcdir="${test.dir}" destdir="${build.tests.dir}" debug="${compiler.debug}" deprecation="${compiler.deprecate}" optimize="${compiler.optimize}" classpathref="test.classpath" />

</target>