Java Code Examples for com.sun.tools.javac.code.Flags#PUBLIC
The following examples show how to use
com.sun.tools.javac.code.Flags#PUBLIC .
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: 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 2
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 3
Source File: PackageGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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; }
Example 4
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 5
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 6
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 7
Source File: GenStubs.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * field definitions: replace initializers with 0, 0.0, false etc * when possible -- i.e. leave public, protected initializers alone */ @Override public void visitVarDef(JCVariableDecl tree) { tree.mods = translate(tree.mods); tree.vartype = translate(tree.vartype); if (tree.init != null) { if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) tree.init = translate(tree.init); else { String t = tree.vartype.toString(); if (t.equals("boolean")) tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; else if (t.equals("byte")) tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; else if (t.equals("char")) tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; else if (t.equals("double")) tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; else if (t.equals("float")) tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; else if (t.equals("int")) tree.init = new JCLiteral(TypeTag.INT, 0) { }; else if (t.equals("long")) tree.init = new JCLiteral(TypeTag.LONG, 0) { }; else if (t.equals("short")) tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; else tree.init = new JCLiteral(TypeTag.BOT, null) { }; } } result = tree; }
Example 8
Source File: GenStubs.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * field definitions: replace initializers with 0, 0.0, false etc * when possible -- i.e. leave public, protected initializers alone */ @Override public void visitVarDef(JCVariableDecl tree) { tree.mods = translate(tree.mods); tree.vartype = translate(tree.vartype); if (tree.init != null) { if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) tree.init = translate(tree.init); else { String t = tree.vartype.toString(); if (t.equals("boolean")) tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; else if (t.equals("byte")) tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; else if (t.equals("char")) tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; else if (t.equals("double")) tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; else if (t.equals("float")) tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; else if (t.equals("int")) tree.init = new JCLiteral(TypeTag.INT, 0) { }; else if (t.equals("long")) tree.init = new JCLiteral(TypeTag.LONG, 0) { }; else if (t.equals("short")) tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; else tree.init = new JCLiteral(TypeTag.BOT, null) { }; } } result = tree; }
Example 9
Source File: GenStubs.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * field definitions: replace initializers with 0, 0.0, false etc * when possible -- i.e. leave public, protected initializers alone */ @Override public void visitVarDef(JCVariableDecl tree) { tree.mods = translate(tree.mods); tree.vartype = translate(tree.vartype); if (tree.init != null) { if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) tree.init = translate(tree.init); else { String t = tree.vartype.toString(); if (t.equals("boolean")) tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; else if (t.equals("byte")) tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; else if (t.equals("char")) tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; else if (t.equals("double")) tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; else if (t.equals("float")) tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; else if (t.equals("int")) tree.init = new JCLiteral(TypeTag.INT, 0) { }; else if (t.equals("long")) tree.init = new JCLiteral(TypeTag.LONG, 0) { }; else if (t.equals("short")) tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; else tree.init = new JCLiteral(TypeTag.BOT, null) { }; } } result = tree; }
Example 10
Source File: GenStubs.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * field definitions: replace initializers with 0, 0.0, false etc * when possible -- i.e. leave public, protected initializers alone */ @Override public void visitVarDef(JCVariableDecl tree) { tree.mods = translate(tree.mods); tree.vartype = translate(tree.vartype); if (tree.init != null) { if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) tree.init = translate(tree.init); else { String t = tree.vartype.toString(); if (t.equals("boolean")) tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; else if (t.equals("byte")) tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; else if (t.equals("char")) tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; else if (t.equals("double")) tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; else if (t.equals("float")) tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; else if (t.equals("int")) tree.init = new JCLiteral(TypeTag.INT, 0) { }; else if (t.equals("long")) tree.init = new JCLiteral(TypeTag.LONG, 0) { }; else if (t.equals("short")) tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; else tree.init = new JCLiteral(TypeTag.BOT, null) { }; } } result = tree; }
Example 11
Source File: Modules.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
MethodSymbol factoryMethod(ClassSymbol tsym) { for (Symbol sym : tsym.members().getSymbolsByName(names.provider, sym -> sym.kind == MTH)) { MethodSymbol mSym = (MethodSymbol)sym; if (mSym.isStatic() && (mSym.flags() & Flags.PUBLIC) != 0 && mSym.params().isEmpty()) { return mSym; } } return null; }
Example 12
Source File: GenStubs.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * field definitions: replace initializers with 0, 0.0, false etc * when possible -- i.e. leave public, protected initializers alone */ @Override public void visitVarDef(JCVariableDecl tree) { tree.mods = translate(tree.mods); tree.vartype = translate(tree.vartype); if (tree.init != null) { if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) tree.init = translate(tree.init); else { String t = tree.vartype.toString(); if (t.equals("boolean")) tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; else if (t.equals("byte")) tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; else if (t.equals("char")) tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; else if (t.equals("double")) tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; else if (t.equals("float")) tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; else if (t.equals("int")) tree.init = new JCLiteral(TypeTag.INT, 0) { }; else if (t.equals("long")) tree.init = new JCLiteral(TypeTag.LONG, 0) { }; else if (t.equals("short")) tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; else tree.init = new JCLiteral(TypeTag.BOT, null) { }; } } result = tree; }
Example 13
Source File: GenStubs.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * field definitions: replace initializers with 0, 0.0, false etc * when possible -- i.e. leave public, protected initializers alone */ @Override public void visitVarDef(JCVariableDecl tree) { tree.mods = translate(tree.mods); tree.vartype = translate(tree.vartype); if (tree.init != null) { if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) tree.init = translate(tree.init); else { String t = tree.vartype.toString(); if (t.equals("boolean")) tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; else if (t.equals("byte")) tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; else if (t.equals("char")) tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; else if (t.equals("double")) tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; else if (t.equals("float")) tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; else if (t.equals("int")) tree.init = new JCLiteral(TypeTag.INT, 0) { }; else if (t.equals("long")) tree.init = new JCLiteral(TypeTag.LONG, 0) { }; else if (t.equals("short")) tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; else tree.init = new JCLiteral(TypeTag.BOT, null) { }; } } result = tree; }
Example 14
Source File: SourceUtils.java From netbeans with Apache License 2.0 | 5 votes |
/** * 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 }
Example 15
Source File: Modules.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
MethodSymbol factoryMethod(ClassSymbol tsym) { for (Symbol sym : tsym.members().getSymbolsByName(names.provider, sym -> sym.kind == MTH)) { MethodSymbol mSym = (MethodSymbol)sym; if (mSym.isStatic() && (mSym.flags() & Flags.PUBLIC) != 0 && mSym.params().isEmpty()) { return mSym; } } return null; }
Example 16
Source File: PrettyCommentsPrinter.java From EasyMPermission with MIT License | 5 votes |
private void removeImplicitModifiersForInterfaceMembers(List<JCTree> defs) { for (JCTree def :defs) { if (def instanceof JCVariableDecl) { ((JCVariableDecl) def).mods.flags &= ~(Flags.PUBLIC | Flags.STATIC | Flags.FINAL); } if (def instanceof JCMethodDecl) { ((JCMethodDecl) def).mods.flags &= ~(Flags.PUBLIC | Flags.ABSTRACT); } if (def instanceof JCClassDecl) { ((JCClassDecl) def).mods.flags &= ~(Flags.PUBLIC | Flags.STATIC); } } }
Example 17
Source File: GenStubs.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * field definitions: replace initializers with 0, 0.0, false etc * when possible -- i.e. leave public, protected initializers alone */ @Override public void visitVarDef(JCVariableDecl tree) { tree.mods = translate(tree.mods); tree.vartype = translate(tree.vartype); if (tree.init != null) { if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) tree.init = translate(tree.init); else { String t = tree.vartype.toString(); if (t.equals("boolean")) tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; else if (t.equals("byte")) tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; else if (t.equals("char")) tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; else if (t.equals("double")) tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; else if (t.equals("float")) tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; else if (t.equals("int")) tree.init = new JCLiteral(TypeTag.INT, 0) { }; else if (t.equals("long")) tree.init = new JCLiteral(TypeTag.LONG, 0) { }; else if (t.equals("short")) tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; else tree.init = new JCLiteral(TypeTag.BOT, null) { }; } } result = tree; }
Example 18
Source File: GenStubs.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * field definitions: replace initializers with 0, 0.0, false etc * when possible -- i.e. leave public, protected initializers alone */ @Override public void visitVarDef(JCVariableDecl tree) { tree.mods = translate(tree.mods); tree.vartype = translate(tree.vartype); if (tree.init != null) { if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) tree.init = translate(tree.init); else { String t = tree.vartype.toString(); if (t.equals("boolean")) tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; else if (t.equals("byte")) tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; else if (t.equals("char")) tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; else if (t.equals("double")) tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; else if (t.equals("float")) tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; else if (t.equals("int")) tree.init = new JCLiteral(TypeTag.INT, 0) { }; else if (t.equals("long")) tree.init = new JCLiteral(TypeTag.LONG, 0) { }; else if (t.equals("short")) tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; else tree.init = new JCLiteral(TypeTag.BOT, null) { }; } } result = tree; }
Example 19
Source File: Corraller.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public Wrap corralMethod(MethodTree mt) { ((JCMethodDecl) mt).mods.flags |= Flags.STATIC | Flags.PUBLIC; return corral(mt); }
Example 20
Source File: SourceCodeAnalysisImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private Element createArrayLengthSymbol(AnalyzeTask at, TypeMirror site) { Name length = Names.instance(at.getContext()).length; Type intType = Symtab.instance(at.getContext()).intType; return new VarSymbol(Flags.PUBLIC | Flags.FINAL, length, intType, ((Type) site).tsym); }