Community
Participate
Working Groups
In case an abstract method has a body, we might want to improve the error reporting. Right now we parse the code, but we don't preserve the statements inside the body. The problem is that inside the DOM/AST we don't preserve the statements. We get an empty body. There are several places that need to be updated to be able to return the statements. We might not want to resolve or analyse the statements, but we should create them. See bug 24623 and bug 51500.
For example, in this case, public class X { public abstract void foo() { System.out.println(); } } We might want to report that the method should not be abstract rather than the type should be abstract. Right now we report: ---------- 1. ERROR in C:\tests_sources\X.java (at line 2) public abstract void foo() { ^^^^^ The abstract method foo in type X can only be defined by an abstract class ---------- 2. ERROR in C:\tests_sources\X.java (at line 2) public abstract void foo() { ^^^^^ Abstract methods do not specify a body ---------- 2 problems (2 errors)
Sounds a fair change. The error message is somewhat counter-intuitive. If the user went through the effort of adding statements to the method, it is very likely that the modifier is bogus.
Actually. I take my previous comment back. The message is ok, since when changing it as proposed, it would become inconsistent with the message flagging presence of abstract method on non abstract type. Won't fix. Also see comment in bug 24623 for addressing the lack of statements in this case.