Bug 59979 - Improve error reporting for abstract method with a body
Summary: Improve error reporting for abstract method with a body
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-26 13:11 EDT by Olivier Thomann CLA
Modified: 2004-05-10 09:57 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2004-04-26 13:11:41 EDT
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.
Comment 1 Olivier Thomann CLA 2004-04-26 13:14:14 EDT
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)
Comment 2 Philipe Mulet CLA 2004-04-28 06:25:25 EDT
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.
Comment 3 Philipe Mulet CLA 2004-05-10 09:57:40 EDT
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.