You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "dennis lucero (Jira)" <ji...@apache.org> on 2020/02/06 16:30:00 UTC
[jira] [Created] (NETBEANS-3802) Hint suggests invalid replacement
with lambda for implementations of interfaces with only default methods
dennis lucero created NETBEANS-3802:
---------------------------------------
Summary: 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
Environment: JDK 13
Reporter: dennis lucero
{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.3.4#803005)
---------------------------------------------------------------------
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