Java Code Examples for com.sun.tools.javac.code.Kinds#MTH
The following examples show how to use
com.sun.tools.javac.code.Kinds#MTH .
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: JNIWriter.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 2
Source File: ClassDocImpl.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Find constructor in this class. * * @param constrName the unqualified name to search for. * @param paramTypes the array of Strings for constructor parameters. * @return the first ConstructorDocImpl which matches, null if not found. */ public ConstructorDoc findConstructor(String constrName, String[] paramTypes) { Names names = tsym.name.table.names; for (Scope.Entry e = tsym.members().lookup(names.fromString("<init>")); e.scope != null; e = e.next()) { if (e.sym.kind == Kinds.MTH) { if (hasParameterTypes((MethodSymbol)e.sym, paramTypes)) { return env.getConstructorDoc((MethodSymbol)e.sym); } } } //###(gj) As a temporary measure until type variables are better //### handled, try again without the parameter types. //### This will often find the right constructor, and occassionally //### find the wrong one. //if (paramTypes != null) { // return findConstructor(constrName, null); //} return null; }
Example 3
Source File: SerializedForm.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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)); } } } }
Example 4
Source File: SerializedForm.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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)); } } } }
Example 5
Source File: JNIWriter.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 6
Source File: JavadocMemberEnter.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public void visitMethodDef(JCMethodDecl tree) { super.visitMethodDef(tree); MethodSymbol meth = tree.sym; if (meth == null || meth.kind != Kinds.MTH) return; TreePath treePath = docenv.getTreePath(env.toplevel, env.enclClass, tree); if (meth.isConstructor()) docenv.makeConstructorDoc(meth, treePath); else if (isAnnotationTypeElement(meth)) docenv.makeAnnotationTypeElementDoc(meth, treePath); else docenv.makeMethodDoc(meth, treePath); // release resources tree.body = null; }
Example 7
Source File: SerializedForm.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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)); } } } }
Example 8
Source File: JavadocMemberEnter.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public void visitMethodDef(JCMethodDecl tree) { super.visitMethodDef(tree); MethodSymbol meth = tree.sym; if (meth == null || meth.kind != Kinds.MTH) return; TreePath treePath = docenv.getTreePath(env.toplevel, env.enclClass, tree); if (meth.isConstructor()) docenv.makeConstructorDoc(meth, treePath); else if (isAnnotationTypeElement(meth)) docenv.makeAnnotationTypeElementDoc(meth, treePath); else docenv.makeMethodDoc(meth, treePath); // release resources tree.body = null; }
Example 9
Source File: AnnotationProxyMaker.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Returns a map from element symbols to their values. * Includes all elements, whether explicit or defaulted. */ private Map<MethodSymbol, Attribute> getAllValues() { Map<MethodSymbol, Attribute> res = new LinkedHashMap<MethodSymbol, Attribute>(); // First find the default values. ClassSymbol sym = (ClassSymbol) anno.type.tsym; for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) { if (e.sym.kind == Kinds.MTH) { MethodSymbol m = (MethodSymbol) e.sym; Attribute def = m.getDefaultValue(); if (def != null) res.put(m, def); } } // Next find the explicit values, possibly overriding defaults. for (Pair<MethodSymbol, Attribute> p : anno.values) res.put(p.fst, p.snd); return res; }
Example 10
Source File: JNIWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 11
Source File: JNIWriter.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 12
Source File: JNIWriter.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 13
Source File: Pool.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Check consistency of reference kind and symbol (see JVMS 4.4.8) */ @SuppressWarnings("fallthrough") private void checkConsistent() { boolean staticOk = false; int expectedKind = -1; Filter<Name> nameFilter = nonInitFilter; boolean interfaceOwner = false; switch (refKind) { case ClassFile.REF_getStatic: case ClassFile.REF_putStatic: staticOk = true; case ClassFile.REF_getField: case ClassFile.REF_putField: expectedKind = Kinds.VAR; break; case ClassFile.REF_newInvokeSpecial: nameFilter = initFilter; expectedKind = Kinds.MTH; break; case ClassFile.REF_invokeInterface: interfaceOwner = true; expectedKind = Kinds.MTH; break; case ClassFile.REF_invokeStatic: interfaceOwner = true; staticOk = true; case ClassFile.REF_invokeVirtual: expectedKind = Kinds.MTH; break; case ClassFile.REF_invokeSpecial: interfaceOwner = true; expectedKind = Kinds.MTH; break; } Assert.check(!refSym.isStatic() || staticOk); Assert.check(refSym.kind == expectedKind); Assert.check(nameFilter.accepts(refSym.name)); Assert.check(!refSym.owner.isInterface() || interfaceOwner); }
Example 14
Source File: Pool.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Check consistency of reference kind and symbol (see JVMS 4.4.8) */ @SuppressWarnings("fallthrough") private void checkConsistent() { boolean staticOk = false; int expectedKind = -1; Filter<Name> nameFilter = nonInitFilter; boolean interfaceOwner = false; switch (refKind) { case ClassFile.REF_getStatic: case ClassFile.REF_putStatic: staticOk = true; case ClassFile.REF_getField: case ClassFile.REF_putField: expectedKind = Kinds.VAR; break; case ClassFile.REF_newInvokeSpecial: nameFilter = initFilter; expectedKind = Kinds.MTH; break; case ClassFile.REF_invokeInterface: interfaceOwner = true; expectedKind = Kinds.MTH; break; case ClassFile.REF_invokeStatic: interfaceOwner = true; staticOk = true; case ClassFile.REF_invokeVirtual: expectedKind = Kinds.MTH; break; case ClassFile.REF_invokeSpecial: interfaceOwner = true; expectedKind = Kinds.MTH; break; } Assert.check(!refSym.isStatic() || staticOk); Assert.check(refSym.kind == expectedKind); Assert.check(nameFilter.accepts(refSym.name)); Assert.check(!refSym.owner.isInterface() || interfaceOwner); }
Example 15
Source File: JavacTrees.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */ MethodSymbol findConstructor(ClassSymbol tsym, List<Type> paramTypes) { for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(names.init); e.scope != null; e = e.next()) { if (e.sym.kind == Kinds.MTH) { if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) { return (MethodSymbol) e.sym; } } } return null; }
Example 16
Source File: T6889255.java From openjdk-jdk8u 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; } } } }
Example 17
Source File: T6889255.java From TencentKona-8 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; } } } }
Example 18
Source File: T6889255.java From openjdk-jdk8u-backup 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; } } } }
Example 19
Source File: T6889255.java From openjdk-8-source 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; } } } }
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; } } } }