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 124137 - Refactoring package names broke the code
Summary: Refactoring package names broke the code
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jan Becicka
URL:
Keywords:
Depends on: 125105
Blocks: 121950
  Show dependency tree
 
Reported: 2007-12-17 15:49 UTC by wmac
Modified: 2008-08-04 09:42 UTC (History)
4 users (show)

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 wmac 2007-12-17 15:49:46 UTC
Hello,

Today I refactored all my packages in the project (almost 10 packages) and removed a prefix of all packages (i.e
converted my.usm.cs.crowdsim.mabs, my.usm.cs.crowdsim.micromodel, .... -> crowdsim.mabs, crowdsim.micromodel, ...).

This resulted into incorrect code (mostly caused by incorrect updated package imports).

I needed to manually fix things (took 20 minutes to fix 40-50 files). I think this is serious issue so I am choosing P1.
Comment 1 Jan Becicka 2008-01-02 10:41:02 UTC
Please attach your messages.log, thanks.
Comment 2 wmac 2008-01-03 09:49:54 UTC
I had submited this almost 3 weeks ago and since then because netbeans had too much bugs (and I was not able to use it
for serious work) I removed it totally.

I do not have any files from it but it should be easy to reproduce such a thing.
Comment 3 Jan Becicka 2008-01-03 12:19:58 UTC
Jirko, please test it. Thanks.
Comment 4 Marian Mirilovic 2008-01-03 12:56:28 UTC
dup. of  #122295 ?, without log we can do almost nothing ;(
Comment 5 wmac 2008-01-03 13:05:58 UTC
Ok, I reinstall NB 6.0 and try to the same refactors and if it happens again I will submit the log. (Or I'd rather do it
with my current nightly NB 6.1 version?)
Comment 6 Jiri Prox 2008-01-03 13:22:49 UTC
I've tested it with 6.0 and the only issue I've found is issue 122295, which should be fixed now in daily 6.1. The
result of the bug was broken sig files, so I've had to delete ${userdir}/var/cache/index to fully recover from it. 

Let's wait for the log, to see if there is another problem.
Comment 7 wmac 2008-01-08 02:53:27 UTC
I installed NB6.0 and tried to refactor package names again and the same thing happens. The problem happens because NB
updates imported packages lists incorrectly. (This time I tried to add a prefix to package names and the same problem
happened). Please pay attention that unlike  "issue 122295" this one does not crash NB, it just causes errors in code.

I want to give you the project but I cannot post it here. To whom should I email the project?  jbecicka@netbeans.org or
 jiriprox@netbeans.org ?

 

Comment 8 Jiri Prox 2008-01-08 06:48:20 UTC
You can send it to me, thanks.

I just want to mention that issue 122295 does not crash whole IDE, only exception is throw a the sig files were broken,
which can cause nonsense error or other improper java editor behavior.
Comment 9 Jan Becicka 2008-01-08 15:15:02 UTC
I also want to remind, that issue 122295 is not fixed in 6.0, but in 6.1M1.
Comment 10 Jiri Prox 2008-01-09 06:48:07 UTC
I've seen this in 6.1 a well. I've used provided project, but I cannot find the reliable steps, it's happening only
something. In my case it looks like that after refactoring is performed the editor shows dialog that file was changed
externally and if I chose "Reload" there is not updated package statement. 
Maybe this can be caused by bad project configuration when source package are located directly in project folder, not in
its subfolder. 
I'll do further investigation.

Downgrading to P2 since the unusual project configuration.
Comment 11 wmac 2008-01-09 07:29:31 UTC
I moved the source files to an src sub-folder (it was that way because I had imported it from eclipse).

Even with sources inside src folder the problem can be reproduced.

