Watch, Follow, &
Connect with Us
Public Report
Report From: JBuilder/Extreme Programming/Refactoring    [ Add a report in this area ]  
Report #:  44893   Status: Reported
Pull up of method with for loop looses for conditional check
Project:  JBuilder Build #:  12.0.216.0 sp3
Version:    12 Submitted By:   Paul Furbacher
Report Type:  Basic functionality failure Date Reported:  4/23/2007 12:28:03 PM
Severity:    Infrequently encountered problem Last Updated: 4/23/2007 12:28:41 PM
Platform:    All versions Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
When pulling up a method to a superclass, the conditional portion of any for loop will be lost in the superclass code.  The superclass will not compile until this problem is corrected manually.
Steps to Reproduce:
Start with a base class and a subclass as follows:

****
package refactor.bugs;

public class AbstractBadPullUpForLoop {  
  public AbstractBadPullUpForLoop() { }  
}

****
package refactor.bugs;

public class BadPullUpForLoop extends AbstractBadPullUpForLoop {
  
  private String [] strings = new String[] { "one", "two" };
  
  public BadPullUpForLoop() { super(); }

  /**
   * methodWithForLoop -- use Refactor > Pull up ... here
   */
  public void methodWithForLoop() {
    for (int i = 0; i < strings.length; i++) {
      System.out.println(" - " + strings[i]);
    }
  }
}

****

Result: note the "; ;" in the for setup:

package refactor.bugs;

public class AbstractBadPullUpForLoop {
  
  public AbstractBadPullUpForLoop() { }

  protected String[] strings = new String[] { "one", "two"};

  /**
   * method pulled up from subclass-- is missing the conditional check in for (...)
   */
  public void methodWithForLoop() {
    for (int i = 0; ; i++) {
      System.out.println(" - " + strings[i]);
    }
  }

}
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01