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 248744 - Incorrect hint: Overridable method call in constructor
Summary: Incorrect hint: Overridable method call in constructor
Status: RESOLVED DUPLICATE of bug 254526
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-19 09:30 UTC by _ gtzabari
Modified: 2015-09-15 14:40 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2014-11-19 09:30:34 UTC
Product Version: NetBeans IDE 8.0.1 (Build 201408251540)
Updates: NetBeans IDE is updated to version NetBeans 8.0.1 Patch 1.1
Java: 1.8.0_25; Java HotSpot(TM) 64-Bit Server VM 25.25-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_25-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\8.0.1
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\8.0.1

Given:
DefaultRequestScope()
{
	this.queryDslConfiguration = LazyReference.create(() ->
	{
		SQLTemplates dialect = new PostgresTemplates();
		Configuration result = new Configuration(dialect);
		if (parent.getRunMode() == RunMode.DEBUG)
		{
			DebugLockMonitor debugLockMonitor = (DebugLockMonitor) getLockMonitor();
			result.addListener(debugLockMonitor);
		}
		return result;
	});
}

where getLockMonitor() is a non-final method in a non-final class.

I believe the hint is wrong because the lambda function is not invoked by the constructor. The lambda is passed into a method that constructs an anonymous class that invokes the lambda. See https://bitbucket.org/cowwoc/pouch/src/26a1127f6a4bbafe08706d5abff7dd5ebb916301/src/main/java/org/bitbucket/cowwoc/pouch/LazyReference.java?at=default#cl-32 for the implementation in question.

Expected behavior: the editor should not display this warning for lamda functions, unless it can prove that they are invoked by the constructor.
Comment 1 err 2015-06-18 02:04:07 UTC
Maybe whatever technique prevents "leaking this in constructor", when 'this' is used in a lambda in a constructor, would also work for this bug.
Comment 2 Svata Dedic 2015-09-15 14:40:29 UTC

*** This bug has been marked as a duplicate of bug 254526 ***