import java.io.IOException; public class Undead { static class FakeStream implements AutoCloseable { public String read() throws IOException { return "fake data"; } @Override public void close() throws IOException { throw new IOException(); } } public static void main(String[] args) { String data = null; try (FakeStream stream = new FakeStream()) { data = stream.read(); } catch (IOException e) { if (data != null) System.out.println("got " + data); // marked incorrectly as dead code } } }