// Note: We can't use file.exists() to check whether the symlink
// exists or not, because that method returns false for existing
// but broken symlink. So, we try without the existence check,
// but in the try-catch block.
// MRI behavior: symlink? on broken symlink should return true.
FileStat stat = fileResource(filename).lstat();
return runtime.newBoolean(stat != null && stat.isSymlink());
} catch (SecurityException re) {
return runtime.getFalse();
} catch (RaiseException re) {
runtime.getGlobalVariables().set("$!", oldExc);
return runtime.getFalse();