Community
Participate
Working Groups
On Version: 3.0.0 Build id: 200310101454 the incremental compiler does not require me to add a 'throws' declaration when my method catches and rethrows a java.io.IOException. With the appropriate options enabled, the IDE also reports a warning when I add the 'throws' declaration that the declared IOException is not actually thrown by the method. Sun's javac flags the missing 'throws' declaration as an error. I've marked this 'major' because it compromises the integrity of compile-time verification. Here is the method: private byte[] getSomeBytes(InputStream in, long length) throws IOException { DataInputStream din = new DataInputStream(in); byte[] bytes = new byte[(int)length]; try { din.readFully(bytes); } catch (IOException ex) { MessageHandler.error(ex); // log exception throw ex; } finally { return bytes; } }
In fact this is not a problem. You really don't need the throw clause, because your method will never throw the exception even if you go in the catch block. The reason is that your finally block always returns an array of bytes and silently consume the potential IOException.
Looks like a duplicate of bug 22445.
Close as duplicate of bug 22445. *** This bug has been marked as a duplicate of 22445 ***