boolean (@NotNull String cn, JavaFileObject.Kind kind) { if (kind == Kind.OTHER && getKind() != kind) { return false; } final String n = cn + kind.extension; String name = myFile.getName(); if (name.equals(n)) { return true; } if (name.equalsIgnoreCase(n)) { // if we are on a case-insensitive file system, // try to compare against the real (exactly as on the disk) file name // try { // todo: use NIO API if available like in the commented code below //return n.equals(myFile.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS).getFileName().toString()); return n.equals(myFile.getCanonicalFile().getName()); } catch (IOException ignored) { } } return false; }