diff --git a/src/main/java/org/checkerframework/specimin/AnnotationTargetRemoverVisitor.java b/src/main/java/org/checkerframework/specimin/AnnotationTargetRemoverVisitor.java index f12397f1..0c900b58 100644 --- a/src/main/java/org/checkerframework/specimin/AnnotationTargetRemoverVisitor.java +++ b/src/main/java/org/checkerframework/specimin/AnnotationTargetRemoverVisitor.java @@ -25,9 +25,12 @@ import com.github.javaparser.ast.visitor.ModifierVisitor; import com.github.javaparser.ast.visitor.Visitable; import java.lang.annotation.ElementType; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; @@ -129,6 +132,10 @@ else if (targetAnnotation.isNormalAnnotationExpr()) { newAnnotation.append("Target("); newAnnotation.append('{'); + + List sortedElementTypes = new ArrayList<>(elementTypes); + Collections.sort(sortedElementTypes, (a, b) -> a.name().compareTo(b.name())); + Iterator iterator = elementTypes.iterator(); while (iterator.hasNext()) { ElementType elementType = iterator.next(); diff --git a/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/initialization/qual/Initialized.java b/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/initialization/qual/Initialized.java index f0b654af..382d051d 100644 --- a/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/initialization/qual/Initialized.java +++ b/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/initialization/qual/Initialized.java @@ -1,5 +1,5 @@ package org.checkerframework.checker.initialization.qual; -@java.lang.annotation.Target({ java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE }) +@java.lang.annotation.Target({ java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.METHOD }) public @interface Initialized { } diff --git a/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/nullness/qual/NonNull.java b/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/nullness/qual/NonNull.java index 9b23b52a..9ff56704 100644 --- a/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/nullness/qual/NonNull.java +++ b/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/nullness/qual/NonNull.java @@ -1,5 +1,5 @@ package org.checkerframework.checker.nullness.qual; -@java.lang.annotation.Target({ java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE }) +@java.lang.annotation.Target({ java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.METHOD }) public @interface NonNull { } diff --git a/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/nullness/qual/UnknownKeyFor.java b/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/nullness/qual/UnknownKeyFor.java index 9bbb7d0b..a4d1aaff 100644 --- a/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/nullness/qual/UnknownKeyFor.java +++ b/src/test/resources/annoingenerictarget/expected/org/checkerframework/checker/nullness/qual/UnknownKeyFor.java @@ -1,5 +1,5 @@ package org.checkerframework.checker.nullness.qual; -@java.lang.annotation.Target({ java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE }) +@java.lang.annotation.Target({ java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.METHOD }) public @interface UnknownKeyFor { } diff --git a/src/test/resources/syntheticannotations/expected/com/example/Bar.java b/src/test/resources/syntheticannotations/expected/com/example/Bar.java index 533e4625..e875d21d 100644 --- a/src/test/resources/syntheticannotations/expected/com/example/Bar.java +++ b/src/test/resources/syntheticannotations/expected/com/example/Bar.java @@ -1,6 +1,6 @@ package com.example; -@java.lang.annotation.Target({ java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.METHOD }) +@java.lang.annotation.Target({ java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.TYPE_USE }) public @interface Bar { public int value();