Search in sources :

Example 6 with QualifierHierarchy

use of org.checkerframework.framework.type.QualifierHierarchy in project checker-framework by typetools.

the class BaseTypeVisitor method checkPostcondition.

/**
 * Check that the expression's type is annotated with {@code annotation} at the regular exit
 * store.
 *
 * @param methodTree declaration of the method
 * @param annotation expression's type must have this annotation
 * @param expression the expression that the postcondition concerns
 */
protected void checkPostcondition(MethodTree methodTree, AnnotationMirror annotation, Receiver expression) {
    CFAbstractStore<?, ?> exitStore = atypeFactory.getRegularExitStore(methodTree);
    if (exitStore == null) {
    // if there is no regular exitStore, then the method
    // cannot reach the regular exit and there is no need to
    // check anything
    } else {
        CFAbstractValue<?> value = exitStore.getValue(expression);
        AnnotationMirror inferredAnno = null;
        if (value != null) {
            QualifierHierarchy hierarchy = atypeFactory.getQualifierHierarchy();
            Set<AnnotationMirror> annos = value.getAnnotations();
            inferredAnno = hierarchy.findAnnotationInSameHierarchy(annos, annotation);
        }
        if (!checkContract(expression, annotation, inferredAnno, exitStore)) {
            checker.report(Result.failure("contracts.postcondition.not.satisfied", expression.toString()), methodTree);
        }
    }
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) QualifierHierarchy(org.checkerframework.framework.type.QualifierHierarchy)

Example 7 with QualifierHierarchy

use of org.checkerframework.framework.type.QualifierHierarchy in project checker-framework by typetools.

the class BaseTypeVisitor method checkConditionalPostcondition.

/**
 * Check that the expression's type is annotated with {@code annotation} at every regular exit
 * that returns {@code result}
 *
 * @param node tree of method with the postcondition
 * @param annotation expression's type must have this annotation
 * @param expression the expression that the postcondition concerns
 * @param result result for which the postcondition is valid
 */
protected void checkConditionalPostcondition(MethodTree node, AnnotationMirror annotation, Receiver expression, boolean result) {
    boolean booleanReturnType = TypesUtils.isBooleanType(TreeUtils.typeOf(node.getReturnType()));
    if (!booleanReturnType) {
        checker.report(Result.failure("contracts.conditional.postcondition.invalid.returntype"), node);
        // annotation is invalid.
        return;
    }
    for (Pair<ReturnNode, ?> pair : atypeFactory.getReturnStatementStores(node)) {
        ReturnNode returnStmt = pair.first;
        Node retValNode = returnStmt.getResult();
        Boolean retVal = retValNode instanceof BooleanLiteralNode ? ((BooleanLiteralNode) retValNode).getValue() : null;
        TransferResult<?, ?> transferResult = (TransferResult<?, ?>) pair.second;
        if (transferResult == null) {
            // Unreachable return statements have no stores, but there is no need to check them.
            continue;
        }
        CFAbstractStore<?, ?> exitStore = (CFAbstractStore<?, ?>) (result ? transferResult.getThenStore() : transferResult.getElseStore());
        CFAbstractValue<?> value = exitStore.getValue(expression);
        // this means the result is a boolean literal
        if (!(retVal == null || retVal == result)) {
            continue;
        }
        AnnotationMirror inferredAnno = null;
        if (value != null) {
            QualifierHierarchy hierarchy = atypeFactory.getQualifierHierarchy();
            Set<AnnotationMirror> annos = value.getAnnotations();
            inferredAnno = hierarchy.findAnnotationInSameHierarchy(annos, annotation);
        }
        if (!checkContract(expression, annotation, inferredAnno, exitStore)) {
            checker.report(Result.failure("contracts.conditional.postcondition.not.satisfied", expression.toString()), returnStmt.getTree());
        }
    }
}
Also used : BooleanLiteralNode(org.checkerframework.dataflow.cfg.node.BooleanLiteralNode) BooleanLiteralNode(org.checkerframework.dataflow.cfg.node.BooleanLiteralNode) ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) Node(org.checkerframework.dataflow.cfg.node.Node) TransferResult(org.checkerframework.dataflow.analysis.TransferResult) ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) AnnotationMirror(javax.lang.model.element.AnnotationMirror) CFAbstractStore(org.checkerframework.framework.flow.CFAbstractStore) QualifierHierarchy(org.checkerframework.framework.type.QualifierHierarchy)

Example 8 with QualifierHierarchy

use of org.checkerframework.framework.type.QualifierHierarchy in project checker-framework by typetools.

the class FormatterLubGlbChecker method initChecker.

