com.sun.tools.javac.code.Kinds Java Examples

The following examples show how to use com.sun.tools.javac.code.Kinds. 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 openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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: AnnotationProxyMaker.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #3
Source File: JavadocMemberEnter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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 #4
Source File: ClassDocImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #5
Source File: SymbolMetadata.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void setAttributes(SymbolMetadata other) {
    if (other == null) {
        throw new NullPointerException();
    }
    setDeclarationAttributes(other.getDeclarationAttributes());
    if ((sym.flags() & Flags.BRIDGE) != 0) {
        Assert.check(other.sym.kind == Kinds.MTH);
        ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>();
        for (TypeCompound tc : other.getTypeAttributes()) {
            // Carry over only contractual type annotations: i.e nothing interior to method body.
            if (!tc.position.type.isLocal())
                typeAttributes.append(tc);
        }
        setTypeAttributes(typeAttributes.toList());
    } else {
        setTypeAttributes(other.getTypeAttributes());
    }
    if (sym.kind == Kinds.TYP) {
        setInitTypeAttributes(other.getInitTypeAttributes());
        setClassInitTypeAttributes(other.getClassInitTypeAttributes());
    }
}
 
Example #6
Source File: SerializedForm.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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 #7
Source File: JNIWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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 #8
Source File: SerializedForm.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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 #9
Source File: JNIWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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 #10
Source File: SerializedForm.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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: ClassDocImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #12
Source File: SerializedForm.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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: JavadocMemberEnter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@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 #14
Source File: SerializedForm.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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 #15
Source File: SerializedForm.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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 #16
Source File: MutableFieldsAnalyzer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitVarDef(JCVariableDecl tree) {
    boolean isJavacPack = tree.sym.outermostClass().fullname.toString()
            .contains(packageToCheck);
    if (isJavacPack &&
        (tree.sym.flags() & SYNTHETIC) == 0 &&
        tree.sym.owner.kind == Kinds.TYP) {
        if (!ignoreField(tree.sym.owner.flatName().toString(),
                tree.getName().toString())) {
            boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0;
            boolean nonFinalStaticEnumField =
                    (tree.sym.flags() & (ENUM | FINAL)) == 0;
            boolean nonFinalStaticField =
                    (tree.sym.flags() & STATIC) != 0 &&
                    (tree.sym.flags() & FINAL) == 0;
            if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
                messages.error(tree, "crules.err.var.must.be.final", tree);
            }
        }
    }
    super.visitVarDef(tree);
}
 
Example #17
Source File: MutableFieldsAnalyzer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitVarDef(JCVariableDecl tree) {
    boolean isJavacPack = tree.sym.outermostClass().fullname.toString()
            .contains(packageToCheck);
    if (isJavacPack &&
        (tree.sym.flags() & SYNTHETIC) == 0 &&
        tree.sym.owner.kind == Kinds.TYP) {
        if (!ignoreField(tree.sym.owner.flatName().toString(),
                tree.getName().toString())) {
            boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0;
            boolean nonFinalStaticEnumField =
                    (tree.sym.flags() & (ENUM | FINAL)) == 0;
            boolean nonFinalStaticField =
                    (tree.sym.flags() & STATIC) != 0 &&
                    (tree.sym.flags() & FINAL) == 0;
            if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
                messages.error(tree, "crules.err.var.must.be.final", tree);
            }
        }
    }
    super.visitVarDef(tree);
}
 
Example #18
Source File: ClassDocImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #19
Source File: ClassDocImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #20
Source File: JavadocMemberEnter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@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 #21
Source File: JavadocMemberEnter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitVarDef(JCVariableDecl tree) {
    if (tree.init != null) {
        boolean isFinal = (tree.mods.flags & FINAL) != 0
                || (env.enclClass.mods.flags & INTERFACE) != 0;
        if (!isFinal || containsNonConstantExpression(tree.init)) {
            // Avoid unnecessary analysis and release resources.
            // In particular, remove non-constant expressions
            // which may trigger Attr.attribClass, since
            // method bodies are also removed, in visitMethodDef.
            tree.init = null;
        }
    }
    super.visitVarDef(tree);
    if (tree.sym != null &&
            tree.sym.kind == Kinds.VAR &&
            !isParameter(tree.sym)) {
        docenv.makeFieldDoc(tree.sym, docenv.getTreePath(env.toplevel, env.enclClass, tree));
    }
}
 
