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 134345

Summary: add property generates wrong code for setXx method
Product: java Reporter: andersb <andersb>
Component: BeansAssignee: issues@java <issues>
Status: RESOLVED DUPLICATE    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:

Description andersb 2008-05-01 20:12:32 UTC
Generation of bounded and/or constrained properties (using "insert code -> add property ..."): Problem in the set-method: 

Example:

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

public class Borrower {

  private String name;
  public static final String PROP_NAME = "name";

  /**
   * Get the value of name
   *
   * @return the value of name
   */
  public String getName() {
    return name;
  }

  /**
   * Set the value of name
   *
   * @param name new value of name
   */
  public void setName(String name) {
    String oldName = name;   PROBLEM, should be String oldName = this.name
    this.name = name;
    propertyChangeSupport.firePropertyChange(PROP_NAME, oldName, name);
  }
  private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);

  /**
   * Add PropertyChangeListener.
   *
   * @param listener
   */
  public void addPropertyChangeListener(PropertyChangeListener listener) {
    propertyChangeSupport.addPropertyChangeListener(listener);
  }

  /**
   * Remove PropertyChangeListener.
   *
   * @param listener
   */
  public void removePropertyChangeListener(PropertyChangeListener listener) {
    propertyChangeSupport.removePropertyChangeListener(listener);
  }

}
Comment 1 Jan Pokorsky 2008-05-02 15:51:02 UTC
Thanks for the report. It was already fixed and the fix will be part of NB 6.1 patch.

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