Java Code Examples for com.sun.tools.javac.code.Flags#PRIVATE
The following examples show how to use
com.sun.tools.javac.code.Flags#PRIVATE .
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: SerializedForm.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example 2
Source File: SerializedForm.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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; }
Example 3
Source File: SerializedForm.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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; }
Example 4
Source File: TreeFactory.java From netbeans with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: TreeMaker.java From netbeans with Apache License 2.0 | 6 votes |
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()); }
Example 6
Source File: TreeMaker.java From netbeans with Apache License 2.0 | 6 votes |
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()); }
Example 7
Source File: SerializedForm.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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; }
Example 8
Source File: WorkArounds.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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; }
Example 9
Source File: PackageGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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; } }
Example 10
Source File: SerializedForm.java From hottub with GNU General Public License v2.0 | 6 votes |
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; }
Example 11
Source File: SerializedForm.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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; }
Example 12
Source File: SerializedForm.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example 13
Source File: HandleFieldDefaults.java From EasyMPermission with MIT License | 6 votes |
public void setFieldDefaultsForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level, boolean makeFinal) { JCVariableDecl field = (JCVariableDecl) fieldNode.get(); if (level != null && level != AccessLevel.NONE) { if ((field.mods.flags & (Flags.PUBLIC | Flags.PRIVATE | Flags.PROTECTED)) == 0) { if (!hasAnnotationAndDeleteIfNeccessary(PackagePrivate.class, fieldNode)) { field.mods.flags |= toJavacModifier(level); } } } if (makeFinal && (field.mods.flags & Flags.FINAL) == 0) { if (!hasAnnotationAndDeleteIfNeccessary(NonFinal.class, fieldNode)) { field.mods.flags |= Flags.FINAL; } } fieldNode.rebuild(); }
Example 14
Source File: JavacHandlerUtil.java From EasyMPermission with MIT License | 6 votes |
/** * Turns an {@code AccessLevel} instance into the flag bit used by javac. */ public static int toJavacModifier(AccessLevel accessLevel) { switch (accessLevel) { case MODULE: case PACKAGE: return 0; default: case PUBLIC: return Flags.PUBLIC; case NONE: case PRIVATE: return Flags.PRIVATE; case PROTECTED: return Flags.PROTECTED; } }
Example 15
Source File: HandleColumn.java From sqlitemagic with Apache License 2.0 | 5 votes |
@Override public void handle(AnnotationValues<Column> annotation, JCTree.JCAnnotation ast, JavacNode annotationNode) { // FIXME: 9.04.16 remove JavacNode node = annotationNode.up(); if (node.getKind() == AST.Kind.FIELD) { JCTree.JCVariableDecl fieldDec = (JCTree.JCVariableDecl) node.get(); if ((fieldDec.mods.flags & Flags.PRIVATE) != 0 && (fieldDec.mods.flags & (Flags.STATIC | Flags.FINAL)) == 0) { fieldDec.mods.flags &= ~Flags.PRIVATE; } node.rebuild(); } }
Example 16
Source File: HandleGetter.java From EasyMPermission with MIT License | 4 votes |
public void createGetterForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, boolean lazy, List<JCAnnotation> onMethod) { if (fieldNode.getKind() != Kind.FIELD) { source.addError("@Getter is only supported on a class or a field."); return; } JCVariableDecl fieldDecl = (JCVariableDecl)fieldNode.get(); if (lazy) { if ((fieldDecl.mods.flags & Flags.PRIVATE) == 0 || (fieldDecl.mods.flags & Flags.FINAL) == 0) { source.addError("'lazy' requires the field to be private and final."); return; } if (fieldDecl.init == null) { source.addError("'lazy' requires field initialization."); return; } } String methodName = toGetterName(fieldNode); if (methodName == null) { source.addWarning("Not generating getter for this field: It does not fit your @Accessors prefix list."); return; } for (String altName : toAllGetterNames(fieldNode)) { switch (methodExists(altName, fieldNode, false, 0)) { case EXISTS_BY_LOMBOK: return; case EXISTS_BY_USER: if (whineIfExists) { String altNameExpl = ""; if (!altName.equals(methodName)) altNameExpl = String.format(" (%s)", altName); source.addWarning( String.format("Not generating %s(): A method with that name already exists%s", methodName, altNameExpl)); } return; default: case NOT_EXISTS: //continue scanning the other alt names. } } long access = toJavacModifier(level) | (fieldDecl.mods.flags & Flags.STATIC); injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), source.get(), lazy, onMethod)); }