void (File file, boolean b) { System.out.println(file.getName()); if (b) { File parent = file; while (parent != null) { parent = parent.getParentFile(); } System.out.println(parent.<warning descr="Method invocation 'getName' will produce 'NullPointerException'">getName</warning>()); } System.out.println(file.getName()); }