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


Java Symbol.isStatic方法代码示例

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


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

示例1: referenceKind

import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
/**
 * Get the opcode associated with this method reference
 */
private int referenceKind(Symbol refSym) {
    if (refSym.isConstructor()) {
        return ClassFile.REF_newInvokeSpecial;
    } else {
        if (refSym.isStatic()) {
            return ClassFile.REF_invokeStatic;
        } else if ((refSym.flags() & PRIVATE) != 0) {
            return ClassFile.REF_invokeSpecial;
        } else if (refSym.enclClass().isInterface()) {
            return ClassFile.REF_invokeInterface;
        } else {
            return ClassFile.REF_invokeVirtual;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:LambdaToMethod.java

示例2: fieldAlwaysInitializedBeforeRead

import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
/**
 * @param symbol the field being read
 * @param pathToRead TreePath to the read operation
 * @param state visitor state
 * @param enclosingBlockPath TreePath to enclosing initializer block
 * @return true if within the initializer, the field is always initialized before the read
 *     operation, false otherwise
 */
private boolean fieldAlwaysInitializedBeforeRead(
    Symbol symbol, TreePath pathToRead, VisitorState state, TreePath enclosingBlockPath) {
  AccessPathNullnessAnalysis nullnessAnalysis = getNullnessAnalysis(state);
  Set<Element> nonnullFields;
  if (symbol.isStatic()) {
    nonnullFields = nullnessAnalysis.getNonnullStaticFieldsBefore(pathToRead, state.context);
  } else {
    nonnullFields = new LinkedHashSet<>();
    nonnullFields.addAll(
        nullnessAnalysis.getNonnullFieldsOfReceiverBefore(pathToRead, state.context));
    nonnullFields.addAll(safeInitByCalleeBefore(pathToRead, state, enclosingBlockPath));
  }
  return nonnullFields.contains(symbol);
}
 
开发者ID:uber,项目名称:NullAway,代码行数:23,代码来源:NullAway.java

示例3: makeIndyCall

import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
/**
 * Generate an indy method call with given name, type and static bootstrap
 * arguments types
 */
private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName,
        List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs,
        Name methName) {
    int prevPos = make.pos;
    try {
        make.at(pos);
        List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
                syms.stringType,
                syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));

        Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
                bsmName, bsm_staticArgs, List.<Type>nil());

        DynamicMethodSymbol dynSym =
                new DynamicMethodSymbol(methName,
                                        syms.noSymbol,
                                        bsm.isStatic() ?
                                            ClassFile.REF_invokeStatic :
                                            ClassFile.REF_invokeVirtual,
                                        (MethodSymbol)bsm,
                                        indyType,
                                        staticArgs.toArray());

        JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
        qualifier.sym = dynSym;
        qualifier.type = indyType.getReturnType();

        JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs);
        proxyCall.type = indyType.getReturnType();
        return proxyCall;
    } finally {
        make.at(prevPos);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:LambdaToMethod.java

示例4: makeIndyCall

import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
/**
 * Generate an indy method call with given name, type and static bootstrap
 * arguments types
 */
private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName,
        List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs,
        Name methName) {
    int prevPos = make.pos;
    try {
        make.at(pos);
        List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
                syms.stringType,
                syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));

        Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
                bsmName, bsm_staticArgs, List.nil());

        DynamicMethodSymbol dynSym =
                new DynamicMethodSymbol(methName,
                                        syms.noSymbol,
                                        bsm.isStatic() ?
                                            ClassFile.REF_invokeStatic :
                                            ClassFile.REF_invokeVirtual,
                                        (MethodSymbol)bsm,
                                        indyType,
                                        staticArgs.toArray());

        JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
        qualifier.sym = dynSym;
        qualifier.type = indyType.getReturnType();

        JCMethodInvocation proxyCall = make.Apply(List.nil(), qualifier, indyArgs);
        proxyCall.type = indyType.getReturnType();
        return proxyCall;
    } finally {
        make.at(prevPos);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:LambdaToMethod.java

示例5: setReceiverNonnull

import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
private void setReceiverNonnull(
    AccessPathNullnessPropagation.ReadableUpdates updates, Node receiver, Symbol symbol) {
  if (symbol != null && !symbol.isStatic()) {
    setNonnullIfAnalyzeable(updates, receiver);
  }
}
 
开发者ID:uber,项目名称:NullAway,代码行数:7,代码来源:AccessPathNullnessPropagation.java

示例6: collectEntities

import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
private FieldInitEntities collectEntities(ClassTree tree, VisitorState state) {
  Symbol.ClassSymbol classSymbol = ASTHelpers.getSymbol(tree);
  Set<Symbol> nonnullInstanceFields = new LinkedHashSet<>();
  Set<Symbol> nonnullStaticFields = new LinkedHashSet<>();
  List<BlockTree> instanceInitializerBlocks = new ArrayList<>();
  List<BlockTree> staticInitializerBlocks = new ArrayList<>();
  Set<MethodTree> constructors = new LinkedHashSet<>();
  Set<MethodTree> instanceInitializerMethods = new LinkedHashSet<>();
  Set<MethodTree> staticInitializerMethods = new LinkedHashSet<>();

  // we assume getMembers() returns members in the same order as the declarations
  for (Tree memberTree : tree.getMembers()) {
    switch (memberTree.getKind()) {
      case METHOD:
        // check if it is a constructor or an @Initializer method
        MethodTree methodTree = (MethodTree) memberTree;
        Symbol.MethodSymbol symbol = ASTHelpers.getSymbol(methodTree);
        if (isConstructor(methodTree)) {
          constructors.add(methodTree);
        } else if (isInitializerMethod(state, symbol)) {
          if (symbol.isStatic()) {
            staticInitializerMethods.add(methodTree);
          } else {
            instanceInitializerMethods.add(methodTree);
          }
        }
        break;
      case VARIABLE:
        // field declaration
        VariableTree varTree = (VariableTree) memberTree;
        Symbol fieldSymbol = ASTHelpers.getSymbol(varTree);
        if (fieldSymbol.type.isPrimitive() || skipDueToFieldAnnotation(fieldSymbol)) {
          continue;
        }
        if (varTree.getInitializer() != null) {
          // note that we check that the initializer does the right thing in
          // matchVariable()
          continue;
        }
        if (fieldSymbol.isStatic()) {
          nonnullStaticFields.add(fieldSymbol);
        } else {
          nonnullInstanceFields.add(fieldSymbol);
        }
        break;
      case BLOCK:
        // initializer block
        BlockTree blockTree = (BlockTree) memberTree;
        if (blockTree.isStatic()) {
          staticInitializerBlocks.add(blockTree);
        } else {
          instanceInitializerBlocks.add(blockTree);
        }
        break;
      case ENUM:
      case CLASS:
      case INTERFACE:
      case ANNOTATION_TYPE:
        // do nothing
        break;
      default:
        throw new RuntimeException(memberTree.getKind().toString() + " " + memberTree);
    }
  }

  return FieldInitEntities.create(
      classSymbol,
      ImmutableSet.copyOf(nonnullInstanceFields),
      ImmutableSet.copyOf(nonnullStaticFields),
      ImmutableList.copyOf(instanceInitializerBlocks),
      ImmutableList.copyOf(staticInitializerBlocks),
      ImmutableSet.copyOf(constructors),
      ImmutableSet.copyOf(instanceInitializerMethods),
      ImmutableSet.copyOf(staticInitializerMethods));
}
 
开发者ID:uber,项目名称:NullAway,代码行数:76,代码来源:NullAway.java

示例7: lambdaIdentSymbolFilter

import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
/**
 *  This is used to filter out those identifiers that needs to be adjusted
 *  when translating away lambda expressions
 */
private boolean lambdaIdentSymbolFilter(Symbol sym) {
    return (sym.kind == VAR || sym.kind == MTH)
            && !sym.isStatic()
            && sym.name != names.init;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:LambdaToMethod.java


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