Java Code Examples for com.sun.tools.javac.code.Flags#INTERFACE
The following examples show how to use
com.sun.tools.javac.code.Flags#INTERFACE .
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: GenStubs.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 2
Source File: GenStubs.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 3
Source File: GenStubs.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 4
Source File: GenStubs.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 5
Source File: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void visitPackageDef(JCPackageDecl tree) { if (!needPackageInfoClass(tree)) return; long flags = Flags.ABSTRACT | Flags.INTERFACE; // package-info is marked SYNTHETIC in JDK 1.6 and later releases flags = flags | Flags.SYNTHETIC; ClassSymbol c = tree.packge.package_info; c.setAttributes(tree.packge); c.flags_field |= flags; ClassType ctype = (ClassType) c.type; ctype.supertype_field = syms.objectType; ctype.interfaces_field = List.nil(); createInfoClass(tree.annotations, c); }
Example 6
Source File: HandleLog.java From EasyMPermission with MIT License | 5 votes |
public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode, String loggerTopic) { deleteAnnotationIfNeccessary(annotationNode, framework.getAnnotationClass()); JavacNode typeNode = annotationNode.up(); switch (typeNode.getKind()) { case TYPE: String logFieldName = annotationNode.getAst().readConfiguration(ConfigurationKeys.LOG_ANY_FIELD_NAME); if (logFieldName == null) logFieldName = "log"; boolean useStatic = !Boolean.FALSE.equals(annotationNode.getAst().readConfiguration(ConfigurationKeys.LOG_ANY_FIELD_IS_STATIC)); if ((((JCClassDecl)typeNode.get()).mods.flags & Flags.INTERFACE) != 0) { annotationNode.addError("@Log is legal only on classes and enums."); return; } if (fieldExists(logFieldName, typeNode) != MemberExistsResult.NOT_EXISTS) { annotationNode.addWarning("Field '" + logFieldName + "' already exists."); return; } JCFieldAccess loggingType = selfType(typeNode); createField(framework, typeNode, loggingType, annotationNode.get(), logFieldName, useStatic, loggerTopic); break; default: annotationNode.addError("@Log is legal only on types."); break; } }
Example 7
Source File: JCTree.java From javaide with GNU General Public License v3.0 | 5 votes |
public Kind getKind() { if ((mods.flags & Flags.ANNOTATION) != 0) return Kind.ANNOTATION_TYPE; else if ((mods.flags & Flags.INTERFACE) != 0) return Kind.INTERFACE; else if ((mods.flags & Flags.ENUM) != 0) return Kind.ENUM; else return Kind.CLASS; }
Example 8
Source File: T6889255.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
String getExpectedName(VarSymbol v, int i) { // special cases: // synthetic method if (((v.owner.owner.flags() & Flags.ENUM) != 0) && v.owner.name.toString().equals("valueOf")) return "name"; // interfaces don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.owner.flags() & Flags.INTERFACE) != 0) return "arg" + (i - 1); // abstract methods don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) return "arg" + (i - 1); // bridge methods use argN. No LVT for them anymore if ((v.owner.flags() & Flags.BRIDGE) != 0) return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type; String s; if (t.hasTag(TypeTag.CLASS)) s = ((ClassType) t).tsym.name.toString(); else s = t.toString(); return String.valueOf(Character.toLowerCase(s.charAt(0))) + i; }
Example 9
Source File: T6889255.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
String getExpectedName(VarSymbol v, int i) { // special cases: // synthetic method if (((v.owner.owner.flags() & Flags.ENUM) != 0) && v.owner.name.toString().equals("valueOf")) return "name"; // interfaces don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.owner.flags() & Flags.INTERFACE) != 0) return "arg" + (i - 1); // abstract methods don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) return "arg" + (i - 1); // bridge methods use argN. No LVT for them anymore if ((v.owner.flags() & Flags.BRIDGE) != 0) return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type; String s; if (t.hasTag(TypeTag.CLASS)) s = ((ClassType) t).tsym.name.toString(); else s = t.toString(); return String.valueOf(Character.toLowerCase(s.charAt(0))) + i; }
Example 10
Source File: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void createInfoClass(List<JCAnnotation> annots, ClassSymbol c) { long flags = Flags.ABSTRACT | Flags.INTERFACE; JCClassDecl infoClass = make.ClassDef(make.Modifiers(flags, annots), c.name, List.nil(), null, List.nil(), List.nil()); infoClass.sym = c; translated.append(infoClass); }
Example 11
Source File: T6889255.java From hottub with GNU General Public License v2.0 | 5 votes |
String getExpectedName(VarSymbol v, int i) { // special cases: // synthetic method if (((v.owner.owner.flags() & Flags.ENUM) != 0) && v.owner.name.toString().equals("valueOf")) return "name"; // interfaces don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.owner.flags() & Flags.INTERFACE) != 0) return "arg" + (i - 1); // abstract methods don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) return "arg" + (i - 1); // bridge methods use argN. No LVT for them anymore if ((v.owner.flags() & Flags.BRIDGE) != 0) return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type; String s; if (t.hasTag(TypeTag.CLASS)) s = ((ClassType) t).tsym.name.toString(); else s = t.toString(); return String.valueOf(Character.toLowerCase(s.charAt(0))) + i; }
Example 12
Source File: TreePruner.java From bazel with Apache License 2.0 | 5 votes |
private static boolean isFinal(JCClassDecl enclClass, JCVariableDecl tree) { if ((tree.mods.flags & Flags.FINAL) == Flags.FINAL) { return true; } if (enclClass != null && (enclClass.mods.flags & (Flags.ANNOTATION | Flags.INTERFACE)) != 0) { // Fields in annotation declarations and interfaces are implicitly final return true; } return false; }
Example 13
Source File: T6889255.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
String getExpectedName(VarSymbol v, int i) { // special cases: // synthetic method if (((v.owner.owner.flags() & Flags.ENUM) != 0) && v.owner.name.toString().equals("valueOf")) return "name"; // interfaces don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.owner.flags() & Flags.INTERFACE) != 0) return "arg" + (i - 1); // abstract methods don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) return "arg" + (i - 1); // bridge methods use argN. No LVT for them anymore if ((v.owner.flags() & Flags.BRIDGE) != 0) return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type; String s; if (t.hasTag(TypeTag.CLASS)) s = ((ClassType) t).tsym.name.toString(); else s = t.toString(); return String.valueOf(Character.toLowerCase(s.charAt(0))) + i; }
Example 14
Source File: T6889255.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
String getExpectedName(VarSymbol v, int i) { // special cases: // synthetic method if (((v.owner.owner.flags() & Flags.ENUM) != 0) && v.owner.name.toString().equals("valueOf")) return "name"; // interfaces don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.owner.flags() & Flags.INTERFACE) != 0) return "arg" + (i - 1); // abstract methods don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) return "arg" + (i - 1); // bridge methods use argN. No LVT for them anymore if ((v.owner.flags() & Flags.BRIDGE) != 0) return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type; String s; if (t.hasTag(TypeTag.CLASS)) s = ((ClassType) t).tsym.name.toString(); else s = t.toString(); return String.valueOf(Character.toLowerCase(s.charAt(0))) + i; }
Example 15
Source File: HandleConstructor.java From EasyMPermission with MIT License | 5 votes |
public static boolean checkLegality(JavacNode typeNode, JavacNode errorNode, String name) { JCClassDecl typeDecl = null; if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get(); long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags; boolean notAClass = (modifiers & (Flags.INTERFACE | Flags.ANNOTATION)) != 0; if (typeDecl == null || notAClass) { errorNode.addError(name + " is only supported on a class or an enum."); return false; } return true; }
Example 16
Source File: T6889255.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
String getExpectedName(VarSymbol v, int i) { // special cases: // synthetic method if (((v.owner.owner.flags() & Flags.ENUM) != 0) && v.owner.name.toString().equals("valueOf")) return "name"; // interfaces don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.owner.flags() & Flags.INTERFACE) != 0) return "arg" + (i - 1); // abstract methods don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) return "arg" + (i - 1); // bridge methods use argN. No LVT for them anymore if ((v.owner.flags() & Flags.BRIDGE) != 0) return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type; String s; if (t.hasTag(TypeTag.CLASS)) s = ((ClassType) t).tsym.name.toString(); else s = t.toString(); return String.valueOf(Character.toLowerCase(s.charAt(0))) + i; }
Example 17
Source File: TreeUtilities.java From netbeans with Apache License 2.0 | 4 votes |
/**Checks whether the given tree represents a class. * @deprecated since 0.67, <code>Tree.getKind() == Kind.CLASS</code> should be used instead. */ @Deprecated public boolean isClass(ClassTree tree) { return (((JCTree.JCModifiers)tree.getModifiers()).flags & (Flags.INTERFACE | Flags.ENUM | Flags.ANNOTATION)) == 0; }
Example 18
Source File: TreeUtilities.java From netbeans with Apache License 2.0 | 4 votes |
/**Checks whether the given tree represents an interface. * @deprecated since 0.67, <code>Tree.getKind() == Kind.INTERFACE</code> should be used instead. */ @Deprecated public boolean isInterface(ClassTree tree) { final long flags = ((JCTree.JCModifiers) tree.getModifiers()).flags; return (flags & Flags.INTERFACE) != 0 && (flags & Flags.ANNOTATION) == 0; }
Example 19
Source File: T6889255.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
void test(String testName, boolean expectNames, String... opts) throws Exception { System.err.println("Test " + testName + ": expectNames:" + expectNames + " javacOpts:" + Arrays.asList(opts)); File outDir = new File(testName); outDir.mkdirs(); compile(outDir, opts); Context ctx = new Context(); JavacFileManager fm = new JavacFileManager(ctx, true, null); fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(outDir)); Symtab syms = Symtab.instance(ctx); ClassReader cr = ClassReader.instance(ctx); cr.saveParameterNames = true; Names names = Names.instance(ctx); Set<String> classes = getTopLevelClasses(outDir); Deque<String> work = new LinkedList<String>(classes); String classname; while ((classname = work.poll()) != null) { System.err.println("Checking class " + classname); ClassSymbol sym = syms.enterClass(syms.noModule, names.table.fromString(classname)); sym.complete(); if ((sym.flags() & Flags.INTERFACE) != 0 && !testInterfaces) continue; for (Symbol s : sym.members_field.getSymbols(NON_RECURSIVE)) { System.err.println("Checking member " + s); switch (s.kind) { case TYP: { String name = s.flatName().toString(); if (!classes.contains(name)) { classes.add(name); work.add(name); } break; } case MTH: verify((MethodSymbol) s, expectNames); break; } } } }
Example 20
Source File: T6889255.java From hottub with GNU General Public License v2.0 | 4 votes |
void test(String testName, boolean expectNames, String... opts) throws Exception { System.err.println("Test " + testName + ": expectNames:" + expectNames + " javacOpts:" + Arrays.asList(opts)); File outDir = new File(testName); outDir.mkdirs(); compile(outDir, opts); Context ctx = new Context(); JavacFileManager fm = new JavacFileManager(ctx, true, null); fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(outDir)); ClassReader cr = ClassReader.instance(ctx); cr.saveParameterNames = true; Names names = Names.instance(ctx); Set<String> classes = getTopLevelClasses(outDir); Deque<String> work = new LinkedList<String>(classes); String classname; while ((classname = work.poll()) != null) { System.err.println("Checking class " + classname); ClassSymbol sym = cr.enterClass(names.table.fromString(classname)); sym.complete(); if ((sym.flags() & Flags.INTERFACE) != 0 && !testInterfaces) continue; for (Scope.Entry e = sym.members_field.elems; e != null; e = e.sibling) { System.err.println("Checking member " + e.sym); switch (e.sym.kind) { case Kinds.TYP: { String name = e.sym.flatName().toString(); if (!classes.contains(name)) { classes.add(name); work.add(name); } break; } case Kinds.MTH: verify((MethodSymbol) e.sym, expectNames); break; } } } }