Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Method


            return EMPTY_CLASS_ITEMS;
        } else {
            Method[] methods = getMethods();
            ClassItem[] items = new ClassItem[methods.length];
            for (int i = 0; i < methods.length; i++) {
                Method method = methods[i];
                items[i] = new ClassItem(method.getName(), this, method);
            }
            return items;
        }       
    }
View Full Code Here


        if (m_curClass != null) {
   
            // check for match to method defined in class
            Method[] methods = getMethods();
            for (int i = 0; i < methods.length; i++) {
                Method method = methods[i];
                if (method.getName().equals(name)) {
                    if (method.getSignature().startsWith(sig)) {
                        return method;
                    }
                }
            }
   
            // try match to method inherited from superclass
            if (m_superClass != null) {
                Method method = m_superClass.getAccessibleMethod(name, sig);
                if (method != null && ((m_isSamePackage &&
                    !method.isPrivate()) || method.isPublic() ||
                    method.isProtected())) {
                    return method;
                }
            }
           
        }
View Full Code Here

     * @param name method name
     * @param sig partial method signature to be matched
     * @return method information, or <code>null</code> if method not found
     */
    public ClassItem getMethod(String name, String sig) {
        Method method = getAccessibleMethod(name, sig);
        if (method == null) {
            return null;
        } else {
            ClassItem item = (ClassItem)m_itemMap.get(method);
            if (item == null) {
View Full Code Here

     * @param name method name
     * @param sigs possible signatures for method (including return type)
     * @return method information, or <code>null</code> if method not found
     */
    public ClassItem getMethod(String name, String[] sigs) {
        Method method = null;
        for (int i = 0; method == null && i < sigs.length; i++) {
            method = getAccessibleMethod(name, sigs[i]);
        }
        if (method == null) {
            return null;
View Full Code Here

            return null;
        }

        // check for match to method defined in class
        Method[] methods = getMethods();
        Method best = null;
        int diff = Integer.MAX_VALUE;
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
            if (method.getName().equals(name) && matchAccess(method, access)) {
               
                // make sure the return type is compatible
                boolean match = true;
                int ndiff = 0;
                if (ret != null) {
                    Type type = method.getReturnType();
                    match = isAssignmentCompatible(ret, type);
                }
                if (match && args != null) {
                   
                    // check closeness of argument types
                    Type[] types = method.getArgumentTypes();
                    if (args.length == types.length) {
                        for (int j = 0; j < args.length; j++) {
                            Type type = types[j];
                            Type arg = args[j];
                            if (!type.equals(arg)) {
View Full Code Here

            atypes = new Type[args.length];
            for (int i = 0; i < args.length; i++) {
                atypes[i] = ClassItem.typeFromName(args[i]);
            }
        }
        Method method =
            getBestAccessibleMethod(name, PRIVATE_ACCESS, rtype, atypes);
        if (method == null) {
            return null;
        }
        ClassItem item = (ClassItem)m_itemMap.get(method);
View Full Code Here

        if (m_curClass != null) {
   
            // check for match to method defined in class
            Method[] methods = getMethods();
            for (int i = 0; i < methods.length; i++) {
                Method method = methods[i];
                if (method.getName().equals("<init>")) {
                    if (method.getSignature().startsWith(sig)) {
                        ClassItem item = (ClassItem)m_itemMap.get(method);
                        if (item == null) {
                            item = new ClassItem("<init>", this, method);
                            m_itemMap.put(method, item);
                        }
View Full Code Here

        if (m_curClass != null) {
   
            // check for match to method defined in class
            Method[] methods = getMethods();
            for (int i = 0; i < methods.length; i++) {
                Method method = methods[i];
                if (method.getName().equals(name) && method.isStatic()) {
                    if (method.getSignature().startsWith(sig)) {
                        ClassItem item = (ClassItem)m_itemMap.get(method);
                        if (item == null) {
                            item = new ClassItem(name, this, method);
                            m_itemMap.put(method, item);
                        }
View Full Code Here

        // check for binding methods defined in class
        Method[] methods = getMethods();
        int count = 0;
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
            String name = method.getName();
            if (name.startsWith(prefix)) {
                count++;
            } else {
                String sig = method.getSignature();
                for (int j = 0; j < matches.length; j += 2) {
                    if (name.equals(matches[j]) && sig.equals(matches[j+1])) {
                        count++;
                        break;
                    }
                }
            }
        }
       
        // generate array of methods found
        if (count == 0) {
            return EMPTY_METHOD_ARRAY;
        } else {
            ExistingMethod[] exists = new ExistingMethod[count];
            int fill = 0;
            for (int i = 0; i < methods.length; i++) {
                Method method = methods[i];
                String name = method.getName();
                boolean match = name.startsWith(prefix);
                if (!match) {
                    String sig = method.getSignature();
                    for (int j = 0; j < matches.length; j += 2) {
                        if (name.equals(matches[j]) &&
                            sig.equals(matches[j+1])) {
                            match = true;
                            break;
View Full Code Here

        if (m_suffixMap == null) {
            m_suffixMap = new HashMap();
            if (m_curClass != null) {
                Method[] methods = getMethods();
                for (int i = 0; i < methods.length; i++) {
                    Method method = methods[i];
                    String mname = method.getName();
                    if (isSuffixName(mname)) {
                        m_suffixMap.put(mname, method);
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.bcel.classfile.Method

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.