当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationUtils.fromClass方法代码示例

本文整理汇总了Java中org.checkerframework.javacutil.AnnotationUtils.fromClass方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationUtils.fromClass方法的具体用法?Java AnnotationUtils.fromClass怎么用?Java AnnotationUtils.fromClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.checkerframework.javacutil.AnnotationUtils的用法示例。


在下文中一共展示了AnnotationUtils.fromClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: solve

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
protected InferenceSolution solve() {
    Elements elements = processingEnvironment.getElementUtils();
    DATAFLOW = AnnotationUtils.fromClass(elements, DataFlow.class);

    Collection<String> datatypesUsed = getDatatypesUsed(slots);
    List<DataflowImpliesLogic> dataflowLogics = new ArrayList<>();

    for (String datatype : datatypesUsed) {
        Set<String> datatypeSet = new HashSet<String>();
        datatypeSet.add(datatype);
        AnnotationMirror dataflowAnnotation= DataflowUtils.createDataflowAnnotation(datatypeSet, processingEnvironment);
        LatticeGenerator lattice = new LatticeGenerator(dataflowAnnotation,processingEnvironment);
        DataflowGeneralSerializer serializer = new DataflowGeneralSerializer(
                slotManager, lattice);
        DataflowImpliesLogic logic = new DataflowImpliesLogic(lattice, constraints, serializer);
        dataflowLogics.add(logic);
    }
    List<DatatypeSolution> datatypeSolutions = solveImpliesLogic(dataflowLogics);
    return getMergedSolution(processingEnvironment, datatypeSolutions);
}
 
开发者ID:Jianchu,项目名称:generic-type-inference-solver,代码行数:22,代码来源:DataflowGeneralSolver.java

示例2: IGJAnnotatedTypeFactory

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Constructor for IGJAnnotatedTypeFactory object.
 *
 * @param checker the checker to which this factory belongs
 */
