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 237072 - Organize Members deletes Javadoc
Summary: Organize Members deletes Javadoc
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
: 235161 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-10-13 02:45 UTC by _ gtzabari
Modified: 2014-03-26 17:05 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
testcase (8.60 KB, application/octet-stream)
2013-10-13 02:45 UTC, _ gtzabari
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2013-10-13 02:45:26 UTC
Created attachment 141034 [details]
testcase

Product Version: NetBeans IDE Dev (Build 201310070001)
Java: 1.7.0_40; Java HotSpot(TM) 64-Bit Server VM 24.0-b56
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

1. Open testcase.
2. Open com.mycompany.organizemembersbugs.Test
3. Click the hint on line 15 "Organize members"
4. Notice that Netbeans deletes the Javadoc from line 9 through 11.

Setting priority to P1 because this bug causes data loss. I didn't notice this problem until I had already processed many files and now I have to recover the Javadoc from history.
Comment 1 Svata Dedic 2013-10-14 10:29:51 UTC
the data loss is recoverable - since it is a hint, editor's Undo be used. In the worst case, the user may recover the data from the local history. Other comment-loosing defects are also filed as P3.
Comment 2 Svata Dedic 2013-10-17 09:06:31 UTC
Fixed in http://hg.netbeans.org/jet-main/rev0f9781dc0eb4
Comment 3 markiewb 2013-10-17 14:07:31 UTC
Canidate for a 7.4 patch? This issue is really annoying.
Comment 4 _ gtzabari 2013-10-20 15:46:01 UTC
7.4 shouldn't have shipped with this bug (which again, I consider a P1). It seems that *any* hint that transforms the code deletes the Javadoc of code it touches. For example, the "Change type of X to long" hint does the same. I reproduced this with 7.4 final, not a dev build.

Please fix this in 7.4 as soon as possible.
Comment 5 Svata Dedic 2013-10-22 13:43:01 UTC
*** Bug 235161 has been marked as a duplicate of this bug. ***
Comment 6 Quality Engineering 2013-10-24 02:39:25 UTC
Integrated into 'main-silver', will be available in build *201310240001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/0f9781dc0eb4
User: Svata Dedic <sdedic@netbeans.org>
Log: #237072: original javadoc copied to copied members
Comment 7 Stepan Zebra 2013-11-13 13:28:18 UTC
There seems to be regressions after the fix:
1) Calling Organize Members from hint causes an empty line to be inserted between a declaration and it's javadoc comment
2) Calling Organize Members from menu causes that some javadoc comments are duplicated
Comment 8 Svata Dedic 2013-11-13 13:32:18 UTC
Based on the time remaining to patch1 deadline, and the side effects discovered by testing, I would prefer NOT to fix it as a part of patch1. I'll try to solve it along with other comment-affecting defects for 8.0
Comment 9 _ gtzabari 2013-11-13 17:39:06 UTC
svata,

I recommend simply disabling Organize Members in patch 1. This functionality causes data loss and should be disabled until it is fixed properly.
Comment 10 markiewb 2013-11-14 14:24:06 UTC
Related to https://netbeans.org/bugzilla/show_bug.cgi?id=238372 ?
Comment 11 Jesse Glick 2013-11-14 14:58:47 UTC
As noted in #229590, I think it is a broad range of refactorings which are affected, so just disabling them is not a realistic option.