Example #22
Source File: SerializedForm.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 #23
Source File: JavadocMemberEnter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@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 #24
Source File: SerializedForm.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 #25
Source File: JNIWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 #26
Source File: MutableFieldsAnalyzer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitVarDef(JCVariableDecl tree) {
    boolean isJavacPack = tree.sym.outermostClass().fullname.toString()
            .contains(packageToCheck);
    if (isJavacPack &&
        (tree.sym.flags() & SYNTHETIC) == 0 &&
        tree.sym.owner.kind == Kinds.TYP) {
        if (!ignoreField(tree.sym.owner.flatName().toString(),
                tree.getName().toString())) {
            boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0;
            boolean nonFinalStaticEnumField =
                    (tree.sym.flags() & (ENUM | FINAL)) == 0;
            boolean nonFinalStaticField =
                    (tree.sym.flags() & STATIC) != 0 &&
                    (tree.sym.flags() & FINAL) == 0;
            if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
                messages.error(tree, "crules.err.var.must.be.final", tree);
            }
        }
    }
    super.visitVarDef(tree);
}
 
Example #27
Source File: JNIWriter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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 #28
Source File: SymbolMetadata.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void setAttributes(SymbolMetadata other) {
    if (other == null) {
        throw new NullPointerException();
    }
    setDeclarationAttributes(other.getDeclarationAttributes());
    if ((sym.flags() & Flags.BRIDGE) != 0) {
        Assert.check(other.sym.kind == Kinds.MTH);
        ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>();
        for (TypeCompound tc : other.getTypeAttributes()) {
            // Carry over only contractual type annotations: i.e nothing interior to method body.
            if (!tc.position.type.isLocal())
                typeAttributes.append(tc);
        }
        setTypeAttributes(typeAttributes.toList());
    } else {
        setTypeAttributes(other.getTypeAttributes());
    }
    if (sym.kind == Kinds.TYP) {
        setInitTypeAttributes(other.getInitTypeAttributes());
        setClassInitTypeAttributes(other.getClassInitTypeAttributes());
    }
}
 
Example #29
Source File: PostFlowAnalysis.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void checkThis(DiagnosticPosition pos, TypeSymbol c) {
    if (checkThis && currentClass != c) {
        List<Pair<TypeSymbol, Symbol>> ots = outerThisStack;
        if (ots.isEmpty()) {
            log.error(pos, new Error("compiler", "no.encl.instance.of.type.in.scope", c)); //NOI18N
            return;
        }
        Pair<TypeSymbol, Symbol> ot = ots.head;
        TypeSymbol otc = ot.fst;
        while (otc != c) {
            do {
                ots = ots.tail;
                if (ots.isEmpty()) {
                    log.error(pos, new Error("compiler", "no.encl.instance.of.type.in.scope", c)); //NOI18N
                    return;
                }
                ot = ots.head;
            } while (ot.snd != otc);
            if (otc.owner.kind != Kinds.Kind.PCK && !otc.hasOuterInstance()) {
                log.error(pos, new Error("compiler", "cant.ref.before.ctor.called", c)); //NOI18N
                return;
            }
            otc = ot.fst;
        }
    }
}
 
Example #30
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
void checkDeprecatedAnnotation(DiagnosticPosition pos, Symbol s) {
    if (lint.isEnabled(LintCategory.DEP_ANN) && s.isDeprecatableViaAnnotation() &&
        (s.flags() & DEPRECATED) != 0 &&
        !syms.deprecatedType.isErroneous() &&
        s.attribute(syms.deprecatedType.tsym) == null) {
        log.warning(LintCategory.DEP_ANN,
                pos, Warnings.MissingDeprecatedAnnotation);
    }
    // Note: @Deprecated has no effect on local variables, parameters and package decls.
    if (lint.isEnabled(LintCategory.DEPRECATION) && !s.isDeprecatableViaAnnotation()) {
        if (!syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) != null) {
            log.warning(LintCategory.DEPRECATION, pos,
                        Warnings.DeprecatedAnnotationHasNoEffect(Kinds.kindName(s)));
        }
    }
}