Search in sources :

Example 76 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method listArrayObjectWrongType.

@Test(expected = SourceChecker.CheckerError.class)
public void listArrayObjectWrongType() {
    AnnotationBuilder builder = new AnnotationBuilder(env, B.class);
    builder.setValue("strings", new Object[] { "m", "n", 1 });
    assertEquals(1, builder.build().getElementValues().size());
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Example 77 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class DependentTypesHelper method standardizeDependentTypeAnnotation.

/**
 * Standardizes a dependent type annotation.
 */
private AnnotationMirror standardizeDependentTypeAnnotation(FlowExpressionContext context, TreePath localScope, AnnotationMirror anno, boolean useLocalScope) {
    AnnotationBuilder builder = new AnnotationBuilder(factory.getProcessingEnv(), AnnotationUtils.annotationName(anno));
    for (String value : getListOfExpressionElements(anno)) {
        List<String> expressionStrings = AnnotationUtils.getElementValueArray(anno, value, String.class, true);
        List<String> standardizedStrings = new ArrayList<>();
        for (String expression : expressionStrings) {
            standardizedStrings.add(standardizeString(expression, context, localScope, useLocalScope));
        }
        builder.setValue(value, standardizedStrings);
    }
    return builder.build();
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) ArrayList(java.util.ArrayList)

Example 78 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class UnitsAnnotationClassLoader method isSupportedAnnotationClass.

/**
 * Custom filter for units annotations:
 *
 * <p>This filter will ignore (by returning false) any units annotation which is an alias of
 * another base unit annotation (identified via {@link UnitsMultiple} meta-annotation). Alias
 * annotations can still be used in source code; they are converted into a base annotation by
 * {@link UnitsAnnotatedTypeFactory#canonicalAnnotation(AnnotationMirror)}. This filter simply
 * makes sure that the alias annotations themselves don't become part of the type hierarchy as
 * their base annotations already are in the hierarchy.
 */
@Override
protected boolean isSupportedAnnotationClass(Class<? extends Annotation> annoClass) {
    // build the initial annotation mirror (missing prefix)
    AnnotationBuilder builder = new AnnotationBuilder(processingEnv, annoClass);
    AnnotationMirror initialResult = builder.build();
    // further refine to see if the annotation is an alias of some other SI Unit annotation
    for (AnnotationMirror metaAnno : initialResult.getAnnotationType().asElement().getAnnotationMirrors()) {
        // Units checker does not need to load the annotations of SI prefix multiples of base units.
        if (AnnotationUtils.areSameByName(metaAnno, "org.checkerframework.checker.units.qual.UnitsMultiple")) {
            return false;
        }
    }
    // Not an alias unit
    return true;
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder)

Example 79 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class FormatterLubGlbChecker method initChecker.

@SuppressWarnings("checkstyle:localvariablename")
@Override
public void initChecker() {
    super.initChecker();
    FormatterTreeUtil treeUtil = new FormatterTreeUtil(this);
    Elements elements = getElementUtils();
    AnnotationMirror UNKNOWNFORMAT = AnnotationBuilder.fromClass(elements, UnknownFormat.class);
    AnnotationMirror FORMAT = AnnotationBuilder.fromClass(elements, Format.class, AnnotationBuilder.elementNamesValues("value", new ConversionCategory[0]));
    AnnotationMirror INVALIDFORMAT = AnnotationBuilder.fromClass(elements, InvalidFormat.class, AnnotationBuilder.elementNamesValues("value", "dummy"));
    AnnotationMirror FORMATBOTTOM = AnnotationBuilder.fromClass(elements, FormatBottom.class);
    AnnotationBuilder builder = new AnnotationBuilder(processingEnv, InvalidFormat.class);
    builder.setValue("value", "Message");
    AnnotationMirror invalidFormatWithMessage = builder.build();
    builder = new AnnotationBuilder(processingEnv, InvalidFormat.class);
    builder.setValue("value", "Message2");
    AnnotationMirror invalidFormatWithMessage2 = builder.build();
    builder = new AnnotationBuilder(processingEnv, InvalidFormat.class);
    builder.setValue("value", "(\"Message\" or \"Message2\")");
    AnnotationMirror invalidFormatWithMessagesOred = builder.build();
    builder = new AnnotationBuilder(processingEnv, InvalidFormat.class);
    builder.setValue("value", "(\"Message\" and \"Message2\")");
    AnnotationMirror invalidFormatWithMessagesAnded = builder.build();
    ConversionCategory[] cc = new ConversionCategory[1];
    cc[0] = ConversionCategory.UNUSED;
    AnnotationMirror formatUnusedAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = ConversionCategory.GENERAL;
    AnnotationMirror formatGeneralAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = ConversionCategory.CHAR;
    AnnotationMirror formatCharAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = ConversionCategory.INT;
    AnnotationMirror formatIntAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = ConversionCategory.TIME;
    AnnotationMirror formatTimeAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = ConversionCategory.FLOAT;
    AnnotationMirror formatFloatAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = ConversionCategory.CHAR_AND_INT;
    AnnotationMirror formatCharAndIntAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = ConversionCategory.INT_AND_TIME;
    AnnotationMirror formatIntAndTimeAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = ConversionCategory.NULL;
    AnnotationMirror formatNullAnno = treeUtil.categoriesToFormatAnnotation(cc);
    QualifierHierarchy qh = ((BaseTypeVisitor<?>) visitor).getTypeFactory().getQualifierHierarchy();
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatIntAndTimeAnno), formatIntAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(INT_AND_TIME) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatGeneralAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(GENERAL) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatCharAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(CHAR) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatIntAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(INT) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatTimeAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(TIME) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatFloatAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(FLOAT) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatCharAndIntAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(CHAR_AND_INT) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatIntAndTimeAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(INT_AND_TIME) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatNullAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(NULL) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(GENERAL) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatGeneralAnno), formatGeneralAnno) : "GLB of @Format(GENERAL) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatCharAnno), formatGeneralAnno) : "GLB of @Format(GENERAL) and @Format(CHAR) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatIntAnno), formatGeneralAnno) : "GLB of @Format(GENERAL) and @Format(INT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatTimeAnno), formatGeneralAnno) : "GLB of @Format(GENERAL) and @Format(TIME) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatFloatAnno), formatGeneralAnno) : "GLB of @Format(GENERAL) and @Format(FLOAT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatCharAndIntAnno), formatGeneralAnno) : "GLB of @Format(GENERAL) and @Format(CHAR_AND_INT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatIntAndTimeAnno), formatGeneralAnno) : "GLB of @Format(GENERAL) and @Format(INT_AND_TIME) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatNullAnno), formatGeneralAnno) : "GLB of @Format(GENERAL) and @Format(NULL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(CHAR) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAnno, formatGeneralAnno), formatGeneralAnno) : "GLB of @Format(CHAR) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAnno, formatCharAnno), formatCharAnno) : "GLB of @Format(CHAR) and @Format(CHAR) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAnno, formatIntAnno), formatGeneralAnno) : "GLB of @Format(CHAR) and @Format(INT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAnno, formatTimeAnno), formatGeneralAnno) : "GLB of @Format(CHAR) and @Format(TIME) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAnno, formatFloatAnno), formatGeneralAnno) : "GLB of @Format(CHAR) and @Format(FLOAT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAnno, formatCharAndIntAnno), formatCharAnno) : "GLB of @Format(CHAR) and @Format(CHAR_AND_INT) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAnno, formatIntAndTimeAnno), formatGeneralAnno) : "GLB of @Format(CHAR) and @Format(INT_AND_TIME) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAnno, formatNullAnno), formatCharAnno) : "GLB of @Format(CHAR) and @Format(NULL) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(INT) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAnno, formatGeneralAnno), formatGeneralAnno) : "GLB of @Format(INT) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAnno, formatCharAnno), formatGeneralAnno) : "GLB of @Format(INT) and @Format(CHAR) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAnno, formatIntAnno), formatIntAnno) : "GLB of @Format(INT) and @Format(INT) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAnno, formatTimeAnno), formatGeneralAnno) : "GLB of @Format(INT) and @Format(TIME) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAnno, formatFloatAnno), formatGeneralAnno) : "GLB of @Format(INT) and @Format(FLOAT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAnno, formatCharAndIntAnno), formatIntAnno) : "GLB of @Format(INT) and @Format(CHAR_AND_INT) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAnno, formatIntAndTimeAnno), formatIntAnno) : "GLB of @Format(INT) and @Format(INT_AND_TIME) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAnno, formatNullAnno), formatIntAnno) : "GLB of @Format(INT) and @Format(NULL) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTimeAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(TIME) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTimeAnno, formatGeneralAnno), formatGeneralAnno) : "GLB of @Format(TIME) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTimeAnno, formatCharAnno), formatGeneralAnno) : "GLB of @Format(TIME) and @Format(CHAR) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTimeAnno, formatIntAnno), formatGeneralAnno) : "GLB of @Format(TIME) and @Format(INT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTimeAnno, formatTimeAnno), formatTimeAnno) : "GLB of @Format(TIME) and @Format(TIME) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTimeAnno, formatFloatAnno), formatGeneralAnno) : "GLB of @Format(TIME) and @Format(FLOAT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTimeAnno, formatCharAndIntAnno), formatGeneralAnno) : "GLB of @Format(TIME) and @Format(CHAR_AND_INT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTimeAnno, formatIntAndTimeAnno), formatTimeAnno) : "GLB of @Format(TIME) and @Format(INT_AND_TIME) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTimeAnno, formatNullAnno), formatTimeAnno) : "GLB of @Format(TIME) and @Format(NULL) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatFloatAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(FLOAT) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatFloatAnno, formatGeneralAnno), formatGeneralAnno) : "GLB of @Format(FLOAT) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatFloatAnno, formatCharAnno), formatGeneralAnno) : "GLB of @Format(FLOAT) and @Format(CHAR) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatFloatAnno, formatIntAnno), formatGeneralAnno) : "GLB of @Format(FLOAT) and @Format(INT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatFloatAnno, formatTimeAnno), formatGeneralAnno) : "GLB of @Format(FLOAT) and @Format(TIME) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatFloatAnno, formatFloatAnno), formatFloatAnno) : "GLB of @Format(FLOAT) and @Format(FLOAT) is not @Format(FLOAT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatFloatAnno, formatCharAndIntAnno), formatGeneralAnno) : "GLB of @Format(FLOAT) and @Format(CHAR_AND_INT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatFloatAnno, formatIntAndTimeAnno), formatGeneralAnno) : "GLB of @Format(FLOAT) and @Format(INT_AND_TIME) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatFloatAnno, formatNullAnno), formatFloatAnno) : "GLB of @Format(FLOAT) and @Format(NULL) is not @Format(FLOAT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatGeneralAnno), formatGeneralAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatCharAnno), formatCharAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(CHAR) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatIntAnno), formatIntAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(INT) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatTimeAnno), formatGeneralAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(TIME) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatFloatAnno), formatGeneralAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(FLOAT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatCharAndIntAnno), formatCharAndIntAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(CHAR_AND_INT) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatIntAndTimeAnno), formatIntAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(INT_AND_TIME) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatCharAndIntAnno, formatNullAnno), formatCharAndIntAnno) : "GLB of @Format(CHAR_AND_INT) and @Format(NULL) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAndTimeAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(INT_AND_TIME) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAndTimeAnno, formatGeneralAnno), formatGeneralAnno) : "GLB of @Format(INT_AND_TIME) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAndTimeAnno, formatCharAnno), formatGeneralAnno) : "GLB of @Format(INT_AND_TIME) and @Format(CHAR) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAndTimeAnno, formatIntAnno), formatIntAnno) : "GLB of @Format(INT_AND_TIME) and @Format(INT) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAndTimeAnno, formatTimeAnno), formatTimeAnno) : "GLB of @Format(INT_AND_TIME) and @Format(TIME) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAndTimeAnno, formatFloatAnno), formatGeneralAnno) : "GLB of @Format(INT_AND_TIME) and @Format(FLOAT) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAndTimeAnno, formatCharAndIntAnno), formatIntAnno) : "GLB of @Format(INT_AND_TIME) and @Format(CHAR_AND_INT) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAndTimeAnno, formatIntAndTimeAnno), formatIntAndTimeAnno) : "GLB of @Format(INT_AND_TIME) and @Format(INT_AND_TIME) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatIntAndTimeAnno, formatNullAnno), formatIntAndTimeAnno) : "GLB of @Format(INT_AND_TIME) and @Format(NULL) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatNullAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(NULL) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatNullAnno, formatGeneralAnno), formatGeneralAnno) : "GLB of @Format(NULL) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatNullAnno, formatCharAnno), formatCharAnno) : "GLB of @Format(NULL) and @Format(CHAR) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatNullAnno, formatIntAnno), formatIntAnno) : "GLB of @Format(NULL) and @Format(INT) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatNullAnno, formatTimeAnno), formatTimeAnno) : "GLB of @Format(NULL) and @Format(TIME) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatNullAnno, formatFloatAnno), formatFloatAnno) : "GLB of @Format(NULL) and @Format(FLOAT) is not @Format(FLOAT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatNullAnno, formatCharAndIntAnno), formatCharAndIntAnno) : "GLB of @Format(NULL) and @Format(CHAR_AND_INT) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatNullAnno, formatIntAndTimeAnno), formatIntAndTimeAnno) : "GLB of @Format(NULL) and @Format(INT_AND_TIME) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatNullAnno, formatNullAnno), formatNullAnno) : "GLB of @Format(NULL) and @Format(NULL) is not @Format(NULL)!";
    // Now test with two ConversionCategory at a time:
    ConversionCategory[] cc2 = new ConversionCategory[2];
    cc2[0] = ConversionCategory.CHAR_AND_INT;
    cc2[1] = ConversionCategory.FLOAT;
    AnnotationMirror formatTwoConvCat1 = treeUtil.categoriesToFormatAnnotation(cc2);
    cc2[0] = ConversionCategory.INT;
    cc2[1] = ConversionCategory.CHAR;
    AnnotationMirror formatTwoConvCat2 = treeUtil.categoriesToFormatAnnotation(cc2);
    cc2[0] = ConversionCategory.INT;
    cc2[1] = ConversionCategory.GENERAL;
    AnnotationMirror formatTwoConvCat3 = treeUtil.categoriesToFormatAnnotation(cc2);
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTwoConvCat1, formatTwoConvCat2), formatTwoConvCat3) : "GLB of @Format([CHAR_AND_INT,FLOAT]) and @Format([INT,CHAR]) is not" + " @Format([INT,GENERAL])!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatGeneralAnno, formatTwoConvCat1), formatGeneralAnno) : "GLB of @I18nFormat(GENERAL) and @I18nFormat([CHAR_AND_INT,FLOAT]) is not" + " @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatTwoConvCat2, formatNullAnno), formatIntAnno) : "GLB of @I18nFormat([INT,CHAR]) and @I18nFormat(NULL) is not @I18nFormat(INT)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(UNKNOWNFORMAT, UNKNOWNFORMAT), UNKNOWNFORMAT) : "GLB of @UnknownFormat and @UnknownFormat is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(UNKNOWNFORMAT, FORMAT), FORMAT) : "GLB of @UnknownFormat and @Format(null) is not @Format(null)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(UNKNOWNFORMAT, formatUnusedAnno), formatUnusedAnno) : "GLB of @UnknownFormat and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(UNKNOWNFORMAT, INVALIDFORMAT), INVALIDFORMAT) : "GLB of @UnknownFormat and @InvalidFormat(null) is not @InvalidFormat(null)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(UNKNOWNFORMAT, invalidFormatWithMessage), invalidFormatWithMessage) : "GLB of @UnknownFormat and @InvalidFormat(\"Message\") is not" + " @InvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(UNKNOWNFORMAT, FORMATBOTTOM), FORMATBOTTOM) : "GLB of @UnknownFormat and @FormatBottom is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMAT, UNKNOWNFORMAT), FORMAT) : "GLB of @Format(null) and @UnknownFormat is not @Format(null)!";
    // practice. Skipping this case as it causes an expected crash.
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMAT, INVALIDFORMAT), FORMATBOTTOM) : "GLB of @Format(null) and @InvalidFormat(null) is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMAT, invalidFormatWithMessage), FORMATBOTTOM) : "GLB of @Format(null) and @InvalidFormat(\"Message\") is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMAT, FORMATBOTTOM), FORMATBOTTOM) : "GLB of @Format(null) and @FormatBottom is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, UNKNOWNFORMAT), formatUnusedAnno) : "GLB of @Format(UNUSED) and @UnknownFormat is not @Format(UNUSED)!";
    // practice. Skipping this case as it causes an expected crash.
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, formatUnusedAnno), formatUnusedAnno) : "GLB of @Format(UNUSED) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, INVALIDFORMAT), FORMATBOTTOM) : "GLB of @Format(UNUSED) and @InvalidFormat(null) is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, invalidFormatWithMessage), FORMATBOTTOM) : "GLB of @Format(UNUSED) and @InvalidFormat(\"Message\") is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(formatUnusedAnno, FORMATBOTTOM), FORMATBOTTOM) : "GLB of @Format(UNUSED) and @FormatBottom is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(INVALIDFORMAT, UNKNOWNFORMAT), INVALIDFORMAT) : "GLB of @InvalidFormat(null) and @UnknownFormat is not @InvalidFormat(null)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(INVALIDFORMAT, FORMAT), FORMATBOTTOM) : "GLB of @InvalidFormat(null) and @Format(null) is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(INVALIDFORMAT, formatUnusedAnno), FORMATBOTTOM) : "GLB of @InvalidFormat(null) and @Format(UNUSED) is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(INVALIDFORMAT, FORMATBOTTOM), FORMATBOTTOM) : "GLB of @InvalidFormat(null) and @FormatBottom is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(invalidFormatWithMessage, UNKNOWNFORMAT), invalidFormatWithMessage) : "GLB of @InvalidFormat(\"Message\") and @UnknownFormat is not" + " @InvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(invalidFormatWithMessage, FORMAT), FORMATBOTTOM) : "GLB of @InvalidFormat(\"Message\") and @Format(null) is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(invalidFormatWithMessage, formatUnusedAnno), FORMATBOTTOM) : "GLB of @InvalidFormat(\"Message\") and @Format(UNUSED) is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(invalidFormatWithMessage, invalidFormatWithMessage), invalidFormatWithMessage) : "GLB of @InvalidFormat(\"Message\") and @InvalidFormat(\"Message\") is not" + " @InvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(invalidFormatWithMessage, invalidFormatWithMessage2), invalidFormatWithMessagesAnded) : "GLB of @InvalidFormat(\"Message\") and @InvalidFormat(\"Message2\") is not" + " @InvalidFormat(\"(\"Message\" and \"Message2\")\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(invalidFormatWithMessage, FORMATBOTTOM), FORMATBOTTOM) : "GLB of @InvalidFormat(\"Message\") and @FormatBottom is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMATBOTTOM, UNKNOWNFORMAT), FORMATBOTTOM) : "GLB of @FormatBottom and @UnknownFormat is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMATBOTTOM, FORMAT), FORMATBOTTOM) : "GLB of @FormatBottom and @Format(null) is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMATBOTTOM, formatUnusedAnno), FORMATBOTTOM) : "GLB of @FormatBottom and @Format(UNUSED) is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMATBOTTOM, INVALIDFORMAT), FORMATBOTTOM) : "GLB of @FormatBottom and @InvalidFormat(null) is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMATBOTTOM, invalidFormatWithMessage), FORMATBOTTOM) : "GLB of @FormatBottom and @InvalidFormat(\"Message\") is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FORMATBOTTOM, FORMATBOTTOM), FORMATBOTTOM) : "GLB of @FormatBottom and @FormatBottom is not @FormatBottom!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatUnusedAnno), formatUnusedAnno) : "LUB of @Format(UNUSED) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatGeneralAnno), formatGeneralAnno) : "LUB of @Format(UNUSED) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatCharAnno), formatCharAnno) : "LUB of @Format(UNUSED) and @Format(CHAR) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatIntAnno), formatIntAnno) : "LUB of @Format(UNUSED) and @Format(INT) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatTimeAnno), formatTimeAnno) : "LUB of @Format(UNUSED) and @Format(TIME) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatFloatAnno), formatFloatAnno) : "LUB of @Format(UNUSED) and @Format(FLOAT) is not @Format(FLOAT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatCharAndIntAnno), formatCharAndIntAnno) : "LUB of @Format(UNUSED) and @Format(CHAR_AND_INT) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatIntAndTimeAnno), formatIntAndTimeAnno) : "LUB of @Format(UNUSED) and @Format(INT_AND_TIME) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatNullAnno), formatNullAnno) : "LUB of @Format(UNUSED) and @Format(NULL) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatUnusedAnno), formatGeneralAnno) : "LUB of @Format(GENERAL) and @Format(UNUSED) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatGeneralAnno), formatGeneralAnno) : "LUB of @Format(GENERAL) and @Format(GENERAL) is not @Format(GENERAL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatCharAnno), formatCharAnno) : "LUB of @Format(GENERAL) and @Format(CHAR) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatIntAnno), formatIntAnno) : "LUB of @Format(GENERAL) and @Format(INT) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatTimeAnno), formatTimeAnno) : "LUB of @Format(GENERAL) and @Format(TIME) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatFloatAnno), formatFloatAnno) : "LUB of @Format(GENERAL) and @Format(FLOAT) is not @Format(FLOAT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatCharAndIntAnno), formatCharAndIntAnno) : "LUB of @Format(GENERAL) and @Format(CHAR_AND_INT) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatIntAndTimeAnno), formatIntAndTimeAnno) : "LUB of @Format(GENERAL) and @Format(INT_AND_TIME) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatNullAnno), formatNullAnno) : "LUB of @Format(GENERAL) and @Format(NULL) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAnno, formatUnusedAnno), formatCharAnno) : "LUB of @Format(CHAR) and @Format(UNUSED) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAnno, formatGeneralAnno), formatCharAnno) : "LUB of @Format(CHAR) and @Format(GENERAL) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAnno, formatCharAnno), formatCharAnno) : "LUB of @Format(CHAR) and @Format(CHAR) is not @Format(CHAR)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAnno, formatIntAnno), formatCharAndIntAnno) : "LUB of @Format(CHAR) and @Format(INT) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAnno, formatTimeAnno), formatNullAnno) : "LUB of @Format(CHAR) and @Format(TIME) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAnno, formatFloatAnno), formatNullAnno) : "LUB of @Format(CHAR) and @Format(FLOAT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAnno, formatCharAndIntAnno), formatCharAndIntAnno) : "LUB of @Format(CHAR) and @Format(CHAR_AND_INT) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAnno, formatIntAndTimeAnno), formatNullAnno) : "LUB of @Format(CHAR) and @Format(INT_AND_TIME) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAnno, formatNullAnno), formatNullAnno) : "LUB of @Format(CHAR) and @Format(NULL) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAnno, formatUnusedAnno), formatIntAnno) : "LUB of @Format(INT) and @Format(UNUSED) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAnno, formatGeneralAnno), formatIntAnno) : "LUB of @Format(INT) and @Format(GENERAL) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAnno, formatCharAnno), formatCharAndIntAnno) : "LUB of @Format(INT) and @Format(CHAR) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAnno, formatIntAnno), formatIntAnno) : "LUB of @Format(INT) and @Format(INT) is not @Format(INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAnno, formatTimeAnno), formatIntAndTimeAnno) : "LUB of @Format(INT) and @Format(TIME) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAnno, formatFloatAnno), formatNullAnno) : "LUB of @Format(INT) and @Format(FLOAT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAnno, formatCharAndIntAnno), formatCharAndIntAnno) : "LUB of @Format(INT) and @Format(CHAR_AND_INT) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAnno, formatIntAndTimeAnno), formatIntAndTimeAnno) : "LUB of @Format(INT) and @Format(INT_AND_TIME) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAnno, formatNullAnno), formatNullAnno) : "LUB of @Format(INT) and @Format(NULL) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTimeAnno, formatUnusedAnno), formatTimeAnno) : "LUB of @Format(TIME) and @Format(UNUSED) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTimeAnno, formatGeneralAnno), formatTimeAnno) : "LUB of @Format(TIME) and @Format(GENERAL) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTimeAnno, formatCharAnno), formatNullAnno) : "LUB of @Format(TIME) and @Format(CHAR) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTimeAnno, formatIntAnno), formatIntAndTimeAnno) : "LUB of @Format(TIME) and @Format(INT) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTimeAnno, formatTimeAnno), formatTimeAnno) : "LUB of @Format(TIME) and @Format(TIME) is not @Format(TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTimeAnno, formatFloatAnno), formatNullAnno) : "LUB of @Format(TIME) and @Format(FLOAT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTimeAnno, formatCharAndIntAnno), formatNullAnno) : "LUB of @Format(TIME) and @Format(CHAR_AND_INT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTimeAnno, formatIntAndTimeAnno), formatIntAndTimeAnno) : "LUB of @Format(TIME) and @Format(INT_AND_TIME) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTimeAnno, formatNullAnno), formatNullAnno) : "LUB of @Format(TIME) and @Format(NULL) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatFloatAnno, formatUnusedAnno), formatFloatAnno) : "LUB of @Format(FLOAT) and @Format(UNUSED) is not @Format(FLOAT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatFloatAnno, formatGeneralAnno), formatFloatAnno) : "LUB of @Format(FLOAT) and @Format(GENERAL) is not @Format(FLOAT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatFloatAnno, formatCharAnno), formatNullAnno) : "LUB of @Format(FLOAT) and @Format(CHAR) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatFloatAnno, formatIntAnno), formatNullAnno) : "LUB of @Format(FLOAT) and @Format(INT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatFloatAnno, formatTimeAnno), formatNullAnno) : "LUB of @Format(FLOAT) and @Format(TIME) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatFloatAnno, formatFloatAnno), formatFloatAnno) : "LUB of @Format(FLOAT) and @Format(FLOAT) is not @Format(FLOAT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatFloatAnno, formatCharAndIntAnno), formatNullAnno) : "LUB of @Format(FLOAT) and @Format(CHAR_AND_INT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatFloatAnno, formatIntAndTimeAnno), formatNullAnno) : "LUB of @Format(FLOAT) and @Format(INT_AND_TIME) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatFloatAnno, formatNullAnno), formatNullAnno) : "LUB of @Format(FLOAT) and @Format(NULL) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAndIntAnno, formatUnusedAnno), formatCharAndIntAnno) : "LUB of @Format(CHAR_AND_INT) and @Format(UNUSED) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAndIntAnno, formatGeneralAnno), formatCharAndIntAnno) : "LUB of @Format(CHAR_AND_INT) and @Format(GENERAL) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAndIntAnno, formatCharAnno), formatCharAndIntAnno) : "LUB of @Format(CHAR_AND_INT) and @Format(CHAR) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAndIntAnno, formatIntAnno), formatCharAndIntAnno) : "LUB of @Format(CHAR_AND_INT) and @Format(INT) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAndIntAnno, formatTimeAnno), formatNullAnno) : "LUB of @Format(CHAR_AND_INT) and @Format(TIME) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAndIntAnno, formatFloatAnno), formatNullAnno) : "LUB of @Format(CHAR_AND_INT) and @Format(FLOAT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAndIntAnno, formatCharAndIntAnno), formatCharAndIntAnno) : "LUB of @Format(CHAR_AND_INT) and @Format(CHAR_AND_INT) is not @Format(CHAR_AND_INT)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAndIntAnno, formatIntAndTimeAnno), formatNullAnno) : "LUB of @Format(CHAR_AND_INT) and @Format(INT_AND_TIME) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatCharAndIntAnno, formatNullAnno), formatNullAnno) : "LUB of @Format(CHAR_AND_INT) and @Format(NULL) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAndTimeAnno, formatUnusedAnno), formatIntAndTimeAnno) : "LUB of @Format(INT_AND_TIME) and @Format(UNUSED) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAndTimeAnno, formatGeneralAnno), formatIntAndTimeAnno) : "LUB of @Format(INT_AND_TIME) and @Format(GENERAL) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAndTimeAnno, formatCharAnno), formatNullAnno) : "LUB of @Format(INT_AND_TIME) and @Format(CHAR) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAndTimeAnno, formatIntAnno), formatIntAndTimeAnno) : "LUB of @Format(INT_AND_TIME) and @Format(INT) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAndTimeAnno, formatTimeAnno), formatIntAndTimeAnno) : "LUB of @Format(INT_AND_TIME) and @Format(TIME) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAndTimeAnno, formatFloatAnno), formatNullAnno) : "LUB of @Format(INT_AND_TIME) and @Format(FLOAT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAndTimeAnno, formatCharAndIntAnno), formatNullAnno) : "LUB of @Format(INT_AND_TIME) and @Format(CHAR_AND_INT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAndTimeAnno, formatIntAndTimeAnno), formatIntAndTimeAnno) : "LUB of @Format(INT_AND_TIME) and @Format(INT_AND_TIME) is not @Format(INT_AND_TIME)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatIntAndTimeAnno, formatNullAnno), formatNullAnno) : "LUB of @Format(INT_AND_TIME) and @Format(NULL) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatNullAnno, formatUnusedAnno), formatNullAnno) : "LUB of @Format(NULL) and @Format(UNUSED) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatNullAnno, formatGeneralAnno), formatNullAnno) : "LUB of @Format(NULL) and @Format(GENERAL) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatNullAnno, formatCharAnno), formatNullAnno) : "LUB of @Format(NULL) and @Format(CHAR) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatNullAnno, formatIntAnno), formatNullAnno) : "LUB of @Format(NULL) and @Format(INT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatNullAnno, formatTimeAnno), formatNullAnno) : "LUB of @Format(NULL) and @Format(TIME) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatNullAnno, formatFloatAnno), formatNullAnno) : "LUB of @Format(NULL) and @Format(FLOAT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatNullAnno, formatCharAndIntAnno), formatNullAnno) : "LUB of @Format(NULL) and @Format(CHAR_AND_INT) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatNullAnno, formatIntAndTimeAnno), formatNullAnno) : "LUB of @Format(NULL) and @Format(INT_AND_TIME) is not @Format(NULL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatNullAnno, formatNullAnno), formatNullAnno) : "LUB of @Format(NULL) and @Format(NULL) is not @Format(NULL)!";
    // Now test with two ConversionCategory at a time:
    cc2[0] = ConversionCategory.CHAR_AND_INT;
    cc2[1] = ConversionCategory.NULL;
    AnnotationMirror formatTwoConvCat4 = treeUtil.categoriesToFormatAnnotation(cc2);
    cc2[0] = ConversionCategory.NULL;
    cc2[1] = ConversionCategory.CHAR;
    AnnotationMirror formatTwoConvCat5 = treeUtil.categoriesToFormatAnnotation(cc2);
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTwoConvCat1, formatTwoConvCat2), formatTwoConvCat4) : "LUB of @Format([CHAR_AND_INT,FLOAT]) and @Format([INT,CHAR]) is not" + " @Format([CHAR_AND_INT,NULL])!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatGeneralAnno, formatTwoConvCat1), formatTwoConvCat1) : "LUB of @I18nFormat(GENERAL) and @I18nFormat([CHAR_AND_INT,FLOAT]) is not" + " @I18nFormat([CHAR_AND_INT,FLOAT])!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatTwoConvCat2, formatNullAnno), formatTwoConvCat5) : "LUB of @I18nFormat([INT,CHAR]) and @I18nFormat(NULL) is not @I18nFormat([NULL,CHAR])!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(UNKNOWNFORMAT, UNKNOWNFORMAT), UNKNOWNFORMAT) : "LUB of @UnknownFormat and @UnknownFormat is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(UNKNOWNFORMAT, FORMAT), UNKNOWNFORMAT) : "LUB of @UnknownFormat and @Format(null) is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(UNKNOWNFORMAT, formatUnusedAnno), UNKNOWNFORMAT) : "LUB of @UnknownFormat and @Format(UNUSED) is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(UNKNOWNFORMAT, INVALIDFORMAT), UNKNOWNFORMAT) : "LUB of @UnknownFormat and @InvalidFormat(null) is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(UNKNOWNFORMAT, invalidFormatWithMessage), UNKNOWNFORMAT) : "LUB of @UnknownFormat and @InvalidFormat(\"Message\") is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(UNKNOWNFORMAT, FORMATBOTTOM), UNKNOWNFORMAT) : "LUB of @UnknownFormat and @FormatBottom is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMAT, UNKNOWNFORMAT), UNKNOWNFORMAT) : "LUB of @Format(null) and @UnknownFormat is not @UnknownFormat!";
    // practice. Skipping this case as it causes an expected crash.
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMAT, INVALIDFORMAT), UNKNOWNFORMAT) : "LUB of @Format(null) and @InvalidFormat(null) is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMAT, invalidFormatWithMessage), UNKNOWNFORMAT) : "LUB of @Format(null) and @InvalidFormat(\"Message\") is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMAT, FORMATBOTTOM), FORMAT) : "LUB of @Format(null) and @FormatBottom is not @Format(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, UNKNOWNFORMAT), UNKNOWNFORMAT) : "LUB of @Format(UNUSED) and @UnknownFormat is not @UnknownFormat!";
    // practice. Skipping this case as it causes an expected crash.
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, formatUnusedAnno), formatUnusedAnno) : "LUB of @Format(UNUSED) and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, INVALIDFORMAT), UNKNOWNFORMAT) : "LUB of @Format(UNUSED) and @InvalidFormat(null) is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, invalidFormatWithMessage), UNKNOWNFORMAT) : "LUB of @Format(UNUSED) and @InvalidFormat(\"Message\") is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(formatUnusedAnno, FORMATBOTTOM), formatUnusedAnno) : "LUB of @Format(UNUSED) and @FormatBottom is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(INVALIDFORMAT, UNKNOWNFORMAT), UNKNOWNFORMAT) : "LUB of @InvalidFormat(null) and @UnknownFormat is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(INVALIDFORMAT, FORMAT), UNKNOWNFORMAT) : "LUB of @InvalidFormat(null) and @Format(null) is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(INVALIDFORMAT, formatUnusedAnno), UNKNOWNFORMAT) : "LUB of @InvalidFormat(null) and @Format(UNUSED) is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(INVALIDFORMAT, FORMATBOTTOM), INVALIDFORMAT) : "LUB of @InvalidFormat(null) and @FormatBottom is not @InvalidFormat(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(invalidFormatWithMessage, UNKNOWNFORMAT), UNKNOWNFORMAT) : "LUB of @InvalidFormat(\"Message\") and @UnknownFormat is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(invalidFormatWithMessage, FORMAT), UNKNOWNFORMAT) : "LUB of @InvalidFormat(\"Message\") and @Format(null) is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(invalidFormatWithMessage, formatUnusedAnno), UNKNOWNFORMAT) : "LUB of @InvalidFormat(\"Message\") and @Format(UNUSED) is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(invalidFormatWithMessage, invalidFormatWithMessage), invalidFormatWithMessage) : "LUB of @InvalidFormat(\"Message\") and @InvalidFormat(\"Message\") is not" + " @InvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(invalidFormatWithMessage, invalidFormatWithMessage2), invalidFormatWithMessagesOred) : "LUB of @InvalidFormat(\"Message\") and @InvalidFormat(\"Message2\") is not" + " @InvalidFormat(\"(\"Message\" or \"Message2\")\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(invalidFormatWithMessage, FORMATBOTTOM), invalidFormatWithMessage) : "LUB of @InvalidFormat(\"Message\") and @FormatBottom is not" + " @InvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMATBOTTOM, UNKNOWNFORMAT), UNKNOWNFORMAT) : "LUB of @FormatBottom and @UnknownFormat is not @UnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMATBOTTOM, FORMAT), FORMAT) : "LUB of @FormatBottom and @Format(null) is not @Format(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMATBOTTOM, formatUnusedAnno), formatUnusedAnno) : "LUB of @FormatBottom and @Format(UNUSED) is not @Format(UNUSED)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMATBOTTOM, INVALIDFORMAT), INVALIDFORMAT) : "LUB of @FormatBottom and @InvalidFormat(null) is not @InvalidFormat(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMATBOTTOM, invalidFormatWithMessage), invalidFormatWithMessage) : "LUB of @FormatBottom and @InvalidFormat(\"Message\") is not" + " @InvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FORMATBOTTOM, FORMATBOTTOM), FORMATBOTTOM) : "LUB of @FormatBottom and @FormatBottom is not @FormatBottom!";
}
Also used : InvalidFormat(org.checkerframework.checker.formatter.qual.InvalidFormat) AnnotationMirror(javax.lang.model.element.AnnotationMirror) FormatterTreeUtil(org.checkerframework.checker.formatter.FormatterTreeUtil) ConversionCategory(org.checkerframework.checker.formatter.qual.ConversionCategory) AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) QualifierHierarchy(org.checkerframework.framework.type.QualifierHierarchy) Elements(javax.lang.model.util.Elements)

