Logo Search packages:      
Sourcecode: janino version File versions  Download package

IClass.IField org::codehaus::janino::UnitCompiler::findIField ( IClass  iClass,
String  name,
Location  location 
) throws CompileException [inline, private]

Find a named field in the given IClass. Honor superclasses and interfaces. See JLS 8.3.

Returns:
null if no field is found

Definition at line 7785 of file UnitCompiler.java.

                              {

        // Search for a field with the given name in the current class.
        IClass.IField[] fields = iClass.getDeclaredIFields();
        for (int i = 0; i < fields.length; ++i) {
            final IClass.IField f = fields[i];
            if (name.equals(f.getName())) return f;
        }

        // Examine superclass.
        IClass.IField f = null;
        {
            IClass superclass = iClass.getSuperclass();
            if (superclass != null) f = this.findIField(superclass, name, location);
        }

        // Examine interfaces.
        IClass[] ifs = iClass.getInterfaces();
        for (int i = 0; i < ifs.length; ++i) {
            IClass.IField f2 = this.findIField(ifs[i], name, location);
            if (f2 != null) {
                if (f != null) throw new CompileException("Access to field \"" + name + "\" is ambiguous - both \"" + f.getDeclaringIClass() + "\" and \"" + f2.getDeclaringIClass() + "\" declare it", location);
                f = f2;
            }
        }
        return f;
    }


Generated by  Doxygen 1.6.0   Back to index