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 254309 - hints missing: add throw clause to...
Summary: hints missing: add throw clause to...
Status: RESOLVED INCOMPLETE
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-12 13:28 UTC by FiruzzZ
Modified: 2015-09-04 12:15 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (55.34 KB, text/plain)
2015-08-12 13:28 UTC, FiruzzZ
Details
java file (31.10 KB, application/octet-stream)
2015-08-26 17:57 UTC, FiruzzZ
Details
form file (22.84 KB, application/octet-stream)
2015-08-26 17:57 UTC, FiruzzZ
Details

Note You need to log in before you can comment on or make changes to this bug.
Description FiruzzZ 2015-08-12 13:28:02 UTC
I have this method: 
private void validateData(BigDecimal a811, BigDecimal a812, BigDecimal a814, BigDecimal a816, BigDecimal fondoJub, BigDecimal aMutual) throws IllegalArgumentException {
        if (a811.add(a812).add(a814).add(a816).add(fondoJub).compareTo(BigDecimal.ZERO) > 0) {
                throw new IllegalArgumentException("Debe ingregar fecha de período Desde Sindical");
        }
       if( something... ) {
             //HERE is where I just get the suggestion of surrouding and not "add throws"
	throw new MessageException(".....");
          }
}

Product Version = NetBeans IDE 8.1 Beta (Build 201508041349)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.8.0_51
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.51-b03
Comment 1 FiruzzZ 2015-08-12 13:28:08 UTC
Created attachment 155295 [details]
IDE log
Comment 2 Svata Dedic 2015-08-26 13:18:08 UTC
I can't reproduce the defect EXCEPT the situation where the method actually overrides something from a superclass/superinterface.

The method in your example is private, but please check if this is actually not your case. The 'add throws' fix explicitly checks and does not suggest to add throws for types not declared by the overriden contract.
Comment 3 FiruzzZ 2015-08-26 17:56:03 UTC
validateData(...) is a local method, not inherited, it is on a JDialog created from the IDE.
I tried changing to public, removing all the throws and see if there is any other suggestion but no, I had to added them manually, I will attach the files.
Comment 4 FiruzzZ 2015-08-26 17:57:26 UTC
Created attachment 155670 [details]
java file
Comment 5 FiruzzZ 2015-08-26 17:57:44 UTC
Created attachment 155671 [details]
form file
Comment 6 Svata Dedic 2015-08-27 07:18:41 UTC
What is the supertype of the MessageException ?
Comment 7 Svata Dedic 2015-08-27 07:37:19 UTC
Additional questions:
* is the throw new MessageException() red-underlined as an error ?
* where does the 'surrounding' hint appear - is the throw statement yellow-wawe underlined to indicate the suggestion, or do you have first to select the statement text - and then many surround-with options appear on Alt-Enter ?
Comment 8 Svata Dedic 2015-09-04 08:07:59 UTC
Suspending until further info. With the attached text, I was able to reproduce something similar only when I selected the throw new expression when MessageException was NOT a RuntimeException subclass; "add throws" appeared first in that case. This is a different kind of popup, which combines hints (and error corrections) with other suggestions.
If MessageException is a RTE subclass, it naturally does not need to be declared in method signature, so this hint does not appear. If you feel the hint could be a suggestion, to add exception at caret to the throws clause, then please reopen as enhancement.
Comment 9 FiruzzZ 2015-09-04 09:37:37 UTC
It is not a RTE, thats why I was waiting for the hint and found the bug
Comment 10 Svata Dedic 2015-09-04 12:15:38 UTC
OK, so something is still missing from the picture. Is the MessageException compilable (= its supertype is resolvable) ? I've created my own exception class so it may differ from your definition