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 258981 - Allow to return default methods as unimplemented
Summary: Allow to return default methods as unimplemented
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks: 256798 258804
  Show dependency tree
 
Reported: 2016-04-23 07:02 UTC by Svata Dedic
Modified: 2016-05-16 07:28 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed changes (10.73 KB, patch)
2016-04-23 07:02 UTC, Svata Dedic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Svata Dedic 2016-04-23 07:02:44 UTC
Created attachment 159404 [details]
Proposed changes

Because of defect #256798 and related it seems better that ElementUtilities.findUnimplementedMethods() does *not* return default methods from interfaces, as they are not strictly speaking needed in order to complete the implementing class. At the same time findOverridableMethods should return those defaults for override.

In some cases, however, it is desirable that findUnimplementedMethods return ALSO the default ones, so I want to add a parametrized variant.

See the attachment for the proposed changes.

I don't have strict use-case, but saw already code which could be argument for additional changes, but I don't want to extend the API speculatively:

* flag to NOT return defaults among overridable methods
* flag to NOT return methods, whose signatures would conflict with existing methods in the class (for both overridable and implementable methods) OR utility function to find methods which are in such signature conflict from among a given list:
i.e. "implement methods" should not offer "int foo()" if "float foo()" already exists in the class, or it could handle it somehow specially
Comment 1 Jaroslav Tulach 2016-04-24 12:21:17 UTC
Y01 Typo "bud include"
Y02 The API changes talk about "findOverridableMethods", but in the diff I see just findUnimplementedMethods with new parameter - the parameter is better, but possibly there is an inconsistency.
Comment 2 Svata Dedic 2016-04-25 08:05:37 UTC
Y02: findOverridableMethod's behaviour changes; it used to ignore default methods in implemented interfaces. As for the missing parameter -- as I write in initial description, I don't have a strict use-case to return just superclass' overridable methods, but I have no strong opinion in neither direction. 
If the inability to ignore default methods is seen as a deficiency, I'll add a parametrized variant.

Note that the default forms should probably each treat default methods differently: findUnimplementedMethods shoud NOT return them, since they are not required to implement for class completion, while findOverridableMethods SHOULD return them as their implementation is available for customization/change/override.
Comment 3 Svata Dedic 2016-05-05 15:13:46 UTC
If no further objection is raised, I'll commit the patch tomorrow.
Comment 4 Jaroslav Tulach 2016-05-16 07:01:14 UTC
I am OK with the change.
Comment 5 Svata Dedic 2016-05-16 07:28:53 UTC
Already pushed as http://hg.netbeans.org/jet-main/rev/486a20322671, but because of bugzilla outage, the notification was not added. It took a little longer, since I disovered other long standing issues with override/implements.