Example 80 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class UnitsRelationsTools method buildAnnoMirrorWithSpecificPrefix.

/**
 * Creates an AnnotationMirror representing a unit defined by annoClass, with the specific Prefix
 * p.
 *
 * <p>This interface is intended only for subclasses of UnitsRelations; other clients should use
 * {@link #buildAnnoMirrorWithSpecificPrefix(ProcessingEnvironment, CharSequence, Prefix)}
 *
 * @param env the Checker Processing Environment, provided as a parameter in init() of a
 *     UnitsRelations implementation
 * @param annoClass the Class of an Annotation representing a Unit (eg m.class for meters)
 * @param p a Prefix value
 * @return an AnnotationMirror of the Unit with the Prefix p, or null if it cannot be constructed
 */
@Nullable
public static AnnotationMirror buildAnnoMirrorWithSpecificPrefix(final ProcessingEnvironment env, final Class<? extends Annotation> annoClass, final Prefix p) {
    AnnotationBuilder builder = new AnnotationBuilder(env, annoClass);
    builder.setValue("value", p);
    return builder.build();
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Aggregations

AnnotationBuilder (org.checkerframework.javacutil.AnnotationBuilder)117 Test (org.junit.Test)60 AnnotationMirror (javax.lang.model.element.AnnotationMirror)21 Nullable (org.checkerframework.checker.nullness.qual.Nullable)6 ArrayList (java.util.ArrayList)5 Elements (javax.lang.model.util.Elements)4 QualifierHierarchy (org.checkerframework.framework.type.QualifierHierarchy)4 List (java.util.List)3 TypeElement (javax.lang.model.element.TypeElement)3 NodeList (com.github.javaparser.ast.NodeList)2 Expression (com.github.javaparser.ast.expr.Expression)2 MarkerAnnotationExpr (com.github.javaparser.ast.expr.MarkerAnnotationExpr)2 MemberValuePair (com.github.javaparser.ast.expr.MemberValuePair)2 NormalAnnotationExpr (com.github.javaparser.ast.expr.NormalAnnotationExpr)2 SingleMemberAnnotationExpr (com.github.javaparser.ast.expr.SingleMemberAnnotationExpr)2 TreeSet (java.util.TreeSet)2 TypeMirror (javax.lang.model.type.TypeMirror)2 FormatterTreeUtil (org.checkerframework.checker.formatter.FormatterTreeUtil)2 ConversionCategory (org.checkerframework.checker.formatter.qual.ConversionCategory)2 InvalidFormat (org.checkerframework.checker.formatter.qual.InvalidFormat)2