Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.ExceptionTable


     * @return array of exceptions thrown by method, or <code>null</code> if
     * a field
     */
    public String[] getExceptions() {
        if (m_item instanceof Method) {
            ExceptionTable etab = ((Method)m_item).getExceptionTable();
            if (etab != null) {
                return etab.getExceptionNames();
            } else {
                return org.jibx.runtime.Utility.EMPTY_STRING_ARRAY;
            }
        }
        return null;
View Full Code Here


     * @return computed hash code for method
     */

    public static int computeMethodHash(Method method) {
        int hash = method.getSignature().hashCode();
        ExceptionTable etab = method.getExceptionTable();
        if (etab != null) {
            String[] excepts = etab.getExceptionNames();
            for (int i = 0; i < excepts.length; i++) {
                hash += excepts[i].hashCode();
            }
        }
        byte[] code = method.getCode().getCode();
View Full Code Here

     * @return <code>true</code> if the equal, <code>false</code> if not
     */
    public static boolean equalMethods(Method a, Method b) {
           
        // check the exceptions thrown by the method
        ExceptionTable etaba = a.getExceptionTable();
        ExceptionTable etabb = b.getExceptionTable();
        if (etaba != null && etabb != null) {
            String[] aexcepts = etaba.getExceptionNames();
            String[] bexcepts = etabb.getExceptionNames();
            if (!Arrays.equals(aexcepts, bexcepts)) {
                return false;
            }
        } else if (etaba != null || etabb != null) {
            return false;
View Full Code Here

            for (int i = 0; i < size; i++) {
                ex[i] = cp.addClass((String) throws_vec.get(i));
            }
        } catch (ArrayIndexOutOfBoundsException e) {
        }
        return new ExceptionTable(cp.addUtf8("Exceptions"), 2 + 2 * size, ex, cp.getConstantPool());
    }
View Full Code Here

                    2 + exc_len + // exceptions
                    2 + attrs_len, // attributes
                    max_stack, max_locals, byte_code, c_exc, code_attrs, cp.getConstantPool());
            addAttribute(code);
        }
        ExceptionTable et = null;
        if (throws_vec.size() > 0) {
            addAttribute(et = getExceptionTable(cp));
            // Add `Exceptions' if there are "throws" clauses
        }
        Method m = new Method(access_flags, name_index, signature_index, getAttributes(), cp
View Full Code Here

        return null;
    }

    HashSet<String> thrownExceptions(Method m) {
        HashSet<String> result = new HashSet<String>();
        ExceptionTable exceptionTable = m.getExceptionTable();
        if (exceptionTable != null) {
            for (String e : exceptionTable.getExceptionNames()) {
                result.add(e);
            }
        }
        return result;
    }
View Full Code Here

        }
        methodMetaData.setParameterTypes(parameterTypes);

        // exceptions
        String[] exceptions;
        ExceptionTable exceptionTable = method.getExceptionTable();
        if (exceptionTable != null) {
            exceptions = exceptionTable.getExceptionNames();
        }
        else {
            exceptions = new String[0];
        }
        methodMetaData.setExceptionTypes(exceptions);
View Full Code Here

      log("         method param[" + i + "]=" + types[i],
          Project.MSG_VERBOSE);
      design.checkClass(types[i]);
    }

    ExceptionTable excs = m.getExceptionTable();
    if (excs != null) {
      types = excs.getExceptionNames();
      for (int i = 0; i < types.length; i++) {
        log("         exc=" + types[i], Project.MSG_VERBOSE);
        design.checkClass(types[i]);
      }
    }
View Full Code Here

        }
        methodMetaData.setParameterTypes(parameterTypes);

        // exceptions
        String[] exceptions;
        ExceptionTable exceptionTable = method.getExceptionTable();
        if (exceptionTable != null) {
            exceptions = exceptionTable.getExceptionNames();
        }
        else {
            exceptions = new String[0];
        }
        methodMetaData.setExceptionTypes(exceptions);
View Full Code Here

        // Print a method comment.
        result.append("/*" + n);
        result.append(" * Method: " + methodName + n);

        // Print the thrown exceptions.
        ExceptionTable etable = wrappedMethod.getExceptionTable();
        if (etable != null) {
            String e = etable.toString();
            if (e.length() > 0) {
                result.append(" * Throws: ");
                result.append(e);
                result.append(n);
            }
View Full Code Here

TOP

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

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.