Note that there are some explanatory texts on larger screens.

plurals
  1. POUnreported exceptions in Netbeans: some are, other not
    primarykey
    data
    text
    <p>I'm using the IDE <strong>Netbeans7.3</strong> to develop in <strong>Java</strong>. There is something strange that I cannot explain to myself, so please, help me to understand.</p> <p>I declared to classes. The first inherits from <code>Exception</code>:</p> <pre><code>public class MyParameterException extends Exception{ public MyParameterException(){ super(); } public MyParameterException(String message){ super(message); } } </code></pre> <p>and the second inherits from NullPointerException:</p> <pre><code>public class NullMyParameterException extends NullPointerException{ public NullMyParameterException(){ super(); } public NullMyParameterException(String message){ super(message); } } </code></pre> <p>Now, when I create a method in a class and I write:</p> <pre><code>public void test(String s){ if(s==null) throw new NullMyParameterException("The input string is null."); if(s.trim().isEmpty()) throw new MyParameterException("The input string is empty."); } </code></pre> <p>What seems strange to me is that I get the message <code>unreported exception MyParameterException must be caught or declared to be thrown</code> from the IDE, but nothing is said about the first exception that I could throw in the method.</p> <p>To my knowledge, the method would expected to be declared as follows:</p> <pre><code>public void test(String str) throws MyNullParameterException, MyParameterException </code></pre> <p>but for Netbeans only sufficies:</p> <pre><code>public void test(String str) throws MyParameterException </code></pre> <p>Is this: </p> <ul> <li>An IDE bug.</li> <li>Normal because classes that inherits from <code>NullPointerException</code> are special.</li> <li>...</li> </ul> <p>Please, let me understand.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload