Bug 23242

Summary: Bad line number info when multiple statements on same line
Product: [Eclipse Project] JDT Reporter: Bruce Sutton <sutton>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P2    
Version: 2.0   
Target Milestone: 2.1 M1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Test case to show stepping problem. none

Description Bruce Sutton CLA 2002-09-05 17:05:06 EDT
When there are two statements on the same line, e.g.
int dummy=0; while ( a < 5 ) {
the marking of the current execution line is often wrong.

Here is a sample:
public class StepBad {

	public static void main( String[] args ) {
		int a = 1;
		int dummy=0; while ( a < 5 ) {
			a = a + 1;
			if ( a < 5 ) {
				System.out.println("still less that 5");
			} else {
				System.out.println("now at 5");
			}
		}
	}
	
}

When stepping you will go into both the "then" and the "else" portions of the if 
statement each time around the while loop (except the last time around the 
loop).

This problem does not occur if the class is compiled with JDK 1.3.1.

javap -k  on the Eclipse generated code looks like this:
 Line numbers for method void main(java.lang.String[])  
   line 5: 0                                           
   line 6: 2                                           
   line 6: 4                                           
   line 7: 7                                           
   line 8: 10                                          
   line 9: 15                                          
   line 11: 26                                         
   line 14: 39                                         

javap -k  on the JDK 1.3.1 generated code looks like this:
Line numbers for method void main(java.lang.String[])   
   line 5: 0                                            
   line 6: 2                                            
   line 7: 7                                            
   line 8: 11                                           
   line 9: 16                                           
   line 11: 27                                          
   line 6: 35                                           
   line 14: 40
Comment 1 Bruce Sutton CLA 2002-09-05 17:06:34 EDT
Created attachment 1940 [details]
Test case to show stepping problem.
Comment 2 Olivier Thomann CLA 2002-09-09 14:35:00 EDT
I need to understand why we don't add the line 6: 34 at the end of the method.
This is why the stepping isn't optimal when the condition of the while loop is
executed.
Comment 3 Olivier Thomann CLA 2002-09-10 12:20:29 EDT
Fixed and released in 2.1 stream.
Comment 4 David Audel CLA 2002-09-18 09:22:35 EDT
Verified.