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

The following examples show how to use com.sun.tools.javac.code.Scope. 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 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 #2
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 #3
Source File: SerializedForm.java    From TencentKona-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 #4
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 #5
Source File: PackageDocImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a list of all classes contained in this package, including
 * member classes of those classes, and their member classes, etc.
 */
private List<ClassDocImpl> getClasses(boolean filtered) {
    if (allClasses != null && !filtered) {
        return allClasses;
    }
    if (allClassesFiltered != null && filtered) {
        return allClassesFiltered;
    }
    ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null) {
            ClassSymbol s = (ClassSymbol)e.sym;
            ClassDocImpl c = env.getClassDoc(s);
            if (c != null && !c.isSynthetic())
                c.addAllClasses(classes, filtered);
        }
    }
    if (filtered)
        return allClassesFiltered = classes.toList();
    else
        return allClasses = classes.toList();
}
 
Example #6
Source File: JNIWriter.java    From hottub 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 #7
Source File: SerializedForm.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void computeDefaultSerializableFields(DocEnv env,
                                              ClassSymbol def,
                                              ClassDocImpl cd) {
    for (Scope.Entry e = def.members().elems; e != null; e = e.sibling) {
        if (e.sym != null && e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) == 0 &&
                (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                FieldDocImpl fd = env.getFieldDoc(f);
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.prepend(fd);
            }
        }
    }
}
 
Example #8
Source File: SerializedForm.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void computeDefaultSerializableFields(DocEnv env,
                                              ClassSymbol def,
                                              ClassDocImpl cd) {
    for (Scope.Entry e = def.members().elems; e != null; e = e.sibling) {
        if (e.sym != null && e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) == 0 &&
                (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                FieldDocImpl fd = env.getFieldDoc(f);
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.prepend(fd);
            }
        }
    }
}
 
Example #9
Source File: PackageDocImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a list of all classes contained in this package, including
 * member classes of those classes, and their member classes, etc.
 */
private List<ClassDocImpl> getClasses(boolean filtered) {
    if (allClasses != null && !filtered) {
        return allClasses;
    }
    if (allClassesFiltered != null && filtered) {
        return allClassesFiltered;
    }
    ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null) {
            ClassSymbol s = (ClassSymbol)e.sym;
            ClassDocImpl c = env.getClassDoc(s);
            if (c != null && !c.isSynthetic())
                c.addAllClasses(classes, filtered);
        }
    }
    if (filtered)
        return allClassesFiltered = classes.toList();
    else
        return allClasses = classes.toList();
}
 
Example #10
Source File: SerializedForm.java    From TencentKona-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 #11
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 #12
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 #13
Source File: PackageDocImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a list of all classes contained in this package, including
 * member classes of those classes, and their member classes, etc.
 */
private List<ClassDocImpl> getClasses(boolean filtered) {
    if (allClasses != null && !filtered) {
        return allClasses;
    }
    if (allClassesFiltered != null && filtered) {
        return allClassesFiltered;
    }
    ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null) {
            ClassSymbol s = (ClassSymbol)e.sym;
            ClassDocImpl c = env.getClassDoc(s);
            if (c != null && !c.isSynthetic())
                c.addAllClasses(classes, filtered);
        }
    }
    if (filtered)
        return allClassesFiltered = classes.toList();
    else
        return allClasses = classes.toList();
}
 
Example #14
Source File: ClassDocImpl.java    From jdk8u60 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 #15
Source File: ElementsService.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public boolean alreadyDefinedIn(CharSequence name, TypeMirror returnType, List<TypeMirror> paramTypes, TypeElement enclClass) {
    ClassSymbol clazz = (ClassSymbol)enclClass;
    Scope scope = clazz.members();
    Name n = names.fromString(name.toString());
    ListBuffer<Type> buff = new ListBuffer<>();
    for (TypeMirror tm : paramTypes) {
        buff.append((Type)tm);
    }
    for (Symbol sym : scope.getSymbolsByName(n, Scope.LookupKind.NON_RECURSIVE)) {
        if(sym.type instanceof ExecutableType &&
                jctypes.containsTypeEquivalent(sym.type.asMethodType().getParameterTypes(), buff.toList()) &&
                jctypes.isSameType(sym.type.asMethodType().getReturnType(), (Type)returnType))
            return true;
    }
    return false;
}
 
Example #16
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 #17
Source File: ClassDocImpl.java    From hottub 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 #18
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 #19
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 #20
Source File: ClassDocImpl.java    From openjdk-8-source 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 #21
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 #22
Source File: AnnotationProxyMaker.java    From java-n-IDE-for-Android with Apache License 2.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 #23
Source File: PackageDocImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a list of all classes contained in this package, including
 * member classes of those classes, and their member classes, etc.
 */
private List<ClassDocImpl> getClasses(boolean filtered) {
    if (allClasses != null && !filtered) {
        return allClasses;
    }
    if (allClassesFiltered != null && filtered) {
        return allClassesFiltered;
    }
    ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null) {
            ClassSymbol s = (ClassSymbol)e.sym;
            ClassDocImpl c = env.getClassDoc(s);
            if (c != null && !c.isSynthetic())
                c.addAllClasses(classes, filtered);
        }
    }
    if (filtered)
        return allClassesFiltered = classes.toList();
    else
        return allClasses = classes.toList();
}
 
Example #24
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 #25
Source File: SerializedForm.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void computeDefaultSerializableFields(DocEnv env,
                                              ClassSymbol def,
                                              ClassDocImpl cd) {
    for (Scope.Entry e = def.members().elems; e != null; e = e.sibling) {
        if (e.sym != null && e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) == 0 &&
                (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                FieldDocImpl fd = env.getFieldDoc(f);
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.prepend(fd);
            }
        }
    }
}
 
Example #26
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 #27
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 #28
Source File: PackageDocImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a list of all classes contained in this package, including
 * member classes of those classes, and their member classes, etc.
 */
private List<ClassDocImpl> getClasses(boolean filtered) {
    if (allClasses != null && !filtered) {
        return allClasses;
    }
    if (allClassesFiltered != null && filtered) {
        return allClassesFiltered;
    }
    ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null) {
            ClassSymbol s = (ClassSymbol)e.sym;
            ClassDocImpl c = env.getClassDoc(s);
            if (c != null && !c.isSynthetic())
                c.addAllClasses(classes, filtered);
        }
    }
    if (filtered)
        return allClassesFiltered = classes.toList();
    else
        return allClasses = classes.toList();
}
 
Example #29
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 #30
Source File: SerializedForm.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void computeDefaultSerializableFields(DocEnv env,
                                              ClassSymbol def,
                                              ClassDocImpl cd) {
    for (Scope.Entry e = def.members().elems; e != null; e = e.sibling) {
        if (e.sym != null && e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) == 0 &&
                (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                FieldDocImpl fd = env.getFieldDoc(f);
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.prepend(fd);
            }
        }
    }
}