@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);
    AnnotationMirror INVALIDFORMAT = AnnotationBuilder.fromClass(elements, InvalidFormat.class);
    AnnotationMirror FORMATBOTTOM = AnnotationBuilder.fromClass(elements, FormatBottom.class);
    AnnotationBuilder builder = new AnnotationBuilder(processingEnv, InvalidFormat.class.getCanonicalName());
    builder.setValue("value", "Message");
    AnnotationMirror InvalidFormatWithMessage = builder.build();
    builder = new AnnotationBuilder(processingEnv, InvalidFormat.class.getCanonicalName());
    builder.setValue("value", "Message2");
    AnnotationMirror InvalidFormatWithMessage2 = builder.build();
    builder = new AnnotationBuilder(processingEnv, InvalidFormat.class.getCanonicalName());
    builder.setValue("value", "(\"Message\" or \"Message2\")");
    AnnotationMirror InvalidFormatWithMessagesOred = builder.build();
    builder = new AnnotationBuilder(processingEnv, InvalidFormat.class.getCanonicalName());
    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 9 with QualifierHierarchy

use of org.checkerframework.framework.type.QualifierHierarchy in project checker-framework by typetools.

the class I18nFormatterLubGlbChecker method initChecker.

@Override
public void initChecker() {
    super.initChecker();
    I18nFormatterTreeUtil treeUtil = new I18nFormatterTreeUtil(this);
    Elements elements = getElementUtils();
    AnnotationMirror I18NUNKNOWNFORMAT = AnnotationBuilder.fromClass(elements, I18nUnknownFormat.class);
    AnnotationMirror I18NFORMAT = AnnotationBuilder.fromClass(elements, I18nFormat.class);
    AnnotationMirror I18NINVALIDFORMAT = AnnotationBuilder.fromClass(elements, I18nInvalidFormat.class);
    AnnotationMirror I18NFORMATFOR = AnnotationBuilder.fromClass(elements, I18nFormatFor.class);
    AnnotationMirror I18NFORMATBOTTOM = AnnotationBuilder.fromClass(elements, I18nFormatBottom.class);
    AnnotationBuilder builder = new AnnotationBuilder(processingEnv, I18nInvalidFormat.class.getCanonicalName());
    builder.setValue("value", "Message");
    AnnotationMirror I18nInvalidFormatWithMessage = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nInvalidFormat.class.getCanonicalName());
    builder.setValue("value", "Message2");
    AnnotationMirror I18nInvalidFormatWithMessage2 = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nInvalidFormat.class.getCanonicalName());
    builder.setValue("value", "(\"Message\" or \"Message2\")");
    AnnotationMirror I18nInvalidFormatWithMessagesOred = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nInvalidFormat.class.getCanonicalName());
    builder.setValue("value", "(\"Message\" and \"Message2\")");
    AnnotationMirror I18nInvalidFormatWithMessagesAnded = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nFormatFor.class.getCanonicalName());
    builder.setValue("value", "#1");
    AnnotationMirror I18nFormatForWithValue1 = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nFormatFor.class.getCanonicalName());
    builder.setValue("value", "#2");
    AnnotationMirror I18nFormatForWithValue2 = builder.build();
    I18nConversionCategory[] cc = new I18nConversionCategory[1];
    cc[0] = I18nConversionCategory.UNUSED;
    AnnotationMirror I18nFormatUnusedAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = I18nConversionCategory.GENERAL;
    AnnotationMirror I18nFormatGeneralAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = I18nConversionCategory.DATE;
    AnnotationMirror I18nFormatDateAnno = treeUtil.categoriesToFormatAnnotation(cc);
    cc[0] = I18nConversionCategory.NUMBER;
    AnnotationMirror I18nFormatNumberAnno = treeUtil.categoriesToFormatAnnotation(cc);
    QualifierHierarchy qh = ((BaseTypeVisitor<?>) visitor).getTypeFactory().getQualifierHierarchy();
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18nFormatUnusedAnno), I18nFormatUnusedAnno) : "GLB of @I18nFormat(UNUSED) and @I18nFormat(UNUSED) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18nFormatGeneralAnno), I18nFormatUnusedAnno) : "GLB of @I18nFormat(UNUSED) and @I18nFormat(GENERAL) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18nFormatDateAnno), I18nFormatUnusedAnno) : "GLB of @I18nFormat(UNUSED) and @I18nFormat(DATE) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18nFormatNumberAnno), I18nFormatUnusedAnno) : "GLB of @I18nFormat(UNUSED) and @I18nFormat(NUMBER) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatGeneralAnno, I18nFormatUnusedAnno), I18nFormatUnusedAnno) : "GLB of @I18nFormat(GENERAL) and @I18nFormat(UNUSED) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatGeneralAnno, I18nFormatGeneralAnno), I18nFormatGeneralAnno) : "GLB of @I18nFormat(GENERAL) and @I18nFormat(GENERAL) is not @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatGeneralAnno, I18nFormatDateAnno), I18nFormatGeneralAnno) : "GLB of @I18nFormat(GENERAL) and @I18nFormat(DATE) is not @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatGeneralAnno, I18nFormatNumberAnno), I18nFormatGeneralAnno) : "GLB of @I18nFormat(GENERAL) and @I18nFormat(NUMBER) is not @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatDateAnno, I18nFormatUnusedAnno), I18nFormatUnusedAnno) : "GLB of @I18nFormat(DATE) and @I18nFormat(UNUSED) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatDateAnno, I18nFormatGeneralAnno), I18nFormatGeneralAnno) : "GLB of @I18nFormat(DATE) and @I18nFormat(GENERAL) is not @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatDateAnno, I18nFormatDateAnno), I18nFormatDateAnno) : "GLB of @I18nFormat(DATE) and @I18nFormat(DATE) is not @I18nFormat(DATE)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatDateAnno, I18nFormatNumberAnno), I18nFormatDateAnno) : "GLB of @I18nFormat(DATE) and @I18nFormat(NUMBER) is not @I18nFormat(DATE)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatNumberAnno, I18nFormatUnusedAnno), I18nFormatUnusedAnno) : "GLB of @I18nFormat(NUMBER) and @I18nFormat(UNUSED) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatNumberAnno, I18nFormatGeneralAnno), I18nFormatGeneralAnno) : "GLB of @I18nFormat(NUMBER) and @I18nFormat(GENERAL) is not @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatNumberAnno, I18nFormatDateAnno), I18nFormatDateAnno) : "GLB of @I18nFormat(NUMBER) and @I18nFormat(DATE) is not @I18nFormat(DATE)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatNumberAnno, I18nFormatNumberAnno), I18nFormatNumberAnno) : "GLB of @I18nFormat(NUMBER) and @I18nFormat(NUMBER) is not @I18nFormat(NUMBER)!";
    // Now test with two I18nConversionCategory at a time:
    I18nConversionCategory[] cc2 = new I18nConversionCategory[2];
    cc2[0] = I18nConversionCategory.DATE;
    cc2[1] = I18nConversionCategory.DATE;
    AnnotationMirror FormatTwoConvCat1 = treeUtil.categoriesToFormatAnnotation(cc2);
    cc2[0] = I18nConversionCategory.UNUSED;
    cc2[1] = I18nConversionCategory.NUMBER;
    AnnotationMirror FormatTwoConvCat2 = treeUtil.categoriesToFormatAnnotation(cc2);
    cc2[0] = I18nConversionCategory.UNUSED;
    cc2[1] = I18nConversionCategory.DATE;
    AnnotationMirror FormatTwoConvCat3 = treeUtil.categoriesToFormatAnnotation(cc2);
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FormatTwoConvCat1, FormatTwoConvCat2), FormatTwoConvCat3) : "GLB of @I18nFormat([DATE,DATE]) and @I18nFormat([UNUSED,NUMBER]) is not @I18nFormat([UNUSED,DATE])!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatGeneralAnno, FormatTwoConvCat1), I18nFormatGeneralAnno) : "GLB of @I18nFormat(GENERAL) and @I18nFormat([DATE,DATE]) is not @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(FormatTwoConvCat2, I18nFormatDateAnno), I18nFormatUnusedAnno) : "GLB of @I18nFormat([UNUSED,NUMBER]) and @I18nFormat(DATE) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatForWithValue1, I18nFormatForWithValue2), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(\"#1\") and @I18nFormatFor(\"#2\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NUNKNOWNFORMAT, I18NUNKNOWNFORMAT), I18NUNKNOWNFORMAT) : "GLB of @I18nUnknownFormat and @I18nUnknownFormat is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NUNKNOWNFORMAT, I18NFORMAT), I18NFORMAT) : "GLB of @I18nUnknownFormat and @I18nFormat(null) is not @I18nFormat(null)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NUNKNOWNFORMAT, I18nFormatUnusedAnno), I18nFormatUnusedAnno) : "GLB of @I18nUnknownFormat and @I18nFormat(UNUSED) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NUNKNOWNFORMAT, I18NINVALIDFORMAT), I18NINVALIDFORMAT) : "GLB of @I18nUnknownFormat and @I18nInvalidFormat(null) is not @I18nInvalidFormat(null)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NUNKNOWNFORMAT, I18nInvalidFormatWithMessage), I18nInvalidFormatWithMessage) : "GLB of @I18nUnknownFormat and @I18nInvalidFormat(\"Message\") is not @I18nInvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NUNKNOWNFORMAT, I18NFORMATFOR), I18NFORMATFOR) : "GLB of @I18nUnknownFormat and @I18nFormatFor(null) is not @I18nFormatFor(null)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NUNKNOWNFORMAT, I18nFormatForWithValue1), I18nFormatForWithValue1) : "GLB of @I18nUnknownFormat and @I18nFormatFor(\"#1\") is not @I18nFormatFor(\"#1\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NUNKNOWNFORMAT, I18NFORMATBOTTOM), I18NFORMATBOTTOM) : "GLB of @I18nUnknownFormat and @I18nFormatBottom is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMAT, I18NUNKNOWNFORMAT), I18NFORMAT) : "GLB of @I18nFormat(null) and @I18nUnknownFormat is not @I18nFormat(null)!";
    // practice. Skipping this case as it causes an expected crash.
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMAT, I18NINVALIDFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nFormat(null) and @I18nInvalidFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMAT, I18nInvalidFormatWithMessage), I18NFORMATBOTTOM) : "GLB of @I18nFormat(null) and @I18nInvalidFormat(\"Message\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMAT, I18NFORMATFOR), I18NFORMATBOTTOM) : "GLB of @I18nFormat(null) and @I18nFormatFor(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMAT, I18nFormatForWithValue1), I18NFORMATBOTTOM) : "GLB of @I18nFormat(null) and @I18nFormatFor(\"#1\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMAT, I18NFORMATBOTTOM), I18NFORMATBOTTOM) : "GLB of @I18nFormat(null) and @I18nFormatBottom is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18NUNKNOWNFORMAT), I18nFormatUnusedAnno) : "GLB of @I18nFormat(UNUSED) and @I18nUnknownFormat is not @I18nFormat(UNUSED)!";
    // practice. Skipping this case as it causes an expected crash.
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18nFormatUnusedAnno), I18nFormatUnusedAnno) : "GLB of @I18nFormat(UNUSED) and @I18nFormat(UNUSED) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18NINVALIDFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nFormat(UNUSED) and @I18nInvalidFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18nInvalidFormatWithMessage), I18NFORMATBOTTOM) : "GLB of @I18nFormat(UNUSED) and @I18nInvalidFormat(\"Message\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18NFORMATFOR), I18NFORMATBOTTOM) : "GLB of @I18nFormat(UNUSED) and @I18nFormatFor(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18nFormatForWithValue1), I18NFORMATBOTTOM) : "GLB of @I18nFormat(UNUSED) and @I18nFormatFor(\"#1\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatUnusedAnno, I18NFORMATBOTTOM), I18NFORMATBOTTOM) : "GLB of @I18nFormat(UNUSED) and @I18nFormatBottom is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NINVALIDFORMAT, I18NUNKNOWNFORMAT), I18NINVALIDFORMAT) : "GLB of @I18nInvalidFormat(null) and @I18nUnknownFormat is not @I18nInvalidFormat(null)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NINVALIDFORMAT, I18NFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(null) and @I18nFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NINVALIDFORMAT, I18nFormatUnusedAnno), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(null) and @I18nFormat(UNUSED) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NINVALIDFORMAT, I18NFORMATFOR), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(null) and @I18nFormatFor(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NINVALIDFORMAT, I18nFormatForWithValue1), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(null) and @I18nFormatFor(\"#1\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NINVALIDFORMAT, I18NFORMATBOTTOM), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(null) and @I18nFormatBottom is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nInvalidFormatWithMessage, I18NUNKNOWNFORMAT), I18nInvalidFormatWithMessage) : "GLB of @I18nInvalidFormat(\"Message\") and @I18nUnknownFormat is not @I18nInvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nInvalidFormatWithMessage, I18NFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(\"Message\") and @I18nFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nInvalidFormatWithMessage, I18nFormatUnusedAnno), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(\"Message\") and @I18nFormat(UNUSED) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nInvalidFormatWithMessage, I18nInvalidFormatWithMessage), I18nInvalidFormatWithMessage) : "GLB of @I18nInvalidFormat(\"Message\") and @I18nInvalidFormat(\"Message\") is not @I18nInvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nInvalidFormatWithMessage, I18nInvalidFormatWithMessage2), I18nInvalidFormatWithMessagesAnded) : "GLB of @I18nInvalidFormat(\"Message\") and @I18nInvalidFormat(\"Message2\") is not @I18nInvalidFormat(\"(\"Message\" and \"Message2\")\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nInvalidFormatWithMessage, I18NFORMATFOR), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(\"Message\") and @I18nFormatFor(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nInvalidFormatWithMessage, I18nFormatForWithValue1), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(\"Message\") and @I18nFormatFor(\"#1\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nInvalidFormatWithMessage, I18NFORMATBOTTOM), I18NFORMATBOTTOM) : "GLB of @I18nInvalidFormat(\"Message\") and @I18nFormatBottom is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATFOR, I18NUNKNOWNFORMAT), I18NFORMATFOR) : "GLB of @I18nFormatFor(null) and @I18nUnknownFormat is not @I18nFormatFor(null)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATFOR, I18NFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(null) and @I18nFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATFOR, I18nFormatUnusedAnno), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(null) and @I18nFormat(UNUSED) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATFOR, I18NINVALIDFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(null) and @I18nInvalidFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATFOR, I18nInvalidFormatWithMessage), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(null) and @I18nInvalidFormat(\"Message\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATFOR, I18NFORMATFOR), I18NFORMATFOR) : "GLB of @I18nFormatFor(null) and @I18nFormatFor(null) is not @I18nFormatFor(null)!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATFOR, I18nFormatForWithValue1), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(null) and @I18nFormatFor(\"#1\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATFOR, I18NFORMATBOTTOM), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(null) and @I18nFormatBottom is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatForWithValue1, I18NUNKNOWNFORMAT), I18nFormatForWithValue1) : "GLB of @I18nFormatFor(\"#1\") and @I18nUnknownFormat is not @I18nFormatFor(\"#1\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatForWithValue1, I18NFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(\"#1\") and @I18nFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatForWithValue1, I18nFormatUnusedAnno), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(\"#1\") and @I18nFormat(UNUSED) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatForWithValue1, I18NINVALIDFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(\"#1\") and @I18nInvalidFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatForWithValue1, I18nInvalidFormatWithMessage), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(\"#1\") and @I18nInvalidFormat(\"Message\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatForWithValue1, I18NFORMATFOR), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(\"#1\") and @I18nFormatFor(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatForWithValue1, I18nFormatForWithValue1), I18nFormatForWithValue1) : "GLB of @I18nFormatFor(\"#1\") and @I18nFormatFor(\"#1\") is not @I18nFormatFor(\"#1\")!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18nFormatForWithValue1, I18NFORMATBOTTOM), I18NFORMATBOTTOM) : "GLB of @I18nFormatFor(\"#1\") and @I18nFormatBottom is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATBOTTOM, I18NUNKNOWNFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nFormatBottom and @I18nUnknownFormat is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATBOTTOM, I18NFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nFormatBottom and @I18nFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATBOTTOM, I18nFormatUnusedAnno), I18NFORMATBOTTOM) : "GLB of @I18nFormatBottom and @I18nFormat(UNUSED) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATBOTTOM, I18NINVALIDFORMAT), I18NFORMATBOTTOM) : "GLB of @I18nFormatBottom and @I18nInvalidFormat(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATBOTTOM, I18nInvalidFormatWithMessage), I18NFORMATBOTTOM) : "GLB of @I18nFormatBottom and @I18nInvalidFormat(\"Message\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATBOTTOM, I18NFORMATFOR), I18NFORMATBOTTOM) : "GLB of @I18nFormatBottom and @I18nFormatFor(null) is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATBOTTOM, I18nFormatForWithValue1), I18NFORMATBOTTOM) : "GLB of @I18nFormatBottom and @I18nFormatFor(\"#1\") is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(I18NFORMATBOTTOM, I18NFORMATBOTTOM), I18NFORMATBOTTOM) : "GLB of @I18nFormatBottom and @I18nFormatBottom is not @I18nFormatBottom!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18nFormatUnusedAnno), I18nFormatUnusedAnno) : "LUB of @I18nFormat(UNUSED) and @I18nFormat(UNUSED) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18nFormatGeneralAnno), I18nFormatGeneralAnno) : "LUB of @I18nFormat(UNUSED) and @I18nFormat(GENERAL) is not @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18nFormatDateAnno), I18nFormatDateAnno) : "LUB of @I18nFormat(UNUSED) and @I18nFormat(DATE) is not @I18nFormat(DATE)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18nFormatNumberAnno), I18nFormatNumberAnno) : "LUB of @I18nFormat(UNUSED) and @I18nFormat(NUMBER) is not @I18nFormat(NUMBER)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatGeneralAnno, I18nFormatUnusedAnno), I18nFormatGeneralAnno) : "LUB of @I18nFormat(GENERAL) and @I18nFormat(UNUSED) is not @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatGeneralAnno, I18nFormatGeneralAnno), I18nFormatGeneralAnno) : "LUB of @I18nFormat(GENERAL) and @I18nFormat(GENERAL) is not @I18nFormat(GENERAL)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatGeneralAnno, I18nFormatDateAnno), I18nFormatDateAnno) : "LUB of @I18nFormat(GENERAL) and @I18nFormat(DATE) is not @I18nFormat(DATE)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatGeneralAnno, I18nFormatNumberAnno), I18nFormatNumberAnno) : "LUB of @I18nFormat(GENERAL) and @I18nFormat(NUMBER) is not @I18nFormat(NUMBER)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatDateAnno, I18nFormatUnusedAnno), I18nFormatDateAnno) : "LUB of @I18nFormat(DATE) and @I18nFormat(UNUSED) is not @I18nFormat(DATE)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatDateAnno, I18nFormatGeneralAnno), I18nFormatDateAnno) : "LUB of @I18nFormat(DATE) and @I18nFormat(GENERAL) is not @I18nFormat(DATE)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatDateAnno, I18nFormatDateAnno), I18nFormatDateAnno) : "LUB of @I18nFormat(DATE) and @I18nFormat(DATE) is not @I18nFormat(DATE)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatDateAnno, I18nFormatNumberAnno), I18nFormatNumberAnno) : "LUB of @I18nFormat(DATE) and @I18nFormat(NUMBER) is not @I18nFormat(NUMBER)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatNumberAnno, I18nFormatUnusedAnno), I18nFormatNumberAnno) : "LUB of @I18nFormat(NUMBER) and @I18nFormat(UNUSED) is not @I18nFormat(NUMBER)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatNumberAnno, I18nFormatGeneralAnno), I18nFormatNumberAnno) : "LUB of @I18nFormat(NUMBER) and @I18nFormat(GENERAL) is not @I18nFormat(NUMBER)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatNumberAnno, I18nFormatDateAnno), I18nFormatNumberAnno) : "LUB of @I18nFormat(NUMBER) and @I18nFormat(DATE) is not @I18nFormat(NUMBER)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatNumberAnno, I18nFormatNumberAnno), I18nFormatNumberAnno) : "LUB of @I18nFormat(NUMBER) and @I18nFormat(NUMBER) is not @I18nFormat(NUMBER)!";
    // Now test with two I18nConversionCategory at a time:
    cc2[0] = I18nConversionCategory.DATE;
    cc2[1] = I18nConversionCategory.NUMBER;
    AnnotationMirror FormatTwoConvCat4 = treeUtil.categoriesToFormatAnnotation(cc2);
    assert AnnotationUtils.areSame(qh.leastUpperBound(FormatTwoConvCat1, FormatTwoConvCat2), FormatTwoConvCat4) : "LUB of @I18nFormat([DATE,DATE]) and @I18nFormat([UNUSED,NUMBER]) is not @I18nFormat([DATE,NUMBER])!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatGeneralAnno, FormatTwoConvCat1), FormatTwoConvCat1) : "LUB of @I18nFormat(GENERAL) and @I18nFormat([DATE,DATE]) is not @I18nFormat([DATE,DATE])!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(FormatTwoConvCat2, I18nFormatDateAnno), FormatTwoConvCat4) : "LUB of @I18nFormat([UNUSED,NUMBER]) and @I18nFormat(DATE) is not @I18nFormat([DATE,NUMBER])!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatForWithValue1, I18nFormatForWithValue2), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(\"#1\") and @I18nFormatFor(\"#2\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NUNKNOWNFORMAT, I18NUNKNOWNFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nUnknownFormat and @I18nUnknownFormat is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NUNKNOWNFORMAT, I18NFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nUnknownFormat and @I18nFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NUNKNOWNFORMAT, I18nFormatUnusedAnno), I18NUNKNOWNFORMAT) : "LUB of @I18nUnknownFormat and @I18nFormat(UNUSED) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NUNKNOWNFORMAT, I18NINVALIDFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nUnknownFormat and @I18nInvalidFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NUNKNOWNFORMAT, I18nInvalidFormatWithMessage), I18NUNKNOWNFORMAT) : "LUB of @I18nUnknownFormat and @I18nInvalidFormat(\"Message\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NUNKNOWNFORMAT, I18NFORMATFOR), I18NUNKNOWNFORMAT) : "LUB of @I18nUnknownFormat and @I18nFormatFor(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NUNKNOWNFORMAT, I18nFormatForWithValue1), I18NUNKNOWNFORMAT) : "LUB of @I18nUnknownFormat and @I18nFormatFor(\"#1\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NUNKNOWNFORMAT, I18NFORMATBOTTOM), I18NUNKNOWNFORMAT) : "LUB of @I18nUnknownFormat and @I18nFormatBottom is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMAT, I18NUNKNOWNFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(null) and @I18nUnknownFormat is not @I18nUnknownFormat!";
    // practice. Skipping this case as it causes an expected crash.
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMAT, I18NINVALIDFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(null) and @I18nInvalidFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMAT, I18nInvalidFormatWithMessage), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(null) and @I18nInvalidFormat(\"Message\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMAT, I18NFORMATFOR), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(null) and @I18nFormatFor(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMAT, I18nFormatForWithValue1), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(null) and @I18nFormatFor(\"#1\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMAT, I18NFORMATBOTTOM), I18NFORMAT) : "LUB of @I18nFormat(null) and @I18nFormatBottom is not @I18nFormat(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18NUNKNOWNFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(UNUSED) and @I18nUnknownFormat is not @I18nUnknownFormat!";
    // practice. Skipping this case as it causes an expected crash.
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18nFormatUnusedAnno), I18nFormatUnusedAnno) : "LUB of @I18nFormat(UNUSED) and @I18nFormat(UNUSED) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18NINVALIDFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(UNUSED) and @I18nInvalidFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18nInvalidFormatWithMessage), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(UNUSED) and @I18nInvalidFormat(\"Message\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18NFORMATFOR), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(UNUSED) and @I18nFormatFor(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18nFormatForWithValue1), I18NUNKNOWNFORMAT) : "LUB of @I18nFormat(UNUSED) and @I18nFormatFor(\"#1\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatUnusedAnno, I18NFORMATBOTTOM), I18nFormatUnusedAnno) : "LUB of @I18nFormat(UNUSED) and @I18nFormatBottom is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NINVALIDFORMAT, I18NUNKNOWNFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(null) and @I18nUnknownFormat is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NINVALIDFORMAT, I18NFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(null) and @I18nFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NINVALIDFORMAT, I18nFormatUnusedAnno), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(null) and @I18nFormat(UNUSED) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NINVALIDFORMAT, I18NFORMATFOR), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(null) and @I18nFormatFor(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NINVALIDFORMAT, I18nFormatForWithValue1), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(null) and @I18nFormatFor(\"#1\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NINVALIDFORMAT, I18NFORMATBOTTOM), I18NINVALIDFORMAT) : "LUB of @I18nInvalidFormat(null) and @I18nFormatBottom is not @I18nInvalidFormat(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nInvalidFormatWithMessage, I18NUNKNOWNFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(\"Message\") and @I18nUnknownFormat is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nInvalidFormatWithMessage, I18NFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(\"Message\") and @I18nFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nInvalidFormatWithMessage, I18nFormatUnusedAnno), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(\"Message\") and @I18nFormat(UNUSED) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nInvalidFormatWithMessage, I18nInvalidFormatWithMessage), I18nInvalidFormatWithMessage) : "LUB of @I18nInvalidFormat(\"Message\") and @I18nInvalidFormat(\"Message\") is not @I18nInvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nInvalidFormatWithMessage, I18nInvalidFormatWithMessage2), I18nInvalidFormatWithMessagesOred) : "LUB of @I18nInvalidFormat(\"Message\") and @I18nInvalidFormat(\"Message2\") is not @I18nInvalidFormat(\"(\"Message\" or \"Message2\")\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nInvalidFormatWithMessage, I18NFORMATFOR), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(\"Message\") and @I18nFormatFor(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nInvalidFormatWithMessage, I18nFormatForWithValue1), I18NUNKNOWNFORMAT) : "LUB of @I18nInvalidFormat(\"Message\") and @I18nFormatFor(\"#1\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nInvalidFormatWithMessage, I18NFORMATBOTTOM), I18nInvalidFormatWithMessage) : "LUB of @I18nInvalidFormat(\"Message\") and @I18nFormatBottom is not @I18nInvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATFOR, I18NUNKNOWNFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(null) and @I18nUnknownFormat is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATFOR, I18NFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(null) and @I18nFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATFOR, I18nFormatUnusedAnno), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(null) and @I18nFormat(UNUSED) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATFOR, I18NINVALIDFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(null) and @I18nInvalidFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATFOR, I18nInvalidFormatWithMessage), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(null) and @I18nInvalidFormat(\"Message\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATFOR, I18NFORMATFOR), I18NFORMATFOR) : "LUB of @I18nFormatFor(null) and @I18nFormatFor(null) is not @I18nFormatFor(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATFOR, I18nFormatForWithValue1), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(null) and @I18nFormatFor(\"#1\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATFOR, I18NFORMATBOTTOM), I18NFORMATFOR) : "LUB of @I18nFormatFor(null) and @I18nFormatBottom is not @I18nFormatFor(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatForWithValue1, I18NUNKNOWNFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(\"#1\") and @I18nUnknownFormat is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatForWithValue1, I18NFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(\"#1\") and @I18nFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatForWithValue1, I18nFormatUnusedAnno), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(\"#1\") and @I18nFormat(UNUSED) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatForWithValue1, I18NINVALIDFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(\"#1\") and @I18nInvalidFormat(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatForWithValue1, I18nInvalidFormatWithMessage), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(\"#1\") and @I18nInvalidFormat(\"Message\") is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatForWithValue1, I18NFORMATFOR), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatFor(\"#1\") and @I18nFormatFor(null) is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatForWithValue1, I18nFormatForWithValue1), I18nFormatForWithValue1) : "LUB of @I18nFormatFor(\"#1\") and @I18nFormatFor(\"#1\") is not @I18nFormatFor(\"#1\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18nFormatForWithValue1, I18NFORMATBOTTOM), I18nFormatForWithValue1) : "LUB of @I18nFormatFor(\"#1\") and @I18nFormatBottom is not @I18nFormatFor(\"#1\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATBOTTOM, I18NUNKNOWNFORMAT), I18NUNKNOWNFORMAT) : "LUB of @I18nFormatBottom and @I18nUnknownFormat is not @I18nUnknownFormat!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATBOTTOM, I18NFORMAT), I18NFORMAT) : "LUB of @I18nFormatBottom and @I18nFormat(null) is not @I18nFormat(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATBOTTOM, I18nFormatUnusedAnno), I18nFormatUnusedAnno) : "LUB of @I18nFormatBottom and @I18nFormat(UNUSED) is not @I18nFormat(UNUSED)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATBOTTOM, I18NINVALIDFORMAT), I18NINVALIDFORMAT) : "LUB of @I18nFormatBottom and @I18nInvalidFormat(null) is not @I18nInvalidFormat(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATBOTTOM, I18nInvalidFormatWithMessage), I18nInvalidFormatWithMessage) : "LUB of @I18nFormatBottom and @I18nInvalidFormat(\"Message\") is not @I18nInvalidFormat(\"Message\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATBOTTOM, I18NFORMATFOR), I18NFORMATFOR) : "LUB of @I18nFormatBottom and @I18nFormatFor(null) is not @I18nFormatFor(null)!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATBOTTOM, I18nFormatForWithValue1), I18nFormatForWithValue1) : "LUB of @I18nFormatBottom and @I18nFormatFor(\"#1\") is not @I18nFormatFor(\"#1\")!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(I18NFORMATBOTTOM, I18NFORMATBOTTOM), I18NFORMATBOTTOM) : "LUB of @I18nFormatBottom and @I18nFormatBottom is not @I18nFormatBottom!";
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) I18nInvalidFormat(org.checkerframework.checker.i18nformatter.qual.I18nInvalidFormat) QualifierHierarchy(org.checkerframework.framework.type.QualifierHierarchy) I18nFormatterTreeUtil(org.checkerframework.checker.i18nformatter.I18nFormatterTreeUtil) Elements(javax.lang.model.util.Elements) I18nConversionCategory(org.checkerframework.checker.i18nformatter.qual.I18nConversionCategory)

Example 10 with QualifierHierarchy

use of org.checkerframework.framework.type.QualifierHierarchy in project checker-framework by typetools.

the class UpperBoundTransfer method getUBQualifier.

/**
 * Returns the UBQualifier for node. It does this by finding a {@link CFValue} for node. First
 * it checks the store in the transfer input. If one isn't there, the analysis is checked. If
 * the UNKNOWN qualifier is returned, then the AnnotatedTypeMirror from the type factory is
 * used.
 *
 * @param n node
 * @param in transfer input
 * @return the UBQualifier for node
 */
private UBQualifier getUBQualifier(Node n, TransferInput<CFValue, CFStore> in) {
    QualifierHierarchy hierarchy = analysis.getTypeFactory().getQualifierHierarchy();
    Receiver rec = FlowExpressions.internalReprOf(atypeFactory, n);
    CFValue value = null;
    if (CFAbstractStore.canInsertReceiver(rec)) {
        value = in.getRegularStore().getValue(rec);
    }
    if (value == null) {
        value = analysis.getValue(n);
    }
    UBQualifier qualifier = getUBQualifier(hierarchy, value);
    if (qualifier.isUnknown()) {
        // The qualifier from the store or analysis might be UNKNOWN if there was some error.
        // For example,
        // @LTLength("a") int i = 4;  // error
        // The type of i in the store is @UpperBoundUnknown, but the type of i as computed by
        // the type factory is @LTLength("a"), so use that type.
        CFValue valueFromFactory = getValueFromFactory(n.getTree(), n);
        return getUBQualifier(hierarchy, valueFromFactory);
    }
    return qualifier;
}
Also used : CFValue(org.checkerframework.framework.flow.CFValue) QualifierHierarchy(org.checkerframework.framework.type.QualifierHierarchy) Receiver(org.checkerframework.dataflow.analysis.FlowExpressions.Receiver)

Aggregations

QualifierHierarchy (org.checkerframework.framework.type.QualifierHierarchy)25 AnnotationMirror (javax.lang.model.element.AnnotationMirror)22 AnnotatedTypeMirror (org.checkerframework.framework.type.AnnotatedTypeMirror)9 AnnotationMirrorSet (org.checkerframework.framework.util.AnnotationMirrorSet)6 ArrayList (java.util.ArrayList)4 AnnotatedTypeVariable (org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedTypeVariable)4 TypeVariable (javax.lang.model.type.TypeVariable)3 Elements (javax.lang.model.util.Elements)3 Types (javax.lang.model.util.Types)3 Receiver (org.checkerframework.dataflow.analysis.FlowExpressions.Receiver)3 TypeUseLocation (org.checkerframework.framework.qual.TypeUseLocation)2 AnnotationMirrorMap (org.checkerframework.framework.util.AnnotationMirrorMap)2 InferredType (org.checkerframework.framework.util.typeinference.solver.InferredValue.InferredType)2 AnnotationBuilder (org.checkerframework.javacutil.AnnotationBuilder)2 MethodTree (com.sun.source.tree.MethodTree)1 Entry (java.util.Map.Entry)1 TypeMirror (javax.lang.model.type.TypeMirror)1 A (lubglb.quals.A)1 B (lubglb.quals.B)1 C (lubglb.quals.C)1