Though it seems the problem depends on the order of refactors (.i.e start from internal package directories or from
outer or mixed)
Comment 12 Jiri Prox 2008-01-09 09:20:02 UTC
Have you used refactoring undo feature during the modification?
I've found testcase which is reproducible, if there is use d undo during the renaming (seems that metadata are not
updated correctly when performing undo and next refactoring will fail)
Comment 13 wmac 2008-01-09 11:27:27 UTC
No, I have not used undo. I will also try to see if it has any effect.
Comment 14 Jan Becicka 2008-01-24 15:14:18 UTC
Probably dupe of issue 125105
Comment 15 Jan Becicka 2008-02-13 12:33:27 UTC
Probably not reproducible after fix of issue 125105
Comment 16 wmac 2008-02-13 12:44:10 UTC
Is this included in daily build? (If so I can test to see if it is reproducible)
Comment 17 Jan Becicka 2008-02-13 12:52:31 UTC
Yes. Please test it in daily build. Thanks
Comment 18 Jan Becicka 2008-02-21 14:38:18 UTC
Any progress? Still reproducible? Thanks
Comment 19 wmac 2008-02-22 07:18:48 UTC
Sorry for the delay. It happens less now. (Previous time I refactored 10 packages and at least 4-5 packages had problem,
this time only one of them had problem).

Another new problem is now introduced.

If you have :

mainpack
mainpack.something
mainpack.something1
mainpack.something2.more
mainpack.something2.more1
...

If you start refactoring from inner packages upward (for example add a com.test prefix) you will have problem
refactoring "mainpack" itself. It will say com.test.mainpack already exists (while it is not, only subpackages of it
exis , not itself).


Comment 20 Jiri Prox 2008-02-22 09:54:56 UTC
can you provide the project once more time, please?
I've tested it again with that one, you've send me some time ago, and I all worked for me (except the already existing
package issue, of course). But I had to change project configuration before testing, since, there was absolute path.
Maybe it had some impact of reproducibility of this issue.
Comment 21 Jan Becicka 2008-02-26 13:14:06 UTC
Please provide your project or steps to reproduce.

Problem with "package already exists" is already reproted (issue 99570). Let's focus on original issue.
Comment 22 wmac 2008-02-27 02:04:22 UTC
Sent to jiriprox@netbeans.org

The problem happens when you refactor one of the packages (there are less than 10).
Comment 23 Jan Becicka 2008-02-28 08:35:26 UTC
Sorry we cannot reproduce it after fix of 125105
Comment 24 Petr Dvorak 2008-03-17 15:39:22 UTC
Had the same problem, I will attach my IDE log. I was executing TS_61_FormRefactoring "Rename a Package" (1). Some of
the packages were not renamed in the source, or - if I tried again with a new project - they were renamed, but there
were "error badges" in the Project window while there were no errors in the code (wrong refresh of the Project view
after the refactoring?).
Comment 25 Petr Dvorak 2008-03-17 15:46:42 UTC
Product Version: NetBeans IDE Dev (Build 200803170003)
Java: 1.6.0_04; Java HotSpot(TM) Client VM 10.0-b19
System: Linux version 2.6.24-12-generic running on i386; UTF-8; en_US (nb)

Ide log and screenshot:

http://www.netbeans.org/nonav/issues/showattachment.cgi/58492/idelog.txt
http://www.netbeans.org/nonav/issues/showattachment.cgi/58493/screenshot.png
Comment 26 Petr Dvorak 2008-03-17 15:56:00 UTC
Note: To reproduce the issue, it seems to be sufficient to use refactor/rename twice on the source package that was
generated in Java Desktop Application by default.
Comment 27 Petr Dvorak 2008-03-17 16:46:46 UTC
Well, maybe just more thing (as I paid more attention to this issue - see the screenshot).

The funny thing about the screnshot is that the code is actually correct. It just remains underlined and with an error
icons in the gutter - so my desc. is probably more for the "editor". If you delete the last "p" in DesktopApp and write
it back, the error messages disappears.
Comment 28 Jiri Prox 2008-04-11 01:47:13 UTC
moving opened issues from TM <= 6.1 to TM=Dev
Comment 29 Jan Becicka 2008-08-04 09:42:47 UTC
Worksforme. Probably fixed with other issues (125105)