Search in sources :

Example 66 with Elements

use of javax.lang.model.util.Elements in project checker-framework by typetools.

the class I18nFormatterLubGlbChecker method initChecker.

@SuppressWarnings("checkstyle:localvariablename")
@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, AnnotationBuilder.elementNamesValues("value", new I18nConversionCategory[0]));
    AnnotationMirror I18NINVALIDFORMAT = AnnotationBuilder.fromClass(elements, I18nInvalidFormat.class, AnnotationBuilder.elementNamesValues("value", "dummy"));
    AnnotationMirror I18NFORMATFOR = AnnotationBuilder.fromClass(elements, I18nFormatFor.class, AnnotationBuilder.elementNamesValues("value", "dummy"));
    AnnotationMirror I18NFORMATBOTTOM = AnnotationBuilder.fromClass(elements, I18nFormatBottom.class);
    AnnotationBuilder builder = new AnnotationBuilder(processingEnv, I18nInvalidFormat.class);
    builder.setValue("value", "Message");
    AnnotationMirror i18nInvalidFormatWithMessage = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nInvalidFormat.class);
    builder.setValue("value", "Message2");
    AnnotationMirror i18nInvalidFormatWithMessage2 = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nInvalidFormat.class);
    builder.setValue("value", "(\"Message\" or \"Message2\")");
    AnnotationMirror i18nInvalidFormatWithMessagesOred = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nInvalidFormat.class);
    builder.setValue("value", "(\"Message\" and \"Message2\")");
    AnnotationMirror i18nInvalidFormatWithMessagesAnded = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nFormatFor.class);
    builder.setValue("value", "#1");
    AnnotationMirror i18nFormatForWithValue1 = builder.build();
    builder = new AnnotationBuilder(processingEnv, I18nFormatFor.class);
    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) I18nFormatFor(org.checkerframework.checker.i18nformatter.qual.I18nFormatFor) Elements(javax.lang.model.util.Elements) I18nConversionCategory(org.checkerframework.checker.i18nformatter.qual.I18nConversionCategory)

Example 67 with Elements

use of javax.lang.model.util.Elements in project checker-framework by typetools.

the class LubGlbChecker method initChecker.

@Override
public void initChecker() {
    super.initChecker();
    Elements elements = processingEnv.getElementUtils();
    A = AnnotationBuilder.fromClass(elements, A.class);
    B = AnnotationBuilder.fromClass(elements, B.class);
    C = AnnotationBuilder.fromClass(elements, C.class);
    D = AnnotationBuilder.fromClass(elements, D.class);
    E = AnnotationBuilder.fromClass(elements, E.class);
    F = AnnotationBuilder.fromClass(elements, F.class);
    POLY = AnnotationBuilder.fromClass(elements, Poly.class);
    QualifierHierarchy qh = ((BaseTypeVisitor<?>) visitor).getTypeFactory().getQualifierHierarchy();
    // System.out.println("LUB of D and E: " + qh.leastUpperBound(D, E));
    assert AnnotationUtils.areSame(qh.leastUpperBound(D, E), C) : "LUB of D and E is not C!";
    // System.out.println("LUB of E and D: " + qh.leastUpperBound(E, D));
    assert AnnotationUtils.areSame(qh.leastUpperBound(E, D), C) : "LUB of E and D is not C!";
    // System.out.println("GLB of B and C: " + qh.greatestLowerBound(B, C));
    assert AnnotationUtils.areSame(qh.greatestLowerBound(B, C), D) : "GLB of B and C is not D!";
    // System.out.println("GLB of C and B: " + qh.greatestLowerBound(C, B));
    assert AnnotationUtils.areSame(qh.greatestLowerBound(C, B), D) : "GLB of C and B is not D!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(POLY, B), F) : "GLB of POLY and B is not F!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(POLY, F), F) : "GLB of POLY and F is not F!";
    assert AnnotationUtils.areSame(qh.greatestLowerBound(POLY, A), POLY) : "GLB of POLY and A is not POLY!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(POLY, B), A) : "LUB of POLY and B is not A!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(POLY, F), POLY) : "LUB of POLY and F is not POLY!";
    assert AnnotationUtils.areSame(qh.leastUpperBound(POLY, A), A) : "LUB of POLY and A is not A!";
}
Also used : A(org.checkerframework.framework.testchecker.lubglb.quals.A) B(org.checkerframework.framework.testchecker.lubglb.quals.B) C(org.checkerframework.framework.testchecker.lubglb.quals.C) D(org.checkerframework.framework.testchecker.lubglb.quals.D) E(org.checkerframework.framework.testchecker.lubglb.quals.E) F(org.checkerframework.framework.testchecker.lubglb.quals.F) QualifierHierarchy(org.checkerframework.framework.type.QualifierHierarchy) Poly(org.checkerframework.framework.testchecker.lubglb.quals.Poly) Elements(javax.lang.model.util.Elements)