public IGJAnnotatedTypeFactory(BaseTypeChecker checker) {
    super(checker);

    READONLY = AnnotationUtils.fromClass(elements, ReadOnly.class);
    MUTABLE = AnnotationUtils.fromClass(elements, Mutable.class);
    IMMUTABLE = AnnotationUtils.fromClass(elements, Immutable.class);
    I = AnnotationUtils.fromClass(elements, I.class);
    ASSIGNS_FIELDS = AnnotationUtils.fromClass(elements, AssignsFields.class);
    BOTTOM_QUAL = AnnotationUtils.fromClass(elements, IGJBottom.class);

    addAliasedAnnotation(org.jmlspecs.annotation.Immutable.class, IMMUTABLE);
    addAliasedAnnotation(org.jmlspecs.annotation.Readonly.class, READONLY);
    addAliasedAnnotation(net.jcip.annotations.Immutable.class, IMMUTABLE);

    // TODO: Add an alias for the Pure JML annotation. It's not a type qualifier, I think adding
    // it above does not work. Also see NullnessAnnotatedTypeFactory.
    // this.addAliasedDeclAnnotation(org.jmlspecs.annotation.Pure.class, Pure.class, annotationToUse);

    this.postInit();
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:26,代码来源:IGJAnnotatedTypeFactory.java

示例3: AffinePointerTransfer

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public AffinePointerTransfer(AffinePointerAnalysis analysis) {
	super(analysis);
	
	checker = ((AffinePointerAnnotatedTypeFactory)analysis.getTypeFactory()).checker;
	
	Elements elts = analysis.getTypeFactory().getElementUtils();
	
	UNUSABLE = AnnotationUtils.fromClass(elts, Unusable.class);
	AFFINE = AnnotationUtils.fromClass(elts, Affine.class);
	SHARED = AnnotationUtils.fromClass(elts, Shared.class);
	BORROWED = AnnotationUtils.fromClass(elts, Borrowed.class);
	BOTTOM = AnnotationUtils.fromClass(elts, Bottom.class);
	NONAFFINE = AnnotationUtils.fromClass(elts, NonAffine.class);
	borrowTracker = new BorrowTracker();
}
 
开发者ID:PPewt,项目名称:affinechecker,代码行数:16,代码来源:AffinePointerTransfer.java

示例4: parseOutPut

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private void parseOutPut(ProcessingEnvironment processingEnvironment,
        int size) {
    Elements elements = processingEnvironment.getElementUtils();
    final AnnotationMirror OSuntrusted = AnnotationUtils.fromClass(
            elements, OsUntrusted.class);
    final AnnotationMirror OStrusted = AnnotationUtils.fromClass(elements,
            OsTrusted.class);
    String s = "";
    for (int i = 0; i < size; i++) {
        result.put(i, OSuntrusted);
    }
    BufferedReader stdInput = new BufferedReader(new StringReader(inReply));
    try {
        while ((s = stdInput.readLine()) != null) {
            // System.out.println(s);
            if (s.contains("[")) {
                String[] Line = s.split(" ");
                if (!Line[1].contains("-1") && !Line[1].contains("-2")) {
                    int VariableId = Integer.parseInt(Line[1]);
                    if (s.contains("Ostrusted")) {
                        trusted++;
                        result.put(VariableId, OStrusted);
                    } else if (s.contains("Osuntrusted")) {
                        untrusted++;
                        result.put(VariableId, OSuntrusted);
                    }
                }
            }
        }
    } catch (NumberFormatException | IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Jianchu,项目名称:generic-type-inference-solver,代码行数:34,代码来源:LogiqlDebugSolverCalTime.java

示例5: DataflowAnnotatedTypeFactory

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public DataflowAnnotatedTypeFactory(BaseTypeChecker checker) {
    super(checker);
    DATAFLOW = AnnotationUtils.fromClass(elements, DataFlow.class);
    DATAFLOWBOTTOM = DataflowUtils.createDataflowAnnotation(DataflowUtils.convert(""), processingEnv);
    DATAFLOWTOP = AnnotationUtils.fromClass(elements, DataFlowTop.class);
    postInit();
}
 
开发者ID:Jianchu,项目名称:generic-type-inference-solver,代码行数:8,代码来源:DataflowAnnotatedTypeFactory.java

示例6: InterningAnnotatedTypeFactory

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Creates a new {@link InterningAnnotatedTypeFactory} that operates on a
 * particular AST.
 *
 * @param checker the checker to use
 */
public InterningAnnotatedTypeFactory(BaseTypeChecker checker) {
    super(checker);
    this.INTERNED = AnnotationUtils.fromClass(elements, Interned.class);
    this.TOP = AnnotationUtils.fromClass(elements, UnknownInterned.class);

    // If you update the following, also update ../../../manual/interning-checker.tex .
    addAliasedAnnotation(com.sun.istack.Interned.class, INTERNED);

    this.postInit();

    // The null literal is interned -> make Void interned also.
    typeAnnotator.addTypeName(java.lang.Void.class, INTERNED);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:20,代码来源:InterningAnnotatedTypeFactory.java

示例7: ImmutabilityAnnotatedTypeFactory

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Constructor for IGJAnnotatedTypeFactory object.
 *
 * @param checker the checker to which this factory belongs
 */
public ImmutabilityAnnotatedTypeFactory(BaseTypeChecker checker) {
    super(checker);

    READONLY = AnnotationUtils.fromClass(elements, ReadOnly.class);
    MUTABLE = AnnotationUtils.fromClass(elements, Mutable.class);
    IMMUTABLE = AnnotationUtils.fromClass(elements, Immutable.class);
    I = AnnotationUtils.fromClass(elements, I.class);
    ASSIGNS_FIELDS = AnnotationUtils.fromClass(elements, AssignsFields.class);
    BOTTOM_QUAL = AnnotationUtils.fromClass(elements, OIGJMutabilityBottom.class);

    this.postInit();
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:18,代码来源:ImmutabilityAnnotatedTypeFactory.java

示例8: removeAnnotation

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public boolean removeAnnotation(Class<? extends Annotation> a) {
    AnnotationMirror anno = AnnotationUtils.fromClass(atypeFactory.elements, a);
    if (anno == null || !atypeFactory.isSupportedQualifier(anno)) {
        ErrorReporter.errorAbort("AnnotatedTypeMirror.removeAnnotation called with un-supported class: " + a);
    }
    return removeAnnotation(anno);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:8,代码来源:AnnotatedTypeMirror.java

示例9: testAnnoAsArgPositive

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Test
public void testAnnoAsArgPositive() {
    AnnotationMirror anno = AnnotationUtils.fromClass(env.getElementUtils(), MyAnno.class);
    AnnotationBuilder builder = new AnnotationBuilder(env, ContainingAnno.class);
    builder.setValue("value", anno);
    assertEquals("@tests.AnnotationBuilderTest.ContainingAnno(@tests.AnnotationBuilderTest.MyAnno)", builder.build().toString());
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:8,代码来源:AnnotationBuilderTest.java

示例10: PropertyKeyAnnotatedTypeFactory

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public PropertyKeyAnnotatedTypeFactory(BaseTypeChecker checker) {
    super(checker);
    this.lookupKeys = Collections.unmodifiableSet(buildLookupKeys());

    // Reuse the framework Bottom annotation and make it the default for the
    // null literal.
    AnnotationMirror BOTTOM = AnnotationUtils.fromClass(elements, Bottom.class);

    this.postInit();

    this.treeAnnotator.addTreeKind(Tree.Kind.NULL_LITERAL, BOTTOM);
    this.typeAnnotator.addTypeName(java.lang.Void.class, BOTTOM);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:14,代码来源:PropertyKeyAnnotatedTypeFactory.java

示例11: FlowTestAnnotatedTypeFactory

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public FlowTestAnnotatedTypeFactory(BaseTypeChecker checker) {
    super(checker, true);
    VALUE = AnnotationUtils.fromClass(elements, Value.class);
    BOTTOM = AnnotationUtils.fromClass(elements, Bottom.class);

    this.postInit();

    this.typeAnnotator.addTypeName(java.lang.Void.class, BOTTOM);
    this.treeAnnotator.addTreeKind(com.sun.source.tree.Tree.Kind.NULL_LITERAL, BOTTOM);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:11,代码来源:FlowTestAnnotatedTypeFactory.java

示例12: NullnessTransfer

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public NullnessTransfer(NullnessAnalysis analysis) {
    super(analysis);
    this.analysis = analysis;
    NONNULL = AnnotationUtils.fromClass(analysis.getTypeFactory()
            .getElementUtils(), NonNull.class);
    NULLABLE = AnnotationUtils.fromClass(analysis.getTypeFactory()
            .getElementUtils(), Nullable.class);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:9,代码来源:NullnessTransfer.java

示例13: TypeAnnotator

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Creates a {@link TypeAnnotator} from the given checker, using that checker's
 * {@link TypeQualifiers} annotation to determine the annotations that are
 * in the type hierarchy.
 */
public TypeAnnotator(AnnotatedTypeFactory atypeFactory) {

    this.typeKinds = new EnumMap<TypeKind, Set<AnnotationMirror>>(TypeKind.class);
    this.typeClasses = new HashMap<Class<? extends AnnotatedTypeMirror>, Set<AnnotationMirror>>();
    this.typeNames = new IdentityHashMap<String, Set<AnnotationMirror>>();

    this.qualHierarchy = atypeFactory.getQualifierHierarchy();
    // this.atypeFactory = atypeFactory;

    // Get type qualifiers from the checker.
    Set<Class<? extends Annotation>> quals = atypeFactory.getSupportedTypeQualifiers();

    // For each qualifier, read the @ImplicitFor annotation and put its type
    // classes and kinds into maps.
    for (Class<? extends Annotation> qual : quals) {
        ImplicitFor implicit = qual.getAnnotation(ImplicitFor.class);
        if (implicit == null) continue;

        AnnotationMirror theQual = AnnotationUtils.fromClass(atypeFactory.elements, qual);
        for (TypeKind typeKind : implicit.types()) {
            addTypeKind(typeKind, theQual);
        }

        for (Class<? extends AnnotatedTypeMirror> typeClass : implicit.typeClasses()) {
            addTypeClass(typeClass, theQual);
        }

        for (Class<?> typeName : implicit.typeNames()) {
            addTypeName(typeName, theQual);
        }
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:38,代码来源:TypeAnnotator.java

示例14: ReflectionTestAnnotatedTypeFactory

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public ReflectionTestAnnotatedTypeFactory(BaseTypeChecker checker) {
    super(checker);
    postInit();
    AnnotationMirror bottom = AnnotationUtils.fromClass(elements,
            ReflectBottom.class);
    this.typeAnnotator.addTypeName(java.lang.Void.class, bottom);
    this.treeAnnotator.addTreeKind(
            com.sun.source.tree.Tree.Kind.NULL_LITERAL, bottom);
    this.treeAnnotator.addTreeKind(
            com.sun.source.tree.Tree.Kind.INT_LITERAL, bottom);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:12,代码来源:ReflectionTestAnnotatedTypeFactory.java

示例15: TreeAnnotator

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Creates a {@link TypeAnnotator} from the given checker, using that checker's
 * {@link TypeQualifiers} annotation to determine the annotations that are
 * in the type hierarchy.
 */
public TreeAnnotator(AnnotatedTypeFactory atypeFactory) {

    this.treeKinds = new EnumMap<Kind, Set<AnnotationMirror>>(Kind.class);
    this.treeClasses = new HashMap<Class<?>, Set<AnnotationMirror>>();
    this.stringPatterns = new IdentityHashMap<Pattern, Set<AnnotationMirror>>();

    this.qualHierarchy = atypeFactory.getQualifierHierarchy();
    this.atypeFactory = atypeFactory;

    // Get type qualifiers from the checker.
    Set<Class<? extends Annotation>> quals = atypeFactory.getSupportedTypeQualifiers();

    // For each qualifier, read the @ImplicitFor annotation and put its tree
    // classes and kinds into maps.
    for (Class<? extends Annotation> qual : quals) {
        ImplicitFor implicit = qual.getAnnotation(ImplicitFor.class);
        if (implicit == null)
            continue;

        AnnotationMirror theQual = AnnotationUtils.fromClass(atypeFactory.elements, qual);
        for (Class<? extends Tree> treeClass : implicit.treeClasses()) {
            addTreeClass(treeClass, theQual);
        }

        for (Tree.Kind treeKind : implicit.trees()) {
            addTreeKind(treeKind, theQual);
        }

        for (String pattern : implicit.stringPatterns()) {
            addStringPattern(pattern, theQual);
        }
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:39,代码来源:TreeAnnotator.java


注:本文中的org.checkerframework.javacutil.AnnotationUtils.fromClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。