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

IClass.IMethod org::codehaus::janino::UnitCompiler::findIMethod ( Java.MethodInvocation  mi  )  throws CompileException [inline]

Find named methods of "targetType", examine the argument types and choose the most specific method. Check that only the allowed exceptions are thrown.

Notice that the returned IClass.IMethod may be declared in an enclosing type.

Returns:
The selected IClass.IMethod or null

Definition at line 5536 of file UnitCompiler.java.

                                                                                        {
        IClass.IMethod iMethod;
        FIND_METHOD: {

            // Method declared by enclosing type declarations?
            for (Java.Scope s = mi.getEnclosingBlockStatement(); !(s instanceof Java.CompilationUnit); s = s.getEnclosingScope()) {
                if (s instanceof Java.TypeDeclaration) {
                    Java.TypeDeclaration td = (Java.TypeDeclaration) s;
    
                    // Find methods with specified name.
                    iMethod = this.findIMethod(
                        (Locatable) mi,    // l
                        (                  // targetType
                            mi.optionalTarget == null ?
                            this.resolve(td) :
                            this.getType(mi.optionalTarget)
                        ),
                        mi.methodName,     // methodName
                        mi.arguments       // arguments
                    );
                    if (iMethod != null) break FIND_METHOD;
                }
            }

            // Static method declared through single static import?
            {
                Object o = this.singleStaticImports.get(mi.methodName);
                if (o instanceof List) {
                    IClass declaringIClass = ((IMethod) ((List) o).get(0)).getDeclaringIClass();
                    iMethod = this.findIMethod(
                        (Locatable) mi,  // l
                        declaringIClass, // targetType
                        mi.methodName,   // methodName
                        mi.arguments     // arguments
                    );
                    if (iMethod != null) break FIND_METHOD;
                }
            }

            // Static method declared through static-import-on-demand?
            for (Iterator it = this.staticImportsOnDemand.iterator(); it.hasNext();) {
                IClass iClass = (IClass) it.next();
                iMethod = this.findIMethod(
                    (Locatable) mi, // l
                    iClass,         // targetType
                    mi.methodName,  // methodName
                    mi.arguments    // arguments
                );
                if (iMethod != null) break FIND_METHOD;
            }

            this.compileError("A method named \"" + mi.methodName + "\" is not declared in any enclosing class nor any supertype, nor through a static import", mi.getLocation());
            return fakeIMethod(this.iClassLoader.OBJECT, mi.methodName, mi.arguments);
        }

        this.checkThrownExceptions(mi, iMethod);
        return iMethod;
    }


Generated by  Doxygen 1.6.0   Back to index