Example 68 with Elements

use of javax.lang.model.util.Elements in project checker-framework by typetools.

the class TypesUtils method leastUpperBound.

// / Least upper bound and greatest lower bound
/**
 * Returns the least upper bound of two {@link TypeMirror}s, ignoring any annotations on the
 * types.
 *
 * <p>Wrapper around Types.lub to add special handling for null types, primitives, and wildcards.
 *
 * @param tm1 a {@link TypeMirror}
 * @param tm2 a {@link TypeMirror}
 * @param processingEnv the {@link ProcessingEnvironment} to use
 * @return the least upper bound of {@code tm1} and {@code tm2}
 */
public static TypeMirror leastUpperBound(TypeMirror tm1, TypeMirror tm2, ProcessingEnvironment processingEnv) {
    Type t1 = TypeAnnotationUtils.unannotatedType(tm1);
    Type t2 = TypeAnnotationUtils.unannotatedType(tm2);
    // Handle the 'null' type manually (not done by types.lub).
    if (t1.getKind() == TypeKind.NULL) {
        return t2;
    }
    if (t2.getKind() == TypeKind.NULL) {
        return t1;
    }
    if (t1.getKind() == TypeKind.WILDCARD) {
        WildcardType wc1 = (WildcardType) t1;
        t1 = (Type) wc1.getExtendsBound();
        if (t1 == null) {
            // Implicit upper bound of java.lang.Object
            Elements elements = processingEnv.getElementUtils();
            return elements.getTypeElement("java.lang.Object").asType();
        }
    }
    if (t2.getKind() == TypeKind.WILDCARD) {
        WildcardType wc2 = (WildcardType) t2;
        t2 = (Type) wc2.getExtendsBound();
        if (t2 == null) {
            // Implicit upper bound of java.lang.Object
            Elements elements = processingEnv.getElementUtils();
            return elements.getTypeElement("java.lang.Object").asType();
        }
    }
    JavacProcessingEnvironment javacEnv = (JavacProcessingEnvironment) processingEnv;
    com.sun.tools.javac.code.Types types = com.sun.tools.javac.code.Types.instance(javacEnv.getContext());
    if (types.isSameType(t1, t2)) {
        // Special case if the two types are equal.
        return t1;
    }
    // Special case for primitives.
    if (isPrimitive(t1) || isPrimitive(t2)) {
        if (types.isAssignable(t1, t2)) {
            return t2;
        } else if (types.isAssignable(t2, t1)) {
            return t1;
        } else {
            Elements elements = processingEnv.getElementUtils();
            return elements.getTypeElement("java.lang.Object").asType();
        }
    }
    return types.lub(t1, t2);
}
Also used : ClassType(com.sun.tools.javac.code.Type.ClassType) CapturedType(com.sun.tools.javac.code.Type.CapturedType) DeclaredType(javax.lang.model.type.DeclaredType) WildcardType(javax.lang.model.type.WildcardType) ArrayType(javax.lang.model.type.ArrayType) UnionType(javax.lang.model.type.UnionType) PrimitiveType(javax.lang.model.type.PrimitiveType) Type(com.sun.tools.javac.code.Type) WildcardType(javax.lang.model.type.WildcardType) JavacProcessingEnvironment(com.sun.tools.javac.processing.JavacProcessingEnvironment) Elements(javax.lang.model.util.Elements)

Example 69 with Elements

use of javax.lang.model.util.Elements in project kie-wb-common by kiegroup.

the class GeneratorUtils method getAnnotatedMethods.

