JarFile constructor throws undocumented exception (only) on Windows OS
Jaikiran Pai
jai.forums2013 at gmail.com
Fri Oct 5 10:54:18 UTC 2018
Hello Alan,
On 05/10/18 4:15 PM, Alan Bateman wrote:
> On 04/10/2018 10:36, Jaikiran Pai wrote:
>> :
>>
>>
>> The javadoc of JarFile constructor(s) mentions that:
>>
>> * @throws IOException if an I/O error has occurred
>>
>> Given that the javadoc doesn't mention anything about this other
>> exception, would this throwing of java.nio.file.InvalidPathException be
>> considered a bug in the implementation?
>>
> Yes, it's a bug in the ZipFile code as it's not specified to throw
> this unchecked exception. Note that the issue is not specific to
> Windows, you'll see the same thing on Linux/other with other garbage
> input - a good example to try is a path string with NUL characters.
You are right indeed. Changing that sample code to something like:
final JarFile jarFile = new JarFile(tmpDir + File.separator + "abc\0xyz");
does indeed end up throwing a java.nio.file.InvalidPathException even on
*nix, on Java 11.
I don't have access to create an issue for this in OpenJDK JIRA, so I'll
go ahead and create one at bugs.java.com.
-Jaikiran
More information about the core-libs-dev
mailing list