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.
I rewrite ModifiersTree as follows: ModifiersTree t = make.Modifiers(fla2, ann2); System.out.println("t: " + t); wc.rewrite(node, t); In the log, I can see that t is as I expect: t: @A2() @A1() static But in the result, A1 is missing: @A2 static void m() { }
Lowering priority. This issues are very specific.
Resolving all issues with milestone "future" as LATER. If you feel strongly that it should be implemented please reopen and set the target milestone to "next".
I am working on a refactoring module and these bugs are crucial for it to work.
@tronicek you're going to have to provide some more info before I can reproduce this.
Created attachment 82698 [details] test case, passes
I've attached a test case... but it passes for me, so we're missing the exact conditions that cause this. @tronicek can you please confirm that when you create your new ModifiersTree, that you are passing in the full list of flags (or the original tree) and BOTH annotations? The API documentation for make.Modifiers clearly states that you can pass in the original tree in order to use its FLAGS, but not its annotations... you need to pass both @A1 and @A2 to the method.
@fommil: sorry for delay, here it is: ModifiersTree original = (ModifiersTree) node; List<? extends AnnotationTree> ann = original.getAnnotations(); List<AnnotationTree> ann2 = new ArrayList<AnnotationTree>(); ann2.add(ann.get(1)); ann2.add(ann.get(0)); Set<Modifier> fla2 = original.getFlags(); modified = make.Modifiers(fla2, ann2); logger.log(Level.INFO, "original: " + original); logger.log(Level.INFO, "modified: " + modified); wc.rewrite(original, modified); I use the following input: @interface A1 { } @interface A2 { } @A1 @A2 public class Test2 { @A1 @A2 static void m() { } } The output is: @A2 public class Test2 { @A2 static void m() { } } which is incorrect. In the log, there is what I expect: original: @A1() @A2() static modified: @A2() @A1() static
OK, really weird bug... I'm able to reproduce *but* it appears to be a problem with the List used in generation, not in the diff code. Uploading a test case that shows the breakage.
Created attachment 82705 [details] test case, fails
OK, the issue is in the ordering of the annotations... works fine without the Collections.reverse() line in the test case but when reversed, code manifests itself.
Reassigning all moonko's java/source bugs to myself.
Everything seems to be clear, no extra info needed. Removing INCOMPLETE.
Bug prior to 7.0, not touched for the last 2 years --> P4.
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue. Thanks for your cooperation, NetBeans IDE 8.2 Release Boss