public static List<ExecutableElement> getAnnotatedMethods(final TypeElement originalClassElement, final ProcessingEnvironment processingEnvironment, final String annotationName, final TypeMirror requiredReturnType, final String[] requiredParameterTypes) {
    final Types typeUtils = processingEnvironment.getTypeUtils();
    final Elements elementUtils = processingEnvironment.getElementUtils();
    TypeElement classElement = originalClassElement;
    while (true) {
        final List<ExecutableElement> methods = ElementFilter.methodsIn(classElement.getEnclosedElements());
        List<ExecutableElement> matches = new ArrayList<ExecutableElement>();
        for (ExecutableElement e : methods) {
            final TypeMirror actualReturnType = e.getReturnType();
            if (getAnnotation(elementUtils, e, annotationName) == null) {
                continue;
            }
            List<String> problems = new ArrayList<String>();
            if (!typeUtils.isAssignable(actualReturnType, requiredReturnType)) {
                problems.add("return " + requiredReturnType);
            }
            if (!doParametersMatch(typeUtils, elementUtils, e, requiredParameterTypes)) {
                if (requiredParameterTypes.length == 0) {
                    problems.add("take no parameters");
                } else {
                    StringBuilder sb = new StringBuilder();
                    sb.append("take ").append(requiredParameterTypes.length).append(" parameters of type (");
                    boolean first = true;
                    for (String p : requiredParameterTypes) {
                        if (!first) {
                            sb.append(", ");
                        }
                        sb.append(p);
                        first = false;
                    }
                    sb.append(")");
                    problems.add(sb.toString());
                }
            }
            if (e.getModifiers().contains(Modifier.STATIC)) {
                problems.add("be non-static");
            }
            if (e.getModifiers().contains(Modifier.PRIVATE)) {
                problems.add("be non-private");
            }
            if (problems.isEmpty()) {
                matches.add(e);
            } else {
                processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, formatProblemsList(annotationName, problems), e);
            }
        }
        if (!matches.isEmpty()) {
            return matches;
        }
        TypeMirror superclass = classElement.getSuperclass();
        if (superclass instanceof DeclaredType) {
            classElement = (TypeElement) ((DeclaredType) superclass).asElement();
        } else {
            break;
        }
    }
    return Collections.emptyList();
}
Also used : Types(javax.lang.model.util.Types) TypeMirror(javax.lang.model.type.TypeMirror) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) ArrayList(java.util.ArrayList) Elements(javax.lang.model.util.Elements) DeclaredType(javax.lang.model.type.DeclaredType)

Example 70 with Elements

use of javax.lang.model.util.Elements in project kie-wb-common by kiegroup.

the class MainProcessor method getDefinitionInheritedType.

private TypeElement getDefinitionInheritedType(TypeElement classElement) {
    final Elements elementUtils = processingEnv.getElementUtils();
    classElement = getParent(classElement);
    while (!classElement.toString().equals(Object.class.getName())) {
        List<VariableElement> variableElements = ElementFilter.fieldsIn(classElement.getEnclosedElements());
        for (VariableElement variableElement : variableElements) {
            for (String annotation : DEFINITION_ANNOTATIONS) {
                if (GeneratorUtils.getAnnotation(elementUtils, variableElement, annotation) != null) {
                    return classElement;
                }
            }
        }
        classElement = getParent(classElement);
    }
    return null;
}
Also used : VariableElement(javax.lang.model.element.VariableElement) Elements(javax.lang.model.util.Elements)

Aggregations

Elements (javax.lang.model.util.Elements)146 TypeElement (javax.lang.model.element.TypeElement)90 TypeMirror (javax.lang.model.type.TypeMirror)52 Element (javax.lang.model.element.Element)46 Types (javax.lang.model.util.Types)40 VariableElement (javax.lang.model.element.VariableElement)35 ExecutableElement (javax.lang.model.element.ExecutableElement)32 Map (java.util.Map)18 ArrayList (java.util.ArrayList)17 SupportedAnnotationTypes (javax.annotation.processing.SupportedAnnotationTypes)17 PackageElement (javax.lang.model.element.PackageElement)17 LinkedHashSet (java.util.LinkedHashSet)15 AnnotationMirror (javax.lang.model.element.AnnotationMirror)15 Test (org.junit.Test)15 List (java.util.List)14 XmlElements (javax.xml.bind.annotation.XmlElements)14 Metadata (org.apache.camel.spi.Metadata)14 Set (java.util.Set)12 DeclaredType (javax.lang.model.type.DeclaredType)12 AnnotationProcessorHelper.findTypeElement (org.apache.camel.tools.apt.AnnotationProcessorHelper.findTypeElement)12