本文整理汇总了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);
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}