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 215139 - [Rename] Method and Field rename incorrectly adds Type.super
Summary: [Rename] Method and Field rename incorrectly adds Type.super
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.2
Hardware: PC Linux
: P2 normal (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-03 18:45 UTC by Michel Graciano
Modified: 2012-09-07 08:39 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample project (13.73 KB, application/zip)
2012-07-03 18:51 UTC, Michel Graciano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Graciano 2012-07-03 18:45:04 UTC
[ BUILD # : 201206291011 ]
[ JDK VERSION : 1.7.5 ]

I will attach a sample project and steps soon.
Comment 1 Michel Graciano 2012-07-03 18:51:26 UTC
Created attachment 121707 [details]
Sample project

1. Open the attached project and both classes inside it;
2. Put the cursor at Bean class, line 5 and column 22;
3. Call Refactor > Rename and mark all options and change the name to 'name1' and confirm;

The result in Caller class should be:

    public String getName() {
        return bean.Bean.super.getName();
    }

    public void setName(String name) {
        bean.Bean.super.setName(name);
    }

During my test, only once, it worked, so I tried again renaming from 'name1' to 'name' again and the problem appeared. In my production project, it is not random, all the time I did it today, the issue showed up.
Comment 2 Michel Graciano 2012-07-03 18:52:01 UTC
It looks to be a stopper for me.
Comment 3 Michel Graciano 2012-07-03 19:13:36 UTC
Well, I was intriguing by the fact that sometime it took me twice to reproduce the issue, so I tried it with a clean install at a Windows workstation and it really took me twice to reproduce the issue.

So, given the steps I told before, it is just necessary to do the step 3 again, changing 'name1' to 'name' I have the following result:

public String getName() {
    return bean.Bean.super.getName();
}

public void setName(String name) {
    bean.Bean.super.setName(name);
}

I have tested it at:
Product Version: NetBeans IDE 7.2 (Build 201206291011)
Java: 1.7.0_03; Java HotSpot(TM) 64-Bit Server VM 22.1-b02
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 4 MackSix 2012-07-03 22:00:13 UTC
(In reply to comment #3)
> Well, I was intriguing by the fact that sometime it took me twice to reproduce
> the issue, so I tried it with a clean install at a Windows workstation and it
> really took me twice to reproduce the issue.
> 
> So, given the steps I told before, it is just necessary to do the step 3 again,
> changing 'name1' to 'name' I have the following result:
> 
> public String getName() {
>     return bean.Bean.super.getName();
> }
> 
> public void setName(String name) {
>     bean.Bean.super.setName(name);
> }
> 

This is showing the incorrect code, right?
Comment 5 MackSix 2012-07-03 22:17:53 UTC
I can changed the field name on line 5 all I want to any other name and it works right, but if I change the name from any name to "name" it generates the wrong code in Caller.java.

I changed it from "name" to "name1" then "name2" then "name3" and it would work, but I change it back to "name" again, it fails in Caller.java.

It is like "name" is some sort of a keyword that causes the bug to happen.
Comment 6 MackSix 2012-07-03 22:25:39 UTC
Product Version: NetBeans IDE 7.2 (Build 201206291011)
Java: 1.7.0_05; Java HotSpot(TM) Client VM 23.1-b03
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)
Comment 7 Ralph Ruijs 2012-07-04 09:32:11 UTC
Thank you for the report. The problem is in the comparison of supertypes. The super keyword should only be added if there is a naming collision from a usage in a subtype.

I do not think this is a stopper as the visibility is low, it has been introduced in September 2011. I will mark it as P2 and patch candidate.
Comment 8 Ralph Ruijs 2012-07-04 09:43:36 UTC
Changeset: 22cb5949f040
Author:    Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Date:      2012-07-04 11:42
Message:   
Issue #215139 - [Rename] Method and Field rename incorrectly adds Type.super
Comment 9 Michel Graciano 2012-07-04 11:56:57 UTC
(In reply to comment #7)
> I do not think this is a stopper as the visibility is low, it has been
> introduced in September 2011. I will mark it as P2 and patch candidate.

I agree we can wait for patch 1. Thanks for the quickly analysis and fix, and everyone for evaluations and better steps to reproduce.
Comment 10 Quality Engineering 2012-07-06 03:15:22 UTC
Integrated into 'main-golden', will be available in build *201207060002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/22cb5949f040
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: Issue #215139 - [Rename] Method and Field rename incorrectly adds Type.super
Comment 11 Michel Graciano 2012-07-06 12:07:54 UTC
v. Build 20120705-0c78cea2f726
Comment 12 Ralph Ruijs 2012-08-31 12:37:13 UTC
http://hg.netbeans.org/releases/rev/1c9fd623d751
Comment 13 Quality Engineering 2012-09-01 11:09:16 UTC
Integrated into 'releases', will be available in build *201209010822* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/1c9fd623d751
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: Issue #215139 - [Rename] Method and Field rename incorrectly adds Type.super