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 165803 - second change method parameters broke code
Summary: second change method parameters broke code
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: Sun All
: P1 blocker (vote)
Assignee: Tomas Zezula
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2009-05-22 12:39 UTC by Vladimir Voskresensky
Modified: 2009-05-28 11:35 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
may be something helpful in log? (27.65 KB, text/plain)
2009-05-22 12:41 UTC, Vladimir Voskresensky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Voskresensky 2009-05-22 12:39:57 UTC
I can not reproduce it 100% but I'm constantly have the following problem:
- trying to use change methods parameters more than once break the code

Last time I have changed one method, than second and in other file I've got modification from:

            String getName = GeneratorUtils.computeGetterName(field);
            String setName = GeneratorUtils.computeSetterName(field);

to 
            String getName = GeneratorUtils.computeGetterName(field, isUpperCase);
            String setName = GeneratorUtils.computeSet, isUpperCaseterName(field);

The second line is corrupted completely :-(
Comment 1 Vladimir Voskresensky 2009-05-22 12:41:23 UTC
Created attachment 82634 [details]
may be something helpful in log?
Comment 2 Vladimir Voskresensky 2009-05-22 12:43:05 UTC
it had to be changed to:
            String getName = GeneratorUtils.computeGetterName(field, isUpperCase);
            String setName = GeneratorUtils.computeSetterName(field, isUpperCase);

but looks like textual replacement occurred on wrong position (old one?)
Comment 3 Jan Pokorsky 2009-05-22 13:59:59 UTC
Most likely a source generator bug. But we need a reproducible test case. The messages.log does not contain anything
related unfortunately.

I tried to reproduce with following sources without success:

import javax.lang.model.element.VariableElement;
class GeneratorUtils {
    static String computeGetterName(VariableElement field) {
	throw new UnsupportedOperationException("Not yet implemented");
    }
    static String computeSetterName(VariableElement field) {
	throw new UnsupportedOperationException("Not yet implemented");
    }
}

and 

import javax.lang.model.element.VariableElement;
public class UsageClass {
    void m() {
	VariableElement field = null;
	boolean isUpperCase = true;
	String getName = GeneratorUtils.computeGetterName(field);
	String setName = GeneratorUtils.computeSetterName(field);
    }
}

I did the Change Method Parameters refactoring to add a parameter 'boolean isUpperCase with default value isUpperCase'
for GeneratorUtils.computeGetterName(field) and later for GeneratorUtils.computeSetterName(field). No matter if it was
invoked inside GeneratorUtils.java

Could you provide your sources (project) here or privately to my email?

And the last question are your at local or remote filesystem?
Comment 4 Jan Pokorsky 2009-05-22 14:10:42 UTC
I have got it. It is necessary to close UsageClass.java and restart IDE to be sure the document was released. Now do
those above described refactorings inside GeneratorUtils.java and you should get broken Usages class.

import javax.lang.model.element.VariableElement;
public class UsageClass {
    void m() {
	VariableElement field = null;
	boolean isUpperCase = true;
	String getName = GeneratorUtils.computeGetterName(field, isUpperCase);
	String setName = GeneratorUtils.computeSet, isUpperCaseterName(field);
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    }
}

Reassigning to java/source.
Comment 5 Vladimir Voskresensky 2009-05-22 15:41:44 UTC
Hi, Jan, great that you reproduced it. 
You are right that document wasn't yet opened in IDE before.

Btw, after restart of IDE I have seen probably related issue:
- try to rename method declaration then try to use find usages for new named method => it is not found in closed file.
if I open the second file => rename was successful

FS: sources are local, but opened through shared NFS folder net/d-espb04-127-81/export/devarea/trunk/cnd.refactoring (it
is C++ support of NB)
Comment 6 Jan Pokorsky 2009-05-22 16:30:19 UTC
Vladimir, it sounds like a race condition that dbalek has already been hunting. CCing guys that may be interested in
failing index.
Comment 7 Vladimir Voskresensky 2009-05-25 11:57:17 UTC
Jan, I'm sure that is a showstopper for FCS. 
I have to manually fix all broken code and then restart IDE to continue work.
It wasn't the case with 6.5
Comment 8 Jiri Prox 2009-05-25 12:16:36 UTC
Marking as showstopper for 6.7
Comment 9 Tomas Zezula 2009-05-26 08:56:55 UTC
Obvious problem, parser is recreated but on the staled snapshot.
Comment 10 Tomas Zezula 2009-05-26 10:15:11 UTC
jet-main: 580220052898
Comment 11 Marian Mirilovic 2009-05-26 15:00:12 UTC
Waiting for review (Dev) and verification (Jirka) ... would be nice to have this in release67 ...
Comment 12 Jiri Prox 2009-05-26 16:33:46 UTC
verified in trunk

please integrate the fix in release67 clone
thanks
Comment 13 Quality Engineering 2009-05-27 07:28:13 UTC
Integrated into 'main-golden', will be available in build *200905270201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/580220052898
User: Tomas Zezula <tzezula@netbeans.org>
Log: #165803:second change method parameters broke code
Comment 14 Jan Jancura 2009-05-27 12:53:01 UTC
outstanding piece of code!
many thanks!!!
Comment 15 David Strupl 2009-05-27 13:12:09 UTC
Integrated into release67 clone as changeset:   e045818961bc
Comment 16 Jiri Prox 2009-05-28 11:35:15 UTC
verified in 6.7rc1