Bug 14933

Summary: AST: No error message generated for unreachable code
Product: [Eclipse Project] JDT Reporter: Jared Burns <jared_burns>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 M6   
Hardware: Other   
OS: other   
Whiteboard:

Description Jared Burns CLA 2002-04-30 11:52:52 EDT
Build 20020425

The following code does not return any errors when we pass it into
AST.parseCompilationUnit(char[], String, IJavaProject). It should return an
error about the unreachable code "return 2;" (as it does when this code is
compiled in a java editor).

class Hello{
static int ___run(java.lang.String[] args) throws Throwable {
return 1; return 2;
}
}
Comment 1 Olivier Thomann CLA 2002-04-30 12:13:06 EDT
I don't see how we can report this error. The "Unreachable code" is detected in the flow analysis. 
There is no flow analysis done when we convert the compiler's AST into a DOM/AST. The resolution 
doesn't imply a flow analysis.
Comment 2 Olivier Thomann CLA 2002-04-30 12:50:26 EDT
getMessages() states that it returns the list of messages reported by the compiler during the 
parsing or name resolution of this compilation unit. I will change it to specify more clearly that 
this list might be a subset of the problems returned by the compiler when the corresponding source 
is compiled.
Comment 3 Jim des Rivieres CLA 2002-04-30 21:44:29 EDT
In summary, reporting this kind of error is outside the scope of the DOM/AST.
This is the kind of error that only a full Java compiler is ever going to
give you. If you need to detect this kind of error, your only serious
option is to invoke the Java compiler.

This bug report should be rejected.