NamedAttributeView#size(null) does not throw NPE(win)

Rajendra Gutupalli Rajendra.Gutupalli at Sun.COM
Tue Jun 10 05:13:04 PDT 2008


Hi Alan,

When we pass null argument to the methods 
NamedAttributeView#(size,read,write)() , it does not throw 
NullPointerException. It happens only in Windows environment. It works 
fine in Linux and Solaris.
Please see the following result and test program tried in Windows XP.
 
<result>
Exception in thread "main" java.nio.file.NoSuchFileException: 
C:\testfile:null
        at 
sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
        at 
sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:90)
        at 
sun.nio.fs.WindowsNamedAttributeView.size(WindowsNamedAttributeView.java:197)
        at newTests.NamedTest2.main(NamedTest2.java:19)
</result>

<code>
import java.nio.file.*;
import java.nio.file.attribute.*;

public class NamedTest2 {

    public static void main(String... args) throws Exception {
        Path path = Path.get("C:\\testfile");
        NamedAttributeView nav = 
path.newFileAttributeView(NamedAttributeView.class, false);
        System.out.println(nav.size(null));
    }
}
</code>

Thanks
Rajendra.




More information about the nio-dev mailing list