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 135226 - Wrong generated code for Property Change Support
Summary: Wrong generated code for Property Change Support
Status: RESOLVED DUPLICATE of bug 131835
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-16 16:41 UTC by mikiglvt
Modified: 2008-05-19 09:08 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mikiglvt 2008-05-16 16:41:24 UTC
When the "Source -> Insert Code -> Add Propery" dialog is used to add a new property and both the "Bounded" and
"Property Change Support" checkboxes are selected, the generated code for the "set" method is wrong:

[Generating a "demo: String" property]:

    public void setDemo(String demo) {
        String oldDemo = demo;
        this.demo = demo;
        propertyChangeSupport.firePropertyChange(PROP_DEMO, oldDemo, demo);
    }

The problem is on the first line of the setter method: it should read:

  String oldDemo = this.demo;

, instead of the current:

  String oldDemo = demo; 

, which does actually set the "old" value to the new one from the method parameter and not really from the class'
("this." prefix is missing!) value. 

Thanks.

Whole generated code, just for the record:

    private String demo = "bug report";

    public static final String PROP_DEMO = "demo";

    public String getDemo() {
        return demo;
    }

    public void setDemo(String demo) {
        String oldDemo = demo;
        this.demo = demo;
        propertyChangeSupport.firePropertyChange(PROP_DEMO, oldDemo, demo);
    }

    private java.beans.PropertyChangeSupport propertyChangeSupport = new java.beans.PropertyChangeSupport(this);

    public void addPropertyChangeListener(java.beans.PropertyChangeListener listener )
    {
        propertyChangeSupport.addPropertyChangeListener( listener );
    }

    public void removePropertyChangeListener(java.beans.PropertyChangeListener listener )
    {
        propertyChangeSupport.removePropertyChangeListener( listener );
    }
Comment 1 Jana Maleckova 2008-05-19 08:53:43 UTC
reassign to java editor for evaluation
Comment 2 Jiri Prox 2008-05-19 09:08:43 UTC
this is already fixed, the fix will be included in patch 1, thanks for your report.

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