We are moving from IBM JDK 8 to Open JDK 11. Our build is using ANT 1.7.0 currently, and I am getting below error when I build project with OpenJDK 11 using ant 1.7.0
/home/devs/sbx/sand1_7000_db1/perimeter/build.xml:83: java.lang.ClassFormatError: Invalid Constant Pool entry Type 18
Total time: 3 seconds
So, I suppose that due to the incompatibility of ANT with JDK 11. Please help me to know which ANT version supports open JDK 11 and open JDK 17.
Here is what is there in the line 83 of build.xml,
<!-- *********************************************************** -->
<!-- Custom Targets -->
<!-- *********************************************************** -->
<target name="checkDependencies" depends="validate">
<depend srcDir="${clump.root.dir}/product/isolatedSrc:${clump.root.dir}/build/product/classes"
destdir="${clump.root.dir}/build/product/classes"
cache="depcache.product"
closure="yes">
</depend>
</target>
Here is the error in -debug mode,
checkDependencies: [depend] Adding class info for com.sterlingcommerce.perimeter.VersionInfo
BUILD FAILED /home/devs/sbx/sand1_7000_db1/perimeter/build.xml:83: java.lang.ClassFormatError: Invalid Constant Pool entry Type 18 at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:115) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329) at org.apache.tools.ant.Project.executeTarget(Project.java:1298) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1181) at org.apache.tools.ant.Main.runBuild(Main.java:698) at org.apache.tools.ant.Main.startAnt(Main.java:199) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Caused by: java.lang.ClassFormatError: Invalid Constant Pool entry Type 18 at org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantPoolEntry.readEntry(ConstantPoolEntry.java:159) at org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantPool.read(ConstantPool.java:67) at org.apache.tools.ant.taskdefs.optional.depend.ClassFile.read(ClassFile.java:72) at org.apache.tools.ant.taskdefs.optional.depend.AntAnalyzer.determineDependencies(AntAnalyzer.java:91) at org.apache.tools.ant.util.depend.AbstractAnalyzer.getClassDependencies(AbstractAnalyzer.java:99) at org.apache.tools.ant.taskdefs.optional.depend.Depend.determineDependencies(Depend.java:344) at org.apache.tools.ant.taskdefs.optional.depend.Depend.execute(Depend.java:689) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105) ... 11 more
Thanks Dev
The exception ClassFormatError: Invalid Constant Pool entry Type 18
occured because the Depend task in the version of Ant you used didn't know how to handle the Invoke Dynamic bytecode instruction. This issue was fixed in Ant 1.9.0:
https://github.com/apache/ant/commit/b103f7e3
You may get other issues with OpenJDK 11/17 though, the best is to simply use the latest version of Ant.