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.
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
Created attachment 155295 [details] IDE log
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.
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.
Created attachment 155670 [details] java file
Created attachment 155671 [details] form file
What is the supertype of the MessageException ?
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 ?
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.
It is not a RTE, thats why I was waiting for the hint and found the bug
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