Closed cxbrooks closed 2 years ago
The reason this did not show up in the build is that Travis Xenial (Ubuntu 16.x) uses ant:
Apache Ant(TM) version 1.9.6 compiled on July 20 2018
This issue prevents upgrading to Ubuntu 20.x because under 20.x we are running
Apache Ant(TM) version 1.10.7 compiled on October 24 2019
So, it is possible to edit kepler-build/build-area/src/org/kepler/build/project/CompileClasspath.java and add code like
FileSet fileSet = new FileSet();
String[] includes = {"*.jar"};
fileSet.setDir(file);
fileSet.appendIncludes(includes);
jarPath.addFileset(fileSet);
in two places and for the build to work with
bash-3.2$ ant -version
Apache Ant(TM) version 1.10.7 compiled on September 1 2019
bash-3.2$ java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
bash-3.2$
However, CompileClasspath.java says:
// use wildcards to reduce the size of the classpath.
// this gets around the maximum path length on windows.
So, adding each jar file will probably break the build under Windows.
See junit: pathelement with wildcard fails running on java 11 - InvalidPathException: Illegal char <*> which discusses a possible fix in Java 12
However, compiling with
openjdk version "12.0.2" 2019-07-16
does not seem to have this fix, nor does
java 14.0.2 2020-07-14
It looks like the issue is that ant needs to fork the javac process?
The summary is that it appears that javac does not properly handle wildcards in the classpath if the arguments are specified in a @argfile
If I have a BatikTest.java file that contains:
import org.apache.batik.swing.svg.JSVGComponent;
public class BatikTest {
public static void main(String[] args) {
System.out.print(System.getProperty("java.version"));
}
}
and a batik-all-1.6.jar file that defines org.apache.batik.swing.svg.JSVGComponent:
bash-3.2$ ls lib/jar/
batik-all-1.6.jar
bash-3.2$
Then running from the command line works:
bash-3.2$ rm *.class; javac -verbose -classpath 'lib/jar/*:.' BatikTest.java
rm: *.class: No such file or directory
[parsing started SimpleFileObject[/Users/cxh/src/kepler-build/ptolemy/test/BatikTest.java]]
[parsing completed 22ms]
[loading /modules/jdk.crypto.cryptoki/module-info.class]
[loading /modules/jdk.localedata/module-info.class]
[loading /modules/jdk.jdi/module-info.class]
[loading /modules/jdk.internal.ed/module-info.class]
...
[search path for source files: lib/jar/batik-all-1.6.jar,.]
[search path for class files: /Library/Java/JavaVirtualMachines/openjdk/jdk-11.0.11+9/Contents/Home/lib/modules,lib/jar/batik-all-1.6.jar,.]
[loading /Users/cxh/src/kepler-build/ptolemy/test/lib/jar/batik-all-1.6.jar(/org/apache/batik/swing/svg/JSVGComponent.class)]
...
[wrote BatikTest.class]
[total 395ms]
bash-3.2$
However, using a @argfile to pass arguments does not work, note that the verbose output of javac does not include lib/jar/batik-all-1.6.jar:
bash-3.2$ cat argfile.txt
-verbose
-classpath
lib/jar/*:.
BatikTest.java
bash-3.2$ rm *.class; javac @argfile.txt
rm: *.class: No such file or directory
[parsing started SimpleFileObject[/Users/cxh/src/kepler-build/ptolemy/test/BatikTest.java]]
[parsing completed 20ms]
[loading /modules/jdk.jlink/module-info.class]
[loading /modules/jdk.jartool/module-info.class]
[loading /modules/java.net.http/module-info.class]
[loading /modules/jdk.scripting.nashorn.shell/module-info.class]
[loading /modules/java.naming/module-info.class]
...
[search path for source files: lib/jar/*,.]
[search path for class files: /Library/Java/JavaVirtualMachines/openjdk/jdk-11.0.11+9/Contents/Home/lib/modules,lib/jar/*,.]
BatikTest.java:3: error: package org.apache.batik.swing.svg does not exist
import org.apache.batik.swing.svg.JSVGComponent;
^
[loading /modules/java.base/java/lang/Object.class]
[total 279ms]
1 error
bash-3.2$
So, the fix is to modify build-area/src/org/kepler/build/project/CompileClasspath.java to expand the *. This might cause problems with Windows, but as ant presumably uses @argfile, then perhaps this won't be a problem.
https://ant.apache.org/manual/Tasks/javac.html says:
tempdir | Where Ant should place temporary files. This is only used if the task is forked and the command line args length exceeds 4 kB. Since Ant 1.6.
Fixed! I needed to recompile kepler-tasks.jar with JDK 1.8 so that the JDK 9 build would work. The commands were:
cd kepler-build/build-area/
ant -f kepler-tasks.xml rejar
svn commit -m "Recompiled kepler-tasks.jar under JDK 1.8." ../kepler-tasks/lib/jar/kepler-tasks.jar target/kepler-tasks.jar
Kepler now compiles with Ubuntu 20.x (focal).
When running
ant compile
under JDK 8, batik was missing:Running
ant -d compile
It turns out to be a problem with ant.
Ant 1.10.7 fails with the above message
The version of ant included in Ptolemy II works:
See also