You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Gregory Williams (Jira)" <ji...@apache.org> on 2021/11/28 22:24:00 UTC
[jira] [Updated] (NETBEANS-3802) Hint suggests invalid replacement with lambda for implementations of interfaces with only default methods
[ https://issues.apache.org/jira/browse/NETBEANS-3802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gregory Williams updated NETBEANS-3802:
---------------------------------------
Affects Version/s: 12.5
> Hint suggests invalid replacement with lambda for implementations of interfaces with only default methods
> ---------------------------------------------------------------------------------------------------------
>
> Key: NETBEANS-3802
> URL: https://issues.apache.org/jira/browse/NETBEANS-3802
> Project: NetBeans
> Issue Type: Bug
> Components: java - Hints
> Affects Versions: 11.2, 12.5
> Environment: JDK 13
> Reporter: dennis lucero
> Priority: Minor
> Labels: hints
>
> {code:java}
> interface Dog {
> default void run() {
> }
> default void bark() {
> }
> }
> public static void foo() {
> final Dog dog = new Dog() {
> @Override
> public void bark() {
> System.out.println("Woof");
> }
> };
> }
> {code}
> For this code NetBeans has a hint stating
> {quote}This anonymous inner class creation can be turned into a lambda expression.
> {quote}
> in the line with {{new Dog()}}. Replacing the code using the hint results in
> {code:java}
> final Dog dog = () -> {
> System.out.println("Woof");
> };
> {code}
> which is invalid code
> {quote}incompatible types: Dog is not a functional interface
> no abstract method found in interface Dog
> {quote}
> (Real world example: http://jdbi.org/apidocs/org/jdbi/v3/core/statement/SqlLogger.html This style of interfaces would also be a nice alternative to Swing’s {{*Listener}}/{{*Adapter}} pairs.)
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists