本文整理汇总了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;
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
示例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;
}