a.type.tsym.attribute(syms.annotationTargetType.tsym); if (atTarget == null) { return inferTargetMetaInfo(a, s);
a.type.tsym.attribute(syms.annotationTargetType.tsym); if (atTarget == null) { return inferTargetMetaInfo(a, s);
a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym); if (atTarget == null) return true; Attribute atValue = atTarget.member(names.value);
a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym); if (atTarget == null) return true; Attribute atValue = atTarget.member(names.value);
/** Is the annotation applicable to types? */ protected boolean isTypeAnnotation(JCAnnotation a, boolean isTypeParameter) { Attribute.Compound atTarget = a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym); if (atTarget == null) { // An annotation without @Target is not a type annotation. return false; } Attribute atValue = atTarget.member(names.value); if (!(atValue instanceof Attribute.Array)) { return false; // error recovery } Attribute.Array arr = (Attribute.Array) atValue; for (Attribute app : arr.values) { if (!(app instanceof Attribute.Enum)) { return false; // recovery } Attribute.Enum e = (Attribute.Enum) app; if (e.value.name == names.TYPE_USE) return true; else if (isTypeParameter && e.value.name == names.TYPE_PARAMETER) return true; } return false; }
/** Is the annotation applicable to types? */ protected boolean isTypeAnnotation(JCAnnotation a, boolean isTypeParameter) { Attribute.Compound atTarget = a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym); if (atTarget == null) { // An annotation without @Target is not a type annotation. return false; } Attribute atValue = atTarget.member(names.value); if (!(atValue instanceof Attribute.Array)) { return false; // error recovery } Attribute.Array arr = (Attribute.Array) atValue; for (Attribute app : arr.values) { if (!(app instanceof Attribute.Enum)) { return false; // recovery } Attribute.Enum e = (Attribute.Enum) app; if (e.value.name == names.TYPE_USE) return true; else if (isTypeParameter && e.value.name == names.TYPE_PARAMETER) return true; } return false; }
/** Fetches the actual Type that should be the containing annotation. */ private Type getContainingType(Attribute.Compound currentAnno, DiagnosticPosition pos, boolean reportError) { Type origAnnoType = currentAnno.type; TypeSymbol origAnnoDecl = origAnnoType.tsym; // Fetch the Repeatable annotation from the current // annotation's declaration, or null if it has none Attribute.Compound ca = origAnnoDecl.attribute(syms.repeatableType.tsym); if (ca == null) { // has no Repeatable annotation if (reportError) log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType); return null; } return filterSame(extractContainingType(ca, pos, origAnnoDecl), origAnnoType); }
/** Fetches the actual Type that should be the containing annotation. */ private Type getContainingType(Attribute.Compound currentAnno, DiagnosticPosition pos, boolean reportError) { Type origAnnoType = currentAnno.type; TypeSymbol origAnnoDecl = origAnnoType.tsym; // Fetch the Repeatable annotation from the current // annotation's declaration, or null if it has none Attribute.Compound ca = origAnnoDecl.attribute(syms.repeatableType.tsym); if (ca == null) { // has no Repeatable annotation if (reportError) log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType); return null; } return filterSame(extractContainingType(ca, pos, origAnnoDecl), origAnnoType); }
RetentionPolicy getRetention(TypeSymbol annotationType) { RetentionPolicy vis = RetentionPolicy.CLASS; // the default Attribute.Compound c = annotationType.attribute(syms.retentionType.tsym); if (c != null) { Attribute value = c.member(names.value); if (value != null && value instanceof Attribute.Enum) { Name levelName = ((Attribute.Enum)value).value.name; if (levelName == names.SOURCE) vis = RetentionPolicy.SOURCE; else if (levelName == names.CLASS) vis = RetentionPolicy.CLASS; else if (levelName == names.RUNTIME) vis = RetentionPolicy.RUNTIME; else ;// /* fail soft */ throw new AssertionError(levelName); } } return vis; }
RetentionPolicy getRetention(TypeSymbol annotationType) { RetentionPolicy vis = RetentionPolicy.CLASS; // the default Attribute.Compound c = annotationType.attribute(syms.retentionType.tsym); if (c != null) { Attribute value = c.member(names.value); if (value != null && value instanceof Attribute.Enum) { Name levelName = ((Attribute.Enum)value).value.name; if (levelName == names.SOURCE) vis = RetentionPolicy.SOURCE; else if (levelName == names.CLASS) vis = RetentionPolicy.CLASS; else if (levelName == names.RUNTIME) vis = RetentionPolicy.RUNTIME; else ;// /* fail soft */ throw new AssertionError(levelName); } } return vis; }
/** * Tests whether an annotation type is @Inherited. */ private boolean isInherited(Type annotype) { return annotype.tsym.attribute(syms.inheritedType.tsym) != null; }
/** * Tests whether an annotation type is @Inherited. */ private boolean isInherited(Type annotype) { return annotype.tsym.attribute(syms.inheritedType.tsym) != null; }