Ouch. That is unfortunate that File cannot reject bad input.

Perhaps FileInputStream etc. should throw a specialized "Bad Filename" FnF for 
paths containing NUL if the underlying filesystem does not support NUL?

Masking garbage input always really scares me.

Mike

On Feb 27 2013, at 02:40 , Alan Bateman wrote:

> On 27/02/2013 02:31, Dan Xu wrote:
>> Thank you, Mike.
>> 
>> The reason not to throw out an exception is for the backward compatibility. 
>> Due to that, the constructorof File object with NUL willnever fail.While in 
>> NIO, it is defined in the spec to throw out exceptions when invalid NUL 
>> character is found.
>> 
>> -Dan
> Right, we can't change the constructor to throw an exception, particularly if 
> this fix is going to be back-ported to 7u. For NIO then it's not an issue 
> because getPath was specified from the begining to throw the unexpected 
> InvalidPathException when it is given garbage.
> 
> -Alan.

Reply via email to