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 243851 - Formatting comments can uncomment them! Which may lead to semantic change of code!
Summary: Formatting comments can uncomment them! Which may lead to semantic change of ...
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0
Hardware: PC Linux
: P2 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-15 14:38 UTC by Szpak
Modified: 2014-04-25 07:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Example for showing instability in code formatting. Invoking formatter many times in a row gives different results! (835 bytes, application/octet-stream)
2014-04-15 14:38 UTC, Szpak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Szpak 2014-04-15 14:38:42 UTC
Created attachment 146768 [details]
Example for showing instability in code formatting. Invoking formatter many times in a row gives different results!

Comment formatting works incorrectly. 

Sometimes comments are UNCOMMENTED by formatter!!! (in my case it depends on number of spaces used before comment, but I believe there may be more such cases).

To be precise it happens to incorrectly indented comments which appear just before javadocs.

This may lead to some serious issues. If you try to reformat whole project (as I did) you should start to be worried.

For example just try to reformat following code using default NB settings (7.4 or 8.0, openSuse 13.1, Win 7, Java 1.7_51).
(get attached file to make sure you are using the same number of spaces as I did)
------------------------------------------------------------------

/**
 * This is class example for showing instability in code formatting.
 * Invoking formatter many times in a row gives different results!!!!
 * Tested in NB 7.4, 8.0, Windows 7, OpenSuse 13.1
 * 
 * @author Marcin Szpak, Laboratory of Visual Analysis ICM, University of Warsaw
 */
public class NetbeansFormattingBug {

      //this comment is going to be UNCOMMENTED!
    /**
     * javadoc here
     */
    public static void main(String[] args) {
    }

     //this comment is going to be PARTLY UNCOMMENTED!
    /**
     */
    public void method1() {

    }

                         //this comment is going CRAZY
    /**
     */
    public void method2() {

    }

      //public void superMethod() {} //this one will be uncommented which may lead to some SERIOUS PROBLEMS!!
    /**
     */
    public void method3() {

    }
}
Comment 1 Dusan Balek 2014-04-18 09:59:39 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/42e8081119d3
Comment 2 Quality Engineering 2014-04-20 01:23:30 UTC
Integrated into 'main-silver', will be available in build *201404200001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/42e8081119d3
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #243851: Formatting comments can uncomment them! Which may lead to semantic change of code! - fixed.
Comment 3 Szpak 2014-04-20 12:12:28 UTC
Hi Dusan Balek

Could you please tell me if this issue was only related to comments just before java docs? Were there any other cases when such problem could appear?

Thanks
Marcin
Comment 4 Jiri Prox 2014-04-22 14:01:51 UTC
verified in trunk
Comment 5 Dusan Balek 2014-04-22 14:13:50 UTC
Integrated into release80.

http://hg.netbeans.org/releases/rev/bac54ca1dbd3
Comment 6 Dusan Balek 2014-04-22 14:45:13 UTC
To Marcin:
yes, the problematic case was a line comment directly followed by javadoc.
Comment 7 Szpak 2014-04-22 14:59:12 UTC
All right. Thanks!
Comment 8 Quality Engineering 2014-04-24 02:03:01 UTC
Integrated into 'releases/release80', will be available in build *201404240045* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/bac54ca1dbd3
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #243851: Formatting comments can uncomment them! Which may lead to semantic change of code! - fixed.