本文整理匯總了Java中com.sun.tools.javac.code.Flags.STATIC屬性的典型用法代碼示例。如果您正苦於以下問題:Java Flags.STATIC屬性的具體用法?Java Flags.STATIC怎麽用?Java Flags.STATIC使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.sun.tools.javac.code.Flags
的用法示例。
在下文中一共展示了Flags.STATIC屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: modifiersToFlags
public static long modifiersToFlags(Set<Modifier> flagset) {
long flags = 0L;
for (Modifier mod : flagset)
switch (mod) {
case PUBLIC: flags |= Flags.PUBLIC; break;
case PROTECTED: flags |= Flags.PROTECTED; break;
case PRIVATE: flags |= Flags.PRIVATE; break;
case ABSTRACT: flags |= Flags.ABSTRACT; break;
case STATIC: flags |= Flags.STATIC; break;
case FINAL: flags |= Flags.FINAL; break;
case TRANSIENT: flags |= Flags.TRANSIENT; break;
case VOLATILE: flags |= Flags.VOLATILE; break;
case SYNCHRONIZED: flags |= Flags.SYNCHRONIZED; break;
case NATIVE: flags |= Flags.NATIVE; break;
case STRICTFP: flags |= Flags.STRICTFP; break;
case DEFAULT: flags |= Flags.DEFAULT; break;
default:
throw new AssertionError("Unknown Modifier: " + mod); //NOI18N
}
return flags;
}
示例2: overridesMethod
/**
* Returns true if this element represents a method which overrides a
* method in one of its superclasses.
*/
public boolean overridesMethod(ExecutableElement element) {
MethodSymbol m = (MethodSymbol)element;
if ((m.flags() & Flags.STATIC) == 0) {
ClassSymbol owner = (ClassSymbol) m.owner;
for (Type sup = jctypes.supertype(m.owner.type);
sup.hasTag(TypeTag.CLASS);
sup = jctypes.supertype(sup)) {
for (Symbol sym : sup.tsym.members().getSymbolsByName(m.name)) {
if (m.overrides(sym, owner, jctypes, true))
return true;
}
}
}
return false;
}
示例3: addModifiersModifier
public ModifiersTree addModifiersModifier(ModifiersTree modifiers, Modifier modifier) {
long c = ((JCModifiers) modifiers).flags & ~Flags.GENERATEDCONSTR;
switch (modifier) {
case ABSTRACT: c = c | Flags.ABSTRACT; break;
case FINAL: c = c | Flags.FINAL; break;
case NATIVE: c = c | Flags.NATIVE; break;
case PRIVATE: c = c | Flags.PRIVATE; break;
case PROTECTED: c = c | Flags.PROTECTED; break;
case PUBLIC: c = c | Flags.PUBLIC; break;
case STATIC: c = c | Flags.STATIC; break;
case STRICTFP: c = c | Flags.STRICTFP; break;
case SYNCHRONIZED: c = c | Flags.SYNCHRONIZED; break;
case TRANSIENT: c = c | Flags.TRANSIENT; break;
case VOLATILE: c = c | Flags.VOLATILE; break;
case DEFAULT: c = c | Flags.DEFAULT; break;
default:
break;
}
return Modifiers(c, modifiers.getAnnotations());
}
示例4: removeModifiersModifier
public ModifiersTree removeModifiersModifier(ModifiersTree modifiers, Modifier modifier) {
long c = ((JCModifiers) modifiers).flags & ~Flags.GENERATEDCONSTR;
switch (modifier) {
case ABSTRACT: c = c & ~Flags.ABSTRACT; break;
case FINAL: c = c & ~Flags.FINAL; break;
case NATIVE: c = c & ~Flags.NATIVE; break;
case PRIVATE: c = c & ~Flags.PRIVATE; break;
case PROTECTED: c = c & ~Flags.PROTECTED; break;
case PUBLIC: c = c & ~Flags.PUBLIC; break;
case STATIC: c = c & ~Flags.STATIC; break;
case STRICTFP: c = c & ~Flags.STRICTFP; break;
case SYNCHRONIZED: c = c & ~Flags.SYNCHRONIZED; break;
case TRANSIENT: c = c & ~Flags.TRANSIENT; break;
case VOLATILE: c = c & ~Flags.VOLATILE; break;
case DEFAULT: c = c & ~Flags.DEFAULT; break;
default:
break;
}
return Modifiers(c, modifiers.getAnnotations());
}
示例5: getDefinedSerializableFields
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
Names names = def.name.table.names;
/* SERIALIZABLE_FIELDS can be private,
* so must lookup by ClassSymbol, not by ClassDocImpl.
*/
for (Scope.Entry e = def.members().lookup(names.fromString(SERIALIZABLE_FIELDS)); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.VAR) {
VarSymbol f = (VarSymbol)e.sym;
if ((f.flags() & Flags.STATIC) != 0 &&
(f.flags() & Flags.PRIVATE) != 0) {
return f;
}
}
}
return null;
}
示例6: computeDefaultSerializableFields
private void computeDefaultSerializableFields(DocEnv env,
ClassSymbol def,
ClassDocImpl cd) {
for (Scope.Entry e = def.members().elems; e != null; e = e.sibling) {
if (e.sym != null && e.sym.kind == Kinds.VAR) {
VarSymbol f = (VarSymbol)e.sym;
if ((f.flags() & Flags.STATIC) == 0 &&
(f.flags() & Flags.TRANSIENT) == 0) {
//### No modifier filtering applied here.
FieldDocImpl fd = env.getFieldDoc(f);
//### Add to beginning.
//### Preserve order used by old 'javadoc'.
fields.prepend(fd);
}
}
}
}
示例7: addMethodIfExist
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
Names names = def.name.table.names;
for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.MTH) {
MethodSymbol md = (MethodSymbol)e.sym;
if ((md.flags() & Flags.STATIC) == 0) {
/*
* WARNING: not robust if unqualifiedMethodName is overloaded
* method. Signature checking could make more robust.
* READOBJECT takes a single parameter, java.io.ObjectInputStream.
* WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
*/
methods.append(env.getMethodDoc(md));
}
}
}
}
示例8: visitMethodDef
/**
* methods: remove method bodies, make methods native
*/
@Override
public void visitMethodDef(JCMethodDecl tree) {
tree.mods = translate(tree.mods);
tree.restype = translate(tree.restype);
tree.typarams = translateTypeParams(tree.typarams);
tree.params = translateVarDefs(tree.params);
tree.thrown = translate(tree.thrown);
if (tree.body != null) {
if ((currClassMods & Flags.INTERFACE) != 0) {
tree.mods.flags &= ~(Flags.DEFAULT | Flags.STATIC);
} else {
tree.mods.flags |= Flags.NATIVE;
}
tree.body = null;
}
result = tree;
}
示例9: getDefinedSerializableFields
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
Names names = def.name.table.names;
/* SERIALIZABLE_FIELDS can be private,
*/
for (Symbol sym : def.members().getSymbolsByName(names.fromString(SERIALIZABLE_FIELDS))) {
if (sym.kind == VAR) {
VarSymbol f = (VarSymbol) sym;
if ((f.flags() & Flags.STATIC) != 0
&& (f.flags() & Flags.PRIVATE) != 0) {
return f;
}
}
}
return null;
}
示例10: addMethodIfExist
private void addMethodIfExist(ClassSymbol def, String methodName) {
Names names = def.name.table.names;
for (Symbol sym : def.members().getSymbolsByName(names.fromString(methodName))) {
if (sym.kind == MTH) {
MethodSymbol md = (MethodSymbol) sym;
if ((md.flags() & Flags.STATIC) == 0) {
/*
* WARNING: not robust if unqualifiedMethodName is overloaded
* method. Signature checking could make more robust.
* READOBJECT takes a single parameter, java.io.ObjectInputStream.
* WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
*/
methods.add(md);
}
}
}
}
示例11: processConstants
ListBuffer<JCTree> processConstants(Element constNode, HashMap<String, Integer> scope) {
String baseName = constNode.getAttribute("basename");
int count = 1;
try {
count = Integer.parseInt(constNode.getAttribute("count"));
} catch (Exception e) {} // nothing to do, will use count = 1
long declFlags = Flags.PUBLIC | Flags.STATIC | Flags.FINAL | Flags.ENUM;
ListBuffer<JCTree> fields = new ListBuffer<>();
for (int i = 0; i < count; i++) {
String declName = baseName +
((count == 1) ? "" : getUniqIndex(scope, baseName));
JCVariableDecl constDecl = make.VarDef(
make.Modifiers(declFlags),
names.fromString(declName),
null, // no need for type in enum decl
null); // no init
fields.append(constDecl);
}
return fields;
}
示例12: getFlagByName
long getFlagByName(String modifierName) {
switch (modifierName) {
case "public":
return Flags.PUBLIC;
case "private":
return Flags.PRIVATE;
case "protected":
return Flags.PROTECTED;
case "static":
return Flags.STATIC;
case "final":
return Flags.FINAL;
case "abstract":
return Flags.ABSTRACT;
case "strictfp":
return Flags.STRICTFP;
default:
return 0;
}
}
示例13: getImplementationOf
public Element getImplementationOf(ExecutableElement method, TypeElement origin) {
MethodSymbol msym = (MethodSymbol)method;
MethodSymbol implmethod = (msym).implementation((TypeSymbol)origin, jctypes, true);
if ((msym.flags() & Flags.STATIC) != 0) {
// return null if outside of hierarchy, or the method itself if origin extends method's class
if (jctypes.isSubtype(((TypeSymbol)origin).type, ((TypeSymbol)((MethodSymbol)method).owner).type)) {
return method;
} else {
return null;
}
}
if (implmethod == null || implmethod == method) {
//look for default implementations
if (allowDefaultMethods) {
com.sun.tools.javac.util.List<MethodSymbol> candidates = jctypes.interfaceCandidates(((TypeSymbol) origin).type, (MethodSymbol) method);
X: for (com.sun.tools.javac.util.List<MethodSymbol> ptr = candidates; ptr.head != null; ptr = ptr.tail) {
MethodSymbol prov = ptr.head;
if (prov != null && prov.overrides((MethodSymbol) method, (TypeSymbol) origin, jctypes, true) &&
hasImplementation(prov)) {
// PENDING: even if `prov' overrides the method, there may be a different method, in different interface, that overrides `method'
// 'prov' must override all such compatible methods in order to present a valid implementation of `method'.
for (com.sun.tools.javac.util.List<MethodSymbol> sibling = candidates; sibling.head != null; sibling = sibling.tail) {
MethodSymbol redeclare = sibling.head;
// if the default method does not override the alternative candidate from an interface, then the default will be rejected
// as specified in JLS #8, par. 8.4.8
if (!prov.overrides(redeclare, (TypeSymbol)origin, jctypes, allowDefaultMethods)) {
break X;
}
}
implmethod = prov;
break;
}
}
}
}
return implmethod;
}
示例14: isMainMethod
/**
* Returns true if the method is a main method
* @param method to be checked
* @return true when the method is a main method
*/
public static boolean isMainMethod (final ExecutableElement method) {
if (!"main".contentEquals(method.getSimpleName())) { //NOI18N
return false;
}
long flags = ((Symbol.MethodSymbol)method).flags(); //faster
if (((flags & Flags.PUBLIC) == 0) || ((flags & Flags.STATIC) == 0)) {
return false;
}
if (method.getReturnType().getKind() != TypeKind.VOID) {
return false;
}
List<? extends VariableElement> params = method.getParameters();
if (params.size() != 1) {
return false;
}
TypeMirror param = params.get(0).asType();
if (param.getKind() != TypeKind.ARRAY) {
return false;
}
ArrayType array = (ArrayType) param;
TypeMirror compound = array.getComponentType();
if (compound.getKind() != TypeKind.DECLARED) {
return false;
}
return "java.lang.String".contentEquals(((TypeElement)((DeclaredType)compound).asElement()).getQualifiedName()); //NOI18N
}
示例15: computeDefaultSerializableFields
private void computeDefaultSerializableFields(ClassSymbol te) {
for (Symbol sym : te.members().getSymbols(NON_RECURSIVE)) {
if (sym != null && sym.kind == VAR) {
VarSymbol f = (VarSymbol) sym;
if ((f.flags() & Flags.STATIC) == 0
&& (f.flags() & Flags.TRANSIENT) == 0) {
//### No modifier filtering applied here.
//### Add to beginning.
//### Preserve order used by old 'javadoc'.
fields.add(f);
}
}
}
}