Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 98165 - [Encapsulate Field] Refactoring does not distinguish between assignment and evaluation
[Encapsulate Field] Refactoring does not distinguish between assignment and e...
Status: RESOLVED WONTFIX
Product: editor
Classification: Unclassified
Component: Refactoring
6.x
PC Windows XP
: P3 (vote)
: TBD
Assigned To: issues@java
issues@java
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-03-19 06:04 UTC by kely_garcia
Modified: 2007-04-03 18:02 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-03-19 06:04:06 UTC
Build ID: 200609161800 (Netbeans 6.0 M3)

Steps to reproduce:

Apply Encapsulate Field refactoring on the following input program:

public class A {
    private boolean theField;
    
    void method_A(){
        if (theField = true){
            // do something
        }
    }
}


Encapsulate Field refactoring produces the erroneous code (uncompilable):

public class A {
    private boolean theField;
    
    void method_A(){
        if (setTheField(true)){
            // do something
        }
    }

    public boolean isTheField() {
        return theField;
    }

    public void setTheField(boolean theField) {
        this.theField = theField;
    }
}

Possible reason: the refactoring engine is not able to distinguish between an
assignment (in the if's condition) and a boolean evaluation (again in the if's
condition).

Solution: if the setter method would return the field, the refactored code would
compile and be correct.
Comment 1 Jiri Prox 2007-03-19 09:32:41 UTC
Returning value from setter will break java bean pattern.
I'm afraid there is no way how to solve this problem. 


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