Still annoying me, but not a critical problem now that I am aware of its existence; I always run a local diff before I commit so I notice when Javadoc goes missing and can easily revert the deletion. Would not help if the Javadoc were added since the last commit of course.
Comment 12 markiewb 2013-11-14 15:39:41 UTC
(In reply to Jesse Glick from comment #11)
> Still annoying me, but not a critical problem now that I am aware of its
> existence; I always run a local diff before I commit so I notice when
> Javadoc goes missing and can easily revert the deletion. Would not help if
> the Javadoc were added since the last commit of course.

BTW: I do the same before pushing my changes. A self-code-review to minimize the diff hunks.

BUT all the other NB users (at companies/schools/universities) aren't aware of this bug. IMHO this issue is still critical because it removes "important" content from the sources.
Comment 13 _ gtzabari 2013-11-14 18:32:27 UTC
So I would delay patch1 until this issue can be fixed properly. It is really critical to get this right.
Comment 14 Svata Dedic 2013-11-14 20:08:55 UTC
(In reply to _ gtzabari from comment #13)
> So I would delay patch1 until this issue can be fixed properly. It is really
> critical to get this right.

I understand considerations about schools / dev teams - but the issues with deleting javadoc is present for years in many kind of hints / refactorings. If's not reasonable to delay a patch to fix issues that have been present 2-3 releases back.

Note: this particular defect was attempted to fix, but the fix was inappropriate; 7.4 behaviour should be better than dev.
Comment 15 _ gtzabari 2013-11-14 20:40:19 UTC
Perhaps that's true, but I've never run into this kind of data-loss before in a public release. I guess we can agree to disagree, but I consider this bug to be a show-stopper (7.4 should have been delayed, had we caught this in time).

Anyway, I've stated my 2 cents :) so I'll leave it at that. I'll be fine with whatever decision you make.
Comment 16 Marian Mirilovic 2013-11-15 07:34:34 UTC
(In reply to _ gtzabari from comment #15)
> Anyway, I've stated my 2 cents :) so I'll leave it at that. I'll be fine
> with whatever decision you make.

We will release Patch 1 on-time, beside that I would like to try to fix this (along with other refactoring deleting javadoc issues) as soon as possible and if it's ready to be shipped as another patch for 7.4 we will do so.
Comment 17 Svata Dedic 2013-11-27 09:42:50 UTC
(In reply to Stepan Zebra from comment #7)
> There seems to be regressions after the fix:
> 1) Calling Organize Members from hint causes an empty line to be inserted
> between a declaration and it's javadoc comment
> 2) Calling Organize Members from menu causes that some javadoc comments are
> duplicated

Stepan: could you please provide a testcase for duplicating comments ? I was able to reproduce the (1) - but I am not sure if I observed the same behaviour as you: the javadoc comment was shifted one line up (previous blank line deleted, one blank inserted between javadoc and its declaration).
Comment 18 Stepan Zebra 2013-11-27 12:03:32 UTC
(In reply to Svata Dedic from comment #17)
> (In reply to Stepan Zebra from comment #7)
> > There seems to be regressions after the fix:
> > 1) Calling Organize Members from hint causes an empty line to be inserted
> > between a declaration and it's javadoc comment
> > 2) Calling Organize Members from menu causes that some javadoc comments are
> > duplicated
> 
> Stepan: could you please provide a testcase for duplicating comments ? I was
> able to reproduce the (1) - but I am not sure if I observed the same
> behaviour as you: the javadoc comment was shifted one line up (previous
> blank line deleted, one blank inserted between javadoc and its declaration).

Using the attached project, I can reproduce it by opening AppTest.java and invoking Source > Organize Members without moving the text cursor anywhere (it's on 1:1) and in Test.java when I put the text cursor to the beginning of the inner class (14:4) and invoke Source > Organize Members twice.
Comment 19 Svata Dedic 2013-11-27 12:59:38 UTC
I've changed internals of copy comments so that duplicates are ignored. Should be safe & backwards compatible. Fixed in rev. 

Note - the AppTest from the attached example is wrongly indented with respect to the formatting settings. If you run Org.Members on it, it will misformat javadoc comments. Once the source formatting is cleaned up (Alt-shift-F), org. members will work OK.

Fixed in rev. http://hg.netbeans.org/jet-main/rev/e841b05ec1a5
Comment 20 Jiri Prox 2013-12-03 14:07:07 UTC
verified in trunk
Comment 21 Svata Dedic 2013-12-13 13:26:22 UTC
Grafted into 7.4 as #7884effdb6f4 and #65f576a409ae
Comment 22 Jesse Glick 2013-12-13 16:48:27 UTC
Is this really supposed to be fixed? Still broken in 20131211-ca7d20f516e1. Move Method, Introduce Constant, etc. delete class Javadoc (and annotations).
Comment 23 Svata Dedic 2013-12-13 17:07:49 UTC
Just the organize members case should be fixed. The problem is more general as you note in comment #11, and is likely to be fixed for 8.0, although it is not safe (according to some preliminary implementation) to backport to 7.4
Comment 24 _ gtzabari 2013-12-13 19:14:07 UTC
Svata,

Are you saying that this is fully fixed in the 8.0 branch, but only part of the fix was backported to 7.4?

Or are you saying that there is outstanding work to fix it in 8.0 as well?
Comment 25 Svata Dedic 2013-12-13 19:25:46 UTC
Sorry for not being clear; the 'Organize Members' effects on comments are supposed to be fully fixed for 8.0 AND backported to 7.4. This is what the orginal report was about, as well as comments #1-11,13-21.

There's potentially a lot of hints, refactorings or other code transformations that break or erase the comments, as one must specifically care about carrying the comments to the changed code.

Filed a separate issue #239487 to address the general behaviour.
Comment 26 Quality Engineering 2014-03-26 17:05:55 UTC
Integrated into 'releases/release74', will be available in build *201403261440* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/7884effdb6f4
User: Svata Dedic <sdedic@netbeans.org>
Log: #237072: original javadoc copied to copied members