/** * Returns true if the given type parameter's declaration is annotated with {@link * #typeParameterAnnotation} indicated it will only ever be instantiated with thread-safe types. */ public boolean hasThreadSafeTypeParameterAnnotation(TypeVariableSymbol symbol) { return typeParameterAnnotation != null && symbol.getAnnotationMirrors().stream() .anyMatch(t -> t.type.tsym.flatName().contentEquals(typeParameterAnnotation.getName())); }
return threadSafeInstantiation(containerTypeParameters, annotation, type); String nameStr = type.tsym.flatName().toString(); if (knownTypes.getKnownUnsafeClasses().contains(nameStr)) { return Violation.of(
@Override public Object visitType(TypeElement e, Object p) { String fqn = e instanceof Symbol.TypeSymbol ? ((Symbol.TypeSymbol)e).flatName().toString() : e.getQualifiedName().toString(); String value = props.getProperty(fqn); if (value == null) { props.setProperty(fqn, file.toExternalForm()); } return super.visitType(e, p); }
/** * Returns a binary name of a type. * @param element for which the binary name should be returned * @return the binary name, see Java Language Specification 13.1 * @throws IllegalArgumentException when the element is not a javac element */ public static String getBinaryName (TypeElement element) throws IllegalArgumentException { if (element instanceof Symbol.TypeSymbol) { return ((Symbol.TypeSymbol)element).flatName().toString(); } else { throw new IllegalArgumentException (); } }
public Name getBinaryName(TypeElement type) { return cast(TypeSymbol.class, type).flatName(); }
/** * An internal-use utility that creates a reified annotation. */ public static <A extends Annotation> A getAnnotation(Symbol annotated, Class<A> annoType) { if (!annoType.isAnnotation()) throw new IllegalArgumentException("Not an annotation type: " + annoType); String name = annoType.getName(); for (Attribute.Compound anno : annotated.getAnnotationMirrors()) if (name.equals(anno.type.tsym.flatName().toString())) return AnnotationProxyMaker.generateAnnotation(anno, annoType); return null; }
public Name getBinaryName(TypeElement type) { return cast(TypeSymbol.class, type).flatName(); }
/** * An internal-use utility that creates a reified annotation. */ public static <A extends Annotation> A getAnnotation(Symbol annotated, Class<A> annoType) { if (!annoType.isAnnotation()) throw new IllegalArgumentException("Not an annotation type: " + annoType); String name = annoType.getName(); for (Attribute.Compound anno : annotated.getAnnotationMirrors()) if (name.equals(anno.type.tsym.flatName().toString())) return AnnotationProxyMaker.generateAnnotation(anno, annoType); return null; }
@Override public <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) { String name = annoType.getName(); // Declaration annotations on type variables are stored in type attributes // on the owner of the TypeVariableSymbol List<Attribute.TypeCompound> candidates = owner.getRawTypeAttributes(); for (Attribute.TypeCompound anno : candidates) if (anno.position.type == TargetType.CLASS_TYPE_PARAMETER || anno.position.type == TargetType.METHOD_TYPE_PARAMETER) if (name.contentEquals(anno.type.tsym.flatName())) return anno; return null; }
@Override public Integer visitClassType(ClassType t, Void ignored) { int result = visit(t.getEnclosingType()); result *= 127; result += t.tsym.flatName().hashCode(); for (Type s : t.getTypeArguments()) { result *= 127; result += visit(s); } return result; }
/** Given a type t, return the extended class name of its erasure in * external representation. */ public Name xClassName(Type t) { if (t.hasTag(CLASS)) { return names.fromUtf(externalize(t.tsym.flatName())); } else if (t.hasTag(ARRAY)) { return typeSig(types.erasure(t)); } else { throw new AssertionError("xClassName"); } }
@Override public Integer visitClassType(ClassType t, Void ignored) { int result = visit(t.getEnclosingType()); result *= 127; result += t.tsym.flatName().hashCode(); for (Type s : t.getTypeArguments()) { result *= 127; result += visit(s); } return result; }
protected <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) { String name = annoType.getName(); for (Attribute.Compound anno : getAnnotationMirrors()) { if (name.equals(anno.type.tsym.flatName().toString())) return anno; } return null; }
@Override public Integer visitClassType(ClassType t, Void ignored) { int result = visit(t.getEnclosingType()); result *= 127; result += t.tsym.flatName().hashCode(); for (Type s : t.getTypeArguments()) { result *= 127; result += visit(s); } return result; }
/** Given a type t, return the extended class name of its erasure in * external representation. */ public Name xClassName(Type t) { if (t.hasTag(CLASS)) { return names.fromUtf(externalize(t.tsym.flatName())); } else if (t.hasTag(ARRAY)) { return typeSig(types.erasure(t)); } else { throw new AssertionError("xClassName"); } }
/** * Returns true if the given type parameter's declaration is annotated with {@link * #typeParameterAnnotation} indicated it will only ever be instantiated with thread-safe types. */ public boolean hasThreadSafeTypeParameterAnnotation(TypeVariableSymbol symbol) { return typeParameterAnnotation != null && symbol.getAnnotationMirrors().stream() .anyMatch(t -> t.type.tsym.flatName().contentEquals(typeParameterAnnotation.getName())); }
protected <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) { String name = annoType.getName(); for (Attribute.Compound anno : getAnnotationMirrors()) { if (name.equals(anno.type.tsym.flatName().toString())) return anno; } return null; }
/** Given a type t, return the extended class name of its erasure in * external representation. */ public Name xClassName(Type t) { if (t.tag == CLASS) { return names.fromUtf(externalize(t.tsym.flatName())); } else if (t.tag == ARRAY) { return typeSig(types.erasure(t)); } else { throw new AssertionError("xClassName"); } }
/** Given a type t, return the extended class name of its erasure in * external representation. */ public Name xClassName(Type t) { if (t.tag == CLASS) { return names.fromUtf(externalize(t.tsym.flatName())); } else if (t.tag == ARRAY) { return typeSig(types.erasure(t)); } else { throw new AssertionError("xClassName"); } }
@Override public Integer visitClassType(ClassType t, Void ignored) { int result = visit(t.getEnclosingType()); result *= 127; result += t.tsym.flatName().hashCode(); for (Type s : t.getTypeArguments()) { result *= 127; result += visit(s); } return result; }