This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 133538

Summary: "Add throws"-hint, when implementing a constructor, which throws an exception
Product: java Reporter: liono <liono>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: REOPENED ---    
Severity: blocker CC: markiewb
Priority: P4    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Shows the issue

Description liono 2008-04-21 21:17:13 UTC
First: The only reason why I marked this issue as a "defect" is because this behavior used to be different on version
5.5.1 and as such I suspect it to be a bug.

When extending a class which constructor throws an Exception you will get an error message (bulb) if the extending
class' constructor does not report the throwing of the exception. When pressing alt-enter you'll get an error telling
you "unreported exception <exception>; must be caught or declared to be thrown" (where <exception> is of course the
thrown exception). Previously this also presented an auto-fix to declare the exception ("Add throws clause").

So, testcase:

public class superclass {
  public superclass() throws Exception {
    throw new Exception("Testing purposes!");
  }
}

public class testclass extends superclass {
  public testclass() {      // The error bulb will appear here
  }
}


Note that as soon as you add "super();" to the constructor of the testclass things will once again behave as expected;
now the error appears on the line which contains "super();" and it will present the option to add the throws clause for you.

This behavior doesn't change with the addition of modules; I have tested it on a pristine 6.1rc2 SE installation with
and without extra modules.
Comment 1 Jiri Prox 2008-04-22 08:45:06 UTC
reproducible
Comment 2 Jan Becicka 2008-05-15 13:23:44 UTC
Max volunteered :)
Comment 3 Max Sauer 2008-11-24 15:01:24 UTC
The 'Add Throws..' should be definitely available.
Comment 4 Martin Balin 2016-07-07 07:18:30 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 5 markiewb 2016-07-10 17:37:39 UTC
Created attachment 160335 [details]
Shows the issue

Still valid in 8.2 dev 
Product Version: NetBeans IDE Dev (Build 201607100002)