[kaffe] java.io.File#isDirectory() and symbolic links

Ito Kazumitsu kaz at maczuka.gcd.org
Sat Dec 25 18:07:12 PST 2004


I am afraid java.io.File#isDirectory()'s behavior of handling
symbolic links is not the same as before.  I do not know
which is correct, but the problem is I have an application
system which depends on the old behavior.

Test Program:

import java.io.*;

public class TestDirectory {
    public static void main(String[] args) throws Exception {
        String _filename = args[0];
        File file=new File(_filename);
        File dir= new File(file.getParent());
        System.out.println("file=" + file + " dir=" + dir);
        if (!dir.isDirectory())
            throw new IOException("not a directory: "+dir);

bash$ ls -lR /tmp/test0 /tmp/test1
total 4
drwxr-xr-x  2 kaz kaz 4096 Dec 26 10:19 a

total 0

total 0
lrwxr-xr-x  1 kaz kaz 12 Dec 26 10:20 a -> /tmp/test0/a


bash$ /usr/local/kaffe/bin/kaffe -fullversion                
  ChangeLog head   : 2004-10-08  Dalibor Topic  <robilad at kaffe.org>
bash$ /usr/local/kaffe/bin/kaffe TestDirectory /tmp/test1/a/z
file=/tmp/test1/a/z dir=/tmp/test1/a


bash$ ~/work/kaffe-inst/bin/kaffe -fullversion
  ChangeLog head   : 2004-12-22  Guilhem Lavaux  <guilhem at kaffe.org>
bash$ ~/work/kaffe-inst/bin/kaffe TestDirectory /tmp/test1/a/z
file=/tmp/test1/a/z dir=/tmp/test1/a
java.io.IOException: not a directory: /tmp/test1/a
   at TestDirectory.main (TestDirectory.java:10)

More information about the kaffe mailing list