JDK-8169715 : jimage fails with IAE when attempts to inspect an empty file
  • Type: Bug
  • Component: tools
  • Sub-Component: jlink
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2016-11-15
  • Updated: 2017-07-19
  • Resolved: 2017-07-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 9
10Fixed 9Fixed
Related Reports
Relates :  
Description
In case when an empty file is specified instead of image, jimage fails with the following error message:

% jimage info empty_file

java.lang.IllegalArgumentException: newLimit > capacity: (28 > 4)
        at java.base/java.nio.Buffer.createLimitException(Buffer.java:367)
        at java.base/java.nio.Buffer.limit(Buffer.java:341)
        at java.base/java.nio.ByteBuffer.limit(ByteBuffer.java:1094)
        at java.base/java.nio.MappedByteBuffer.limit(MappedByteBuffer.java:230)
        at java.base/java.nio.MappedByteBuffer.limit(MappedByteBuffer.java:66)
        at java.base/jdk.internal.jimage.BasicImageReader.slice(BasicImageReader.java:203)
        at java.base/jdk.internal.jimage.BasicImageReader.intBuffer(BasicImageReader.java:210)
        at java.base/jdk.internal.jimage.BasicImageReader.<init>(BasicImageReader.java:147)
        at java.base/jdk.internal.jimage.BasicImageReader.open(BasicImageReader.java:173)
        at jdk.jlink/jdk.tools.jimage.JImageTask.iterate(JImageTask.java:383)
        at jdk.jlink/jdk.tools.jimage.JImageTask.run(JImageTask.java:435)
        at jdk.jlink/jdk.tools.jimage.JImageTask.run(JImageTask.java:228)
        at jdk.jlink/jdk.tools.jimage.Main.main(Main.java:34)

The issue affects all jimage commands.

Tested on the latest jigsaw and jdk 9-ea+144.

Comments
False alarm, when running some test fail in different ways, but that appears to be an issue with the tests, e.g: tools/jimage/JImageExtractTest.jtr java.io.IOException: "./JImageExtractTest8307723459751109927not_an_image" is not an image file at java.base/jdk.internal.jimage.BasicImageReader.<init>(BasicImageReader.java:148)
23-02-2017

http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-February/046327.html
13-02-2017