Project: JDT
Bug 352785 [extract method] Refactor > Extract Method with break statement in switch causes NPE
Reported: 2011-07-21 12:57:27 | Status: resolved fixed

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

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java