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


Java Attribute.Compound方法代码示例

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


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

示例1: findAutoProxy

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
@NonNull
private Attribute.Compound findAutoProxy(@NonNull final List<? extends AnnotationMirror> mirrors) {
    for (final AnnotationMirror mirror : mirrors) {
        final TypeElement element = (TypeElement) mirror.getAnnotationType().asElement();

        try {
            final Class<?> aClass = CommonClassGenerator.extractClass(element);

            if (AutoProxy.class == aClass) {
                return (Attribute.Compound) mirror;
            }
        } catch (Throwable ignored) {
            // do nothing
        }
    }

    throw new RuntimeException("AutoProxy annotation not found");
}
 
开发者ID:OleksandrKucherenko,项目名称:autoproxy,代码行数:19,代码来源:TypeProcessor.java

示例2: needsHeader

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
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;
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:21,代码来源:JNIWriter.java

示例3: createYieldPart

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/** Compose default value return if proxy do not allows call to inner instance. */
protected void createYieldPart(@NonNull final MethodSpec.Builder builder,
                               @NonNull final Type returnType,
                               @Nullable final Attribute.Compound yield) throws Exception {
    // create return based on @Yield annotation values
    final AutoProxy.Yield annotation = extractYield(yield);
    final String value = annotation.value();
    final Class<?> adapter = annotation.adapter();
    final ReturnsPoet poet;

    if (RetBool.class == adapter || RetBoolGenerator.class == adapter) {
        poet = RetBoolGenerator.getInstance();
    } else if (Returns.class == adapter && isRetBoolValue(value)) {
        poet = RetBoolGenerator.getInstance();
    } else if (RetNumber.class == adapter || RetNumberGenerator.class == adapter) {
        poet = RetNumberGenerator.getInstance();
    } else if (Returns.class == adapter && isRetNumberValue(value)) {
        poet = RetNumberGenerator.getInstance();
    } else if (Returns.class == adapter || ReturnsGenerator.class == adapter) {
        poet = ReturnsGenerator.getInstance();
    } else {
        // create instance of generator by reflection info
        final Constructor<?> ctr = adapter.getConstructor();
        poet = (ReturnsPoet) ctr.newInstance();
    }

    final boolean composed = poet.compose(returnType, value, builder);

    if (!composed) {
        ReturnsGenerator.getInstance().compose(returnType, Returns.THROWS, builder);
    }
}
 
开发者ID:OleksandrKucherenko,项目名称:autoproxy,代码行数:33,代码来源:CommonClassGenerator.java

示例4: annotations

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:TypeVariableImpl.java

示例5: annotations

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:ProgramElementDocImpl.java

示例6: extractClass

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/** Extract reflection Class&lt;?&gt; information from compound. */
@NonNull
public static Class<?> extractClass(@NonNull final Attribute.Compound am) throws ClassNotFoundException {
    final TypeElement te = (TypeElement) am.getAnnotationType().asElement();

    return extractClass(te);
}
 
开发者ID:OleksandrKucherenko,项目名称:autoproxy,代码行数:8,代码来源:CommonClassGenerator.java

示例7: annotations

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Get the annotations of this program element.
 * Return an empty array if there are none.
 */
@Override
public AnnotationDesc[] annotations() {
    List<? extends TypeCompound> tas = type.getAnnotationMirrors();
    if (tas == null ||
            tas.isEmpty()) {
        return new AnnotationDesc[0];
    }
    AnnotationDesc res[] = new AnnotationDesc[tas.length()];
    int i = 0;
    for (Attribute.Compound a : tas) {
        res[i++] = new AnnotationDescImpl(env, a);
    }
    return res;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:AnnotatedTypeImpl.java

示例8: visitCompound

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:DPrinter.java

示例9: annotations

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Get the annotations of this parameter.
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:ParameterImpl.java

示例10: verifyExtensionInterfaces

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
private void verifyExtensionInterfaces( JCTree.JCClassDecl tree )
{
  if( !hasAnnotation( tree.getModifiers().getAnnotations(), Extension.class ) )
  {
    return;
  }

  outer:
  for( JCExpression iface: tree.getImplementsClause() )
  {
    final Symbol.TypeSymbol ifaceSym = iface.type.tsym;
    if( ifaceSym == _tp.getSymtab().objectType.tsym )
    {
      continue;
    }

    for( Attribute.Compound anno: ifaceSym.getAnnotationMirrors() )
    {
      if( anno.type.toString().equals( Structural.class.getName() ) )
      {
        continue outer;
      }
    }
    // extension interfaces must be structural
    _tp.report( iface, Diagnostic.Kind.ERROR, ExtIssueMsg.MSG_ONLY_STRUCTURAL_INTERFACE_ALLOWED_HERE.get( iface.toString() ) );
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:28,代码来源:ExtensionTransformer.java

示例11: annotations

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Get the annotations of this package.
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:PackageDocImpl.java

示例12: getByVariable

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
public static SerializationStrategyRecord getByVariable(JCVariableDecl var) {

            for (JCAnnotation annotation : var.mods.annotations) {
                try {
                    List<Attribute.Compound> annotationAttributes = annotation.type.tsym.getMetadata().getDeclarationAttributes();
                    Attribute.Compound strategyCompound = null;
                    for (Attribute.Compound ac : annotationAttributes) {
                        if (ac.type.toString().endsWith("AutoSerializationStrategy")) {
                            strategyCompound = ac;
                        }
                    }

                    if (strategyCompound == null)
                        continue;

                    SerializationStrategyRecord result = new SerializationStrategyRecord();
                    for (Pair<com.sun.tools.javac.code.Symbol.MethodSymbol, Attribute> pair : strategyCompound.values) {
                        String annotationArgument = pair.fst.toString();
                        if (annotationArgument.startsWith("targetStrategy")) {
                            result.targetStrategy = ((Attribute.Constant) pair.snd).value.toString();
                        } else if (annotationArgument.startsWith("toTarget")) {
                            result.toTarget = ((Attribute.Constant) pair.snd).value.toString();
                        } else if (annotationArgument.startsWith("fromTarget")) {
                            result.fromTarget = ((Attribute.Constant) pair.snd).value.toString();
                        }
                    }
                    return result;
                } catch (NullPointerException | ClassCastException | IndexOutOfBoundsException ignored) {
                }
            }

            return null;
        }
 
开发者ID:Devexperts,项目名称:egen,代码行数:34,代码来源:StatementFactory.java

示例13: createCompoundFromAnnotationMirror

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Returns a newly created Attribute.Compound corresponding to an
 * argument AnnotationMirror.
 *
 * @param am  an AnnotationMirror, which may be part of an AST or an internally
 *            created subclass.
 * @return  a new Attribute.Compound corresponding to the AnnotationMirror
 */
public static Attribute.Compound createCompoundFromAnnotationMirror(ProcessingEnvironment env,
        AnnotationMirror am) {
    // Create a new Attribute to match the AnnotationMirror.
    List<Pair<Symbol.MethodSymbol, Attribute>> values = List.nil();
    for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry :
             am.getElementValues().entrySet()) {
        Attribute attribute = attributeFromAnnotationValue(env, entry.getKey(), entry.getValue());
        values = values.append(new Pair<>((Symbol.MethodSymbol)entry.getKey(),
                                          attribute));
    }
    return new Attribute.Compound((Type.ClassType)am.getAnnotationType(), values);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:21,代码来源:TypeAnnotationUtils.java

示例14: annotations

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Get the annotations of this program element.
 * Return an empty array if there are none.
 */
public AnnotationDesc[] annotations() {
    AnnotationDesc res[] = new AnnotationDesc[sym.getAnnotationMirrors().length()];
    int i = 0;
    for (Attribute.Compound a : sym.getAnnotationMirrors()) {
        res[i++] = new AnnotationDescImpl(env, a);
    }
    return res;
}
 
开发者ID:openjdk,项目名称:jdk7-langtools,代码行数:13,代码来源:ProgramElementDocImpl.java

示例15: createCompoundFromAnnotationMirror

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Returns a newly created Attribute.Compound corresponding to an argument AnnotationMirror.
 *
 * @param am an AnnotationMirror, which may be part of an AST or an internally created subclass
 * @return a new Attribute.Compound corresponding to the AnnotationMirror
 */
public static Attribute.Compound createCompoundFromAnnotationMirror(
        ProcessingEnvironment env, AnnotationMirror am) {
    // Create a new Attribute to match the AnnotationMirror.
    List<Pair<Symbol.MethodSymbol, Attribute>> values = List.nil();
    for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry :
            am.getElementValues().entrySet()) {
        Attribute attribute =
                attributeFromAnnotationValue(env, entry.getKey(), entry.getValue());
        values = values.append(new Pair<>((Symbol.MethodSymbol) entry.getKey(), attribute));
    }
    return new Attribute.Compound((Type.ClassType) am.getAnnotationType(), values);
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:19,代码来源:TypeAnnotationUtils.java


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