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.
Product Version: NetBeans IDE Dev (Build 201601130002) Java: 1.8.0_66; Java HotSpot(TM) 64-Bit Server VM 25.66-b17 Runtime: Java(TM) SE Runtime Environment 1.8.0_66-b17 System: Windows 10 version 10.0 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 This is a simple bug, but causes data loss silently so I set the priority at P1. Given: @JsonTypeInfo(use = JsonTypeInfo.Id.CUSTOM, property = "type", include = JsonTypeInfo.As.EXISTING_PROPERTY) @JsonTypeIdResolver(WorkerTypeIdResolver.class) // TODO: https://github.com/FasterXML/jackson-databind/issues/1056#issuecomment-172208353 @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id") public class SomeClass { } If you invoke Organize Members, Netbeans deletes all lines between the imports the last annotation. Meaning, it deletes the line comment and the two annotations above it. Expected behavior: Netbeans should not provide the hint Organize Members, and even if it does (because some other lines trigger Organize Members) then it should not modify the annotations and line comment.
Sorry, the code sniplet I posted was incorrect. Here is an easier way to reproduce code sniplet that will work: --------- package somepackage; /** * Some block comment. */ @SuppressWarnings("unchecked") // Some line comment @Deprecated public class Test { private int test; public int getTest() { return test; } } --------- After Organize Members you will end up with: --------- package somepackage; @Deprecated public class Test { private int test; public int getTest() { return test; } } --------- Notice that the block comment, @SuppressWarnings, and line comment were all deleted.
Reproducible The cause is the comment between annotations
Seems like the // comment gets incorrectly assigned to TWO trees (annotation, class) instead of just annotation tree. I've made adjustments so that comments are assigned to the nearby annotations. Fixed in jet-main#bb79176c8f8f
Integrated into 'main-silver', will be available in build *201603030002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/bb79176c8f8f User: Svata Dedic <sdedic@netbeans.org> Log: #257599: dive into ModifiersTree to assign comments to annotations