Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352785

Summary: [extract method] Refactor > Extract Method with break statement in switch causes NPE
Product: [Eclipse Project] JDT Reporter: Shawn Lauzon <s_lauzon>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, daniel_megert
Version: 3.6   
Target Milestone: 3.8 M7   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Stack dump none

Description Shawn Lauzon CLA 2011-07-21 12:57:27 EDT
Build Identifier: 20110615-0604

If I attempt to Refactor > Extract Method which includes a break statement inside a switch, an unexpected exception occurs, which is an NPE (will attach stack later).

It should give an error which says something like you can't refactor a method which includes multiple exit points, or something like that.





Reproducible: Always

Steps to Reproduce:
1. Write some code:
   public void foo(int i) {

    	switch (i) {
    	case 1:
         	if (true) {
        		break;
        	}
    	}
} 

2. Highlight the some code within the case 1 statement.

3. Choose Refactor > Extract Method
Comment 1 Shawn Lauzon CLA 2011-07-21 12:58:56 EDT
Created attachment 200107 [details]
Stack dump
Comment 2 Ayushman Jain CLA 2011-07-21 13:01:37 EDT
Moving to JDT/UI
Comment 3 Dani Megert CLA 2011-07-22 02:29:14 EDT
Used to work but got broken during 3.6.