ant/jdk17, and badly generated jars

Dave Brosius <[email protected]> Thu, 26 Oct 2023 15:05:46 -0400
Newsgroups gmane.comp.jakarta.ant.user
Message-ID <[email protected]>
HI folks, we have an odd situation where we have an ant build that 
generates a jar file that includes a resource bundle property file using 
<jar>, later in the same build  a custom ant task is executed, which 
loads that class from  the classpath, and tries to read that bundle 
file, and fails  with

[genSchema] Caused by: java.util.zip.ZipException: ZipFile invalid LOC 
header (bad signature)
[genSchema]     at 
java.util.zip.ZipFile$ZipFileInputStream.initDataOffset(ZipFile.java:920) 
~[?:?]
[genSchema]     at 
java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:931) ~[?:?]
[genSchema]     at 
java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:448) 
~[?:?]
[genSchema]     at 
java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) ~[?:?]
[genSchema]     at 
java.io.FilterInputStream.read(FilterInputStream.java:132) ~[?:?]
[genSchema]     at 
sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:270) ~[?:?]
[genSchema]     at 
sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:313) ~[?:?]
[genSchema]     at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:188) 
~[?:?]
[genSchema]     at 
java.io.InputStreamReader.read(InputStreamReader.java:177) ~[?:?]
[genSchema]     at java.io.Reader.read(Reader.java:250) ~[?:?]
[genSchema]     at 
java.util.Properties$LineReader.readLine(Properties.java:504) ~[?:?]
[genSchema]     at java.util.Properties.load0(Properties.java:419) ~[?:?]
[genSchema]     at java.util.Properties.load(Properties.java:382) ~[?:?]
[genSchema]     at 
java.util.PropertyResourceBundle.<init>(PropertyResourceBundle.java:200) 
~[?:?]


My guess was, for some reason that jar file wasn't completely written 
and/or closed by the time the custom task is run. To test, before 
running  the custom test, i do this

             <copy file="${snapshots.dir}/opc-i18n.jar" 
tofile="${snapshots.dir}/opc-i18nX.jar"/>
             <copy file="${snapshots.dir}/opc-i18nX.jar" 
tofile="${snapshots.dir}/opc-i18n.jar"/>

both copies seem to go fine, kind of ruling out the open part. and when 
i manually open the copied jar after the build, it seems fine (no bad 
LOC header from ui tools). [btw, the original file loads fine  in ui 
tools too]

If i run the section that  uses the jar, without the script that 
generates the jar, it works fine.

No use of <parallel> is used.

Anyone have  any ideas what could be  going on? Or how  to  debug more?