You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dave Brosius <da...@oracle.com> on 2023/10/26 19:05:46 UTC

ant/jdk17, and badly generated jars

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?




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: [External] : Re: ant/jdk17, and badly generated jars

Posted by Jaikiran Pai <ja...@apache.org>.
Hello Dave,

This looks like it will need some investigation and appears to be some 
genuine issue either in the build script or within Ant or maybe JDK? Is 
there a simple reproducer that you will be able to share to help 
reproduce this?

-Jaikiran

On 28/10/23 8:31 am, Dave Brosius wrote:
> java version "17.0.2" 2022-01-18 LTS
> Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
> Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, 
> sharing)
>
>
> Apache Ant(TM) version 1.10.14 compiled on August 16 2023
>
>
> Distributor ID:    Linuxmint
> Description:    Linux Mint 20.3
> Release:    20.3
> Codename:    una
>
>
> I tried debugging the ant task standalone running  against the 
> pregenerated jar, and in this case the code ran fine, It seems like i 
> only have problems when the jar is generated in the same process as 
> when i tried to load.
>
>
> --dave
>
>
>
> On 10/27/23 20:33, Jaikiran Pai wrote:
>> Hello Dave,
>>
>> In addition to what Stefan noted, could you also tell us which 
>> specific version of Java 17 this is? The output from "java -version" 
>> command would be useful.
>>
>> -Jaikiran
>>
>> On 27/10/23 11:31 pm, Stefan Bodewig wrote:
>>> Hi Dave
>>>
>>> Dave Brosius <da...@oracle.com> writes:
>>>
>>>> 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)
>>> The OpenJDK folks have been adding additional checks inside the zip
>>> package which may reject archives it has been able to read before. This
>>> has found at least one bug in Ant's zip code[1] which looks 
>>> unrelated to
>>> your exception (and has been fixed in 1.10.14).
>>>
>>> It may be the case this is another bug inside of Ant's zip package - or
>>> the added checks inside of th JDK are wrong. Any chance you could try
>>> with jdk21 (I've seen they've relaxed/adapted some checks after jdk17)?
>>>
>>> Also you may want to check the jar with a different zip tool like unzip
>>> to see whether it emits any warnings. If all else fails, it would be
>>> great if you could provide us with a jar that's been rejected so we can
>>> have a look ourselves.
>>>
>>> Cheers
>>>
>>>          Stefan
>>>
>>> [1] 
>>> https://urldefense.com/v3/__https://bz.apache.org/bugzilla/show_bug.cgi?id=66873__;!!ACWV5N9M2RV99hQ!POftHvnDa-UXJC8nyoO5MTV5pZLBUO0ElzffxPhYHLyMTGRkViNLoP0ntbXvo-RrzAppEBiBHTUT90Al92Qm$ 
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: [External] : Re: ant/jdk17, and badly generated jars

Posted by Dave Brosius <da...@oracle.com>.
java version "17.0.2" 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, 
sharing)


Apache Ant(TM) version 1.10.14 compiled on August 16 2023


Distributor ID:    Linuxmint
Description:    Linux Mint 20.3
Release:    20.3
Codename:    una


I tried debugging the ant task standalone running  against the 
pregenerated jar, and in this case the code ran fine, It seems like i 
only have problems when the jar is generated in the same process as when 
i tried to load.


--dave



On 10/27/23 20:33, Jaikiran Pai wrote:
> Hello Dave,
>
> In addition to what Stefan noted, could you also tell us which 
> specific version of Java 17 this is? The output from "java -version" 
> command would be useful.
>
> -Jaikiran
>
> On 27/10/23 11:31 pm, Stefan Bodewig wrote:
>> Hi Dave
>>
>> Dave Brosius <da...@oracle.com> writes:
>>
>>> 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)
>> The OpenJDK folks have been adding additional checks inside the zip
>> package which may reject archives it has been able to read before. This
>> has found at least one bug in Ant's zip code[1] which looks unrelated to
>> your exception (and has been fixed in 1.10.14).
>>
>> It may be the case this is another bug inside of Ant's zip package - or
>> the added checks inside of th JDK are wrong. Any chance you could try
>> with jdk21 (I've seen they've relaxed/adapted some checks after jdk17)?
>>
>> Also you may want to check the jar with a different zip tool like unzip
>> to see whether it emits any warnings. If all else fails, it would be
>> great if you could provide us with a jar that's been rejected so we can
>> have a look ourselves.
>>
>> Cheers
>>
>>          Stefan
>>
>> [1] 
>> https://urldefense.com/v3/__https://bz.apache.org/bugzilla/show_bug.cgi?id=66873__;!!ACWV5N9M2RV99hQ!POftHvnDa-UXJC8nyoO5MTV5pZLBUO0ElzffxPhYHLyMTGRkViNLoP0ntbXvo-RrzAppEBiBHTUT90Al92Qm$ 
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: ant/jdk17, and badly generated jars

Posted by Jaikiran Pai <ja...@apache.org>.
Hello Dave,

In addition to what Stefan noted, could you also tell us which specific 
version of Java 17 this is? The output from "java -version" command 
would be useful.

-Jaikiran

On 27/10/23 11:31 pm, Stefan Bodewig wrote:
> Hi Dave
>
> Dave Brosius <da...@oracle.com> writes:
>
>> 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)
> The OpenJDK folks have been adding additional checks inside the zip
> package which may reject archives it has been able to read before. This
> has found at least one bug in Ant's zip code[1] which looks unrelated to
> your exception (and has been fixed in 1.10.14).
>
> It may be the case this is another bug inside of Ant's zip package - or
> the added checks inside of th JDK are wrong. Any chance you could try
> with jdk21 (I've seen they've relaxed/adapted some checks after jdk17)?
>
> Also you may want to check the jar with a different zip tool like unzip
> to see whether it emits any warnings. If all else fails, it would be
> great if you could provide us with a jar that's been rejected so we can
> have a look ourselves.
>
> Cheers
>
>          Stefan
>
> [1] https://bz.apache.org/bugzilla/show_bug.cgi?id=66873
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: ant/jdk17, and badly generated jars

Posted by Stefan Bodewig <bo...@apache.org>.
Hi Dave

Dave Brosius <da...@oracle.com> writes:

> 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)

The OpenJDK folks have been adding additional checks inside the zip
package which may reject archives it has been able to read before. This
has found at least one bug in Ant's zip code[1] which looks unrelated to
your exception (and has been fixed in 1.10.14).

It may be the case this is another bug inside of Ant's zip package - or
the added checks inside of th JDK are wrong. Any chance you could try
with jdk21 (I've seen they've relaxed/adapted some checks after jdk17)?

Also you may want to check the jar with a different zip tool like unzip
to see whether it emits any warnings. If all else fails, it would be
great if you could provide us with a jar that's been rejected so we can
have a look ourselves.

Cheers

        Stefan

[1] https://bz.apache.org/bugzilla/show_bug.cgi?id=66873

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org