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 - "Add throws"-hint, when implementing a constructor, which throws an exception
Summary: "Add throws"-hint, when implementing a constructor, which throws an exception
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: Svata Dedic
Depends on:
Reported: 2008-04-21 21:17 UTC by liono
Modified: 2016-07-10 17:38 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

Shows the issue (14.25 KB, image/png)
2016-07-10 17:37 UTC, markiewb

Note You need to log in before you can comment on or make changes to this bug.
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
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)