Bug 23242 - Bad line number info when multiple statements on same line
Summary: Bad line number info when multiple statements on same line
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: 2.1 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-05 17:05 EDT by Bruce Sutton CLA
Modified: 2002-09-18 09:22 EDT (History)
0 users

See Also:


Attachments
Test case to show stepping problem. (256 bytes, text/plain)
2002-09-05 17:06 EDT, Bruce Sutton CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.