Java Code Examples for com.sun.tools.javac.code.Attribute#Compound
The following examples show how to use
com.sun.tools.javac.code.Attribute#Compound .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavacElements.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@DefinedBy(Api.LANGUAGE_MODEL) public Map<MethodSymbol, Attribute> getElementValuesWithDefaults( AnnotationMirror a) { Attribute.Compound anno = cast(Attribute.Compound.class, a); DeclaredType annotype = a.getAnnotationType(); Map<MethodSymbol, Attribute> valmap = anno.getElementValues(); for (ExecutableElement ex : methodsIn(annotype.asElement().getEnclosedElements())) { MethodSymbol meth = (MethodSymbol) ex; Attribute defaultValue = meth.getDefaultValue(); if (defaultValue != null && !valmap.containsKey(meth)) { valmap.put(meth, defaultValue); } } return valmap; }
Example 2
Source File: JNIWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 3
Source File: Annotate.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private <T extends Attribute.Compound> T makeContainerAnnotation(List<T> toBeReplaced, AnnotationContext<T> ctx, Symbol sym, boolean isTypeParam) { // Process repeated annotations T validRepeated = processRepeatedAnnotations(toBeReplaced, ctx, sym, isTypeParam); if (validRepeated != null) { // Check that the container isn't manually // present along with repeated instances of // its contained annotation. ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym); if (manualContainer != null) { log.error(ctx.pos.get(manualContainer.first()), Errors.InvalidRepeatableAnnotationRepeatedAndContainerPresent(manualContainer.first().type.tsym)); } } // A null return will delete the Placeholder return validRepeated; }
Example 4
Source File: ManAttr_8.java From manifold with Apache License 2.0 | 6 votes |
private Type getFragmentValueType( Attribute.Compound attribute ) { String type = null; for( com.sun.tools.javac.util.Pair<Symbol.MethodSymbol, Attribute> pair: attribute.values ) { Name argName = pair.fst.getSimpleName(); if( argName.toString().equals( "type" ) ) { type = (String)pair.snd.getValue(); } } if( type != null ) { Symbol.ClassSymbol fragValueSym = IDynamicJdk.instance().getTypeElement( JavacPlugin.instance().getContext(), getEnv().toplevel, type ); if( fragValueSym != null ) { return fragValueSym.type; } } return null; }
Example 5
Source File: ExtensionTransformer.java From manifold with Apache License 2.0 | 5 votes |
@SuppressWarnings("WeakerAccess") public static boolean isJailbreakSymbol( Symbol sym ) { if( sym == null ) { return false; } SymbolMetadata metadata = sym.getMetadata(); if( metadata == null || (metadata.isTypesEmpty() && metadata.isEmpty()) ) { return false; } List<Attribute.TypeCompound> typeAttributes = metadata.getTypeAttributes(); if( !typeAttributes.isEmpty() ) { return typeAttributes.stream() .anyMatch( attr -> attr.type.toString().equals( Jailbreak.class.getTypeName() ) ); } List<Attribute.Compound> attributes = metadata.getDeclarationAttributes(); if( !attributes.isEmpty() ) { return attributes.stream() .anyMatch( attr -> attr.type.toString().equals( Jailbreak.class.getTypeName() ) ); } return false; }
Example 6
Source File: DPrinter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void visitCompound(Attribute.Compound a) { if (a instanceof Attribute.TypeCompound) { Attribute.TypeCompound ta = (Attribute.TypeCompound) a; // consider a custom printer? printObject("position", ta.position, Details.SUMMARY); } printObject("synthesized", a.isSynthesized(), Details.SUMMARY); printList("values", a.values); visitAttribute(a); }
Example 7
Source File: ProgramElementDocImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Get the annotations of this program element. * Return an empty array if there are none. */ public AnnotationDesc[] annotations() { AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()]; int i = 0; for (Attribute.Compound a : sym.getRawAttributes()) { res[i++] = new AnnotationDescImpl(env, a); } return res; }
Example 8
Source File: ProgramElementDocImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Get the annotations of this program element. * Return an empty array if there are none. */ public AnnotationDesc[] annotations() { AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()]; int i = 0; for (Attribute.Compound a : sym.getRawAttributes()) { res[i++] = new AnnotationDescImpl(env, a); } return res; }
Example 9
Source File: TypeUtil.java From manifold with Apache License 2.0 | 5 votes |
public static boolean isStructuralInterface( TypeProcessor tp, Symbol sym ) { if( sym == null ) { return false; } if( (!sym.isInterface() || !sym.hasAnnotations()) && !(sym instanceof Symbol.TypeVariableSymbol) ) { return false; } // use the raw type Type type = tp.getTypes().erasure( sym.type ); sym = type.tsym; if( !sym.isInterface() || !sym.hasAnnotations() ) { return false; } for( Attribute.Compound annotation : sym.getAnnotationMirrors() ) { if( annotation.type.toString().equals( Structural.class.getName() ) ) { return true; } } return false; }
Example 10
Source File: AnnotationProxyMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void visitCompound(Attribute.Compound c) { try { Class<? extends Annotation> nested = returnClass.asSubclass(Annotation.class); value = generateAnnotation(c, nested); } catch (ClassCastException ex) { value = null; // indicates a type mismatch } }
Example 11
Source File: AnnotationProxyMaker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitCompound(Attribute.Compound c) { try { Class<? extends Annotation> nested = returnClass.asSubclass(Annotation.class); value = generateAnnotation(c, nested); } catch (ClassCastException ex) { value = null; // indicates a type mismatch } }
Example 12
Source File: Annotate.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Extract the actual Type to be used for a containing annotation. */ private Type extractContainingType(Attribute.Compound ca, DiagnosticPosition pos, TypeSymbol annoDecl) { // The next three checks check that the Repeatable annotation // on the declaration of the annotation type that is repeating is // valid. // Repeatable must have at least one element if (ca.values.isEmpty()) { log.error(pos, Errors.InvalidRepeatableAnnotation(annoDecl)); return null; } Pair<MethodSymbol,Attribute> p = ca.values.head; Name name = p.fst.name; if (name != names.value) { // should contain only one element, named "value" log.error(pos, Errors.InvalidRepeatableAnnotation(annoDecl)); return null; } if (!(p.snd instanceof Attribute.Class)) { // check that the value of "value" is an Attribute.Class log.error(pos, Errors.InvalidRepeatableAnnotation(annoDecl)); return null; } return ((Attribute.Class)p.snd).getValue(); }
Example 13
Source File: TypeVariableImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Get the annotations of this program element. * Return an empty array if there are none. */ public AnnotationDesc[] annotations() { if (!type.isAnnotated()) { return new AnnotationDesc[0]; } List<? extends TypeCompound> tas = type.getAnnotationMirrors(); AnnotationDesc res[] = new AnnotationDesc[tas.length()]; int i = 0; for (Attribute.Compound a : tas) { res[i++] = new AnnotationDescImpl(env, a); } return res; }
Example 14
Source File: TypeVariableImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Get the annotations of this program element. * Return an empty array if there are none. */ public AnnotationDesc[] annotations() { if (!type.isAnnotated()) { return new AnnotationDesc[0]; } List<? extends TypeCompound> tas = type.getAnnotationMirrors(); AnnotationDesc res[] = new AnnotationDesc[tas.length()]; int i = 0; for (Attribute.Compound a : tas) { res[i++] = new AnnotationDescImpl(env, a); } return res; }
Example 15
Source File: AnnotationValueImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public void visitCompound(Attribute.Compound c) { value = new AnnotationDescImpl(env, c); }
Example 16
Source File: AnnotationValueImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public void visitCompound(Attribute.Compound c) { sb.append(new AnnotationDescImpl(env, c)); }
Example 17
Source File: AnnotationDescImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
AnnotationDescImpl(DocEnv env, Attribute.Compound annotation) { this.env = env; this.annotation = annotation; }
Example 18
Source File: AnnotationValueImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void visitCompound(Attribute.Compound c) { value = new AnnotationDescImpl(env, c); }
Example 19
Source File: AnnotationValueImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
public void visitCompound(Attribute.Compound c) { value = new AnnotationDescImpl(env, c); }
Example 20
Source File: AnnotationDescImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
AnnotationDescImpl(DocEnv env, Attribute.Compound annotation) { this.env = env; this.annotation = annotation; }