This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 206686

Summary: [encapsulate field] introduces behavioral change: Enables overriding
Product: java Reporter: GustavoSoares
Component: RefactoringAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P4    
Version: 7.0.1   
Hardware: PC   
OS: Mac OS X   
Issue Type: DEFECT Exception Reporter:

Description GustavoSoares 2011-12-24 04:03:09 UTC
Create the classes:

package p2;
public class C {
  protected long getF(){
    return 0;
  }
  public long m(){
    return getF();
  }
}


package p2;
public class A extends C {
  public long f=10;
  public long test(){
    return m();
  }
}


apply the pull up field refactoring to B.f 

package p2;
public class C {
  protected long getF(){
    return 0;
  }
  public long m(){
    return getF();
  }
}


package p2;
public class A extends C {
  private long f=10;
  public long test(){
    return m();
  }

    public long getF() {
        return f;
    }

    public void setf(long f) {
        this.f = f;
    }
}


The transformation changes behavior. After the transformation the m method
returns 10 instead of 0
Comment 1 Martin Balin 2016-07-07 07:18:44 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss