FULL PRODUCT VERSION :
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b10)
Java HotSpot(TM) Client VM (build 25.20-b10, mixed mode)
A DESCRIPTION OF THE PROBLEM :
https://bugs.openjdk.java.net/browse/JDK-8030816
javac (8u20-ea-b10) does't crash but outputs a wrong error message when mixing a lambda expression and an inner class.
-----
//import java.awt.event.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("Test");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
frame.add(button);
frame.setSize(160, 160);
frame.setVisible(true);
});
}
}
-----
P.S. Without a lambda expression, javac (8u20-ea-b10) does't output the wrong error message.
-----
//import java.awt.event.*;
import javax.swing.*;
public class Test1 {
public static void main(String[] args) {
// SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("Test1");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("Test");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
frame.add(button);
frame.setSize(160, 160);
frame.setVisible(true);
// });
}
}
-----
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Test.java:10: error: cannot find symbol
button.addActionListener(new ActionListener() {
^
symbol: class ActionListener
location: class Test
1 error
ACTUAL -
Test.java:12: error: missing return statement
public void actionPerformed(ActionEvent e) {
^
Test.java:10: error: cannot find symbol
button.addActionListener(new ActionListener() {
^
symbol: class ActionListener
location: class Test
2 errors
REPRODUCIBILITY :
This bug can be reproduced always.