-
Bug
-
Resolution: Fixed
-
P4
-
8
JLS 15.1 has always said: "An expression denotes nothing if and only if it is a method invocation (§15.12) that invokes a method that does not return a value, that is, a method declared void (§8.4). Such an expression can be used only as an expression statement (§14.8), because every other context in which an expression can appear requires the expression to denote something."
The second sentence is wrong with the advent of lambda expressions. A lambda expression's body may contain a void expression without the void expression being used as an expression statement. The following lambda body has no semicolons, hence no expression statements, yet the void expression is legal as the body:
x.m(e -> System.out.println("hi"));
The second sentence is wrong with the advent of lambda expressions. A lambda expression's body may contain a void expression without the void expression being used as an expression statement. The following lambda body has no semicolons, hence no expression statements, yet the void expression is legal as the body:
x.m(e -> System.out.println("hi"));