diff -r 06ad65d6fab5 java.source/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java --- a/java.source/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java Sat May 16 19:07:21 2009 +0200 +++ b/java.source/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java Sun May 24 15:34:12 2009 +0100 @@ -51,6 +51,7 @@ import com.sun.source.tree.ModifiersTree; import com.sun.source.tree.NewArrayTree; import com.sun.source.tree.Tree; +import com.sun.source.tree.Tree.Kind; import com.sun.source.tree.TypeParameterTree; import com.sun.source.tree.VariableTree; import com.sun.source.util.TreeScanner; @@ -1492,6 +1493,50 @@ assertEquals(golden, res); } + // created with + // cat test/unit/src/Test.java | sed 's|"|\\"|g' | sed 's/$/\\n" +/g' | sed 's/^/"/' + public void test159981() throws Exception { + String test = + "@interface A1 { }\n" + + "@interface A2 { }\n" + + "class Test2 {\n" + + " @A1\n" + + " |@A2\n" + + " static void m() { }\n" + + "}\n"; + String golden = test.replace("|", ""); + File file = new File(getWorkDir(), "Test.java"); + final int index = test.indexOf("|"); + assertTrue(index != -1); + TestUtilities.copyStringToFile(file, test.replace("|", "")); + JavaSource src = getJavaSource(file); + Task task = new Task() { + + public void run(WorkingCopy copy) throws Exception { + if (copy.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) { + return; + } + Tree node = copy.getTreeUtilities().pathFor(index).getLeaf(); + assertEquals(Kind.MODIFIERS, node.getKind()); + ModifiersTree original = (ModifiersTree) node; + TreeMaker make = copy.getTreeMaker(); + System.out.println("original: " + original); + List ann2 = new ArrayList(); + ann2.addAll(original.getAnnotations()); + // the reverse ordering breaks things + Collections.reverse(ann2); + Set fla2 = original.getFlags(); + ModifiersTree modified = make.Modifiers(fla2, ann2); + System.out.println("modified: " + modified); + copy.rewrite(original, modified); + } + }; + src.runModificationTask(task).commit(); + String res = TestUtilities.copyFileToString(file); + System.out.println(res); + assertEquals(golden, res); + } + String getGoldenPckg() { return ""; }