Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 108474 - [encapsulate field] Encap. field results in change of behavior
[encapsulate field] Encap. field results in change of behavior
Status: RESOLVED DUPLICATE of bug 108489
Product: java
Classification: Unclassified
Component: Refactoring
6.x
PC Windows XP
: P3 (vote)
: 6.x
Assigned To: Jan Pokorsky
issues@java
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-06-29 00:03 UTC by kely_garcia
Modified: 2008-02-11 12:58 UTC (History)
0 users

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kely_garcia 2007-06-29 00:03:46 UTC
Build ID: 200609161800 (Netbeans 6.0 M3)

Steps To Reproduce:
Encapsulate field "theField" on the following:

public class A {
  public String theField;
  public static void main(  String[] args){
    B b=new B();
    b.setTheField("abcd");
  }
}
class B extends A {
  public void setTheField(  String theField){
    this.theField=theField;
  }
}

Yields the following refactored code:
public class A {
    private String theField;
    public static void main(  String[] args){
        B b=new B();
        b.setTheField("abcd");
    }

    public String getTheField() {
        return theField;
    }

    public void setTheField(String theField) {
        this.theField = theField;
    }
}
class B extends A {
    public void setTheField(  String theField){
        this.setTheField(theField);
    }
}

Running A before refactoring: ""
Running A after refactoring : Exception in thread "main" java.lang.StackOverflowError
	                                     at p1.B.setTheField(A.java:22)
Comment 1 Jan Becicka 2007-06-29 10:20:03 UTC
Valid for 5.5. Encapsulate fields not implemented in M10. Planned for beta1. Need to be reevaluated when implemented.
Should be resolved for 6.0
Comment 2 Daniel Prusa 2008-02-11 12:58:17 UTC
Similar problem to that reported in issue 108489.

*** This issue has been marked as a duplicate of 108489 ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo