• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExceptionTable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.bcel.classfile.ExceptionTable的典型用法代码示例。如果您正苦于以下问题:Java ExceptionTable类的具体用法?Java ExceptionTable怎么用?Java ExceptionTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExceptionTable类属于org.apache.bcel.classfile包,在下文中一共展示了ExceptionTable类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: visit

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
public void visit(ExceptionTable obj) {
	if (DEBUG) {
		String names[] = obj.getExceptionNames();
		for (int i = 0; i < names.length; i++)
			if (names[i].equals("java.lang.Exception")
			        || names[i].equals("java.lang.Throwable"))
				System.out.println(names[i] + " thrown by " + getFullyQualifiedMethodName());
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:DontCatchIllegalMonitorStateException.java


示例2: findDeclaredExceptions

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
/**
 * Find the declared exceptions for the method called
 * by given instruction.
 *
 * @param inv the InvokeInstruction
 * @param cpg the ConstantPoolGen used by the class the InvokeInstruction belongs to
 * @return array of ObjectTypes of thrown exceptions, or null
 *         if we can't find the list of declared exceptions
 */
public static ObjectType[] findDeclaredExceptions(InvokeInstruction inv, ConstantPoolGen cpg)
        throws ClassNotFoundException {
	Method m = findPrototypeMethod(inv, cpg);

	if (m == null)
		return null;

	ExceptionTable exTable = m.getExceptionTable();
	if (exTable == null)
		return new ObjectType[0];

	String[] exNameList = exTable.getExceptionNames();
	ObjectType[] result = new ObjectType[exNameList.length];
	for (int i = 0; i < exNameList.length; ++i) {
		result[i] = new ObjectType(exNameList[i]);
	}
	return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:Hierarchy.java


示例3: visitMethod

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
/**
 * @see org.apache.bcel.classfile.Visitor#visitMethod(org.apache.bcel.classfile.Method)
 */
public void visitMethod(Method m) {
	log("      method=" + m.getName(), Project.MSG_VERBOSE);
	String retType = Utility.methodSignatureReturnType(m.getSignature());
	log("         method ret type=" + retType, Project.MSG_VERBOSE);
	if (!"void".equals(retType))
		design.checkClass(retType);

	String[] types = Utility.methodSignatureArgumentTypes(m.getSignature());
	for (int i = 0; i < types.length; i++) {
		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]);
		}
	}

	processInstructions(m);
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:28,代码来源:VisitorImpl.java


示例4: visitExceptionTable

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
public void visitExceptionTable(ExceptionTable e) {
  String[] names = e.getExceptionNames();
  for(int i=0; i < names.length; i++)
    out.println(".throws " + names[i].replace('.', '/'));

  printEndMethod(e);
}
 
开发者ID:diana-hep,项目名称:root4j,代码行数:8,代码来源:JasminVisitor.java


示例5: visitExceptionTable

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
@Override
public void visitExceptionTable(ExceptionTable e) {
    /*
     * String[] names = e.getExceptionNames(); for (int i = 0; i <
     * names.length; i++) out.println(".throws " +
     * names[i].replace('.', '/'));
     * 
     * printEndMethod(e);
     */
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:ClassToXmlvmProcess.java


示例6: visit

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
@Override
public void visit(ExceptionTable obj) {
    if (DEBUG) {
        String names[] = obj.getExceptionNames();
        for (String name : names)
            if (name.equals("java.lang.Exception") || name.equals("java.lang.Throwable"))
                System.out.println(name + " thrown by " + getFullyQualifiedMethodName());
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:10,代码来源:DontCatchIllegalMonitorStateException.java


示例7: thrownExceptions

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
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;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:9,代码来源:UselessSubclassMethod.java


示例8: getExceptionTable

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
/**
 * @return `Exceptions' attribute of all the exceptions thrown by this method.
 */
private ExceptionTable getExceptionTable( ConstantPoolGen cp ) {
    int size = throws_vec.size();
    int[] ex = new int[size];
    try {
        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());
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:15,代码来源:MethodGen.java


示例9: toString

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
/**
 * Returns a string that represents a method part of
 * a JNI-style header file.
 */
public String toString() {
    String n = System.getProperty("line.separator");
    StringBuffer result = new StringBuffer();

    String methodName = Mangler.mangleUnicode(
            clazz.getName() + "." + getName() + getSignature());

    // 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);
        }
    }

    result.append(" */" + n);

    // Print a method declaration in a readable way.
    result.append("JNIEXPORT " + getJNIReturnType() + " JNICALL" + n);
    result.append("Java_" + clazz.getMangledName() + "_" + getMangledName());

    result.append('(');
    result.append("JNIEnv *");
    if (isStatic()) {
        result.append(", jclass");
    } else {
        result.append(", jobject");
    }
    Type types[] = getArgumentTypes();
    for (int i = 0; i < types.length; i++) {
        result.append(", ");
        if (i == 0) {
            result.append(n);
            result.append("    ");
        }
        result.append(ClazzMethod.getJNIType(types[i]));
    }
    result.append(");" + n);
    result.append(n);

    return result.toString();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:54,代码来源:ClazzMethod.java


示例10: toAlternativeString

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
/**
 * Returns an alternative string that represents a method part of
 * a JNI-style header file.
 */
public String toAlternativeString() {
    String n = System.getProperty("line.separator");
    StringBuffer result = new StringBuffer();

    // Print a method comment.
    result.append("/*" + n);
    result.append(" * Class:     " + Mangler.mangleUnicode(clazz.getName())
            + n);
    result.append(" * Method:    " + Mangler.mangleUnicode(getName()) + n);
    result.append(" * Signature: " + getSignature() + 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);
        }
    }

    result.append(" */" + n);

    // Print a method declaration in a readable way.
    result.append("JNIEXPORT " + getJNIReturnType() + " JNICALL "
            + "Java_" + clazz.getMangledName() + "_" + getMangledName() + n);

    result.append("  (JNIEnv *, ");
    if (isStatic()) {
        result.append("jclass");
    } else {
        result.append("jobject");
    }
    Type types[] = getArgumentTypes();
    for (int i = 0; i < types.length; i++) {
        result.append(", ");
        result.append(ClazzMethod.getJNIType(types[i]));
    }
    result.append(");" + n);
    result.append(n);

    return result.toString();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:49,代码来源:ClazzMethod.java


示例11: visit

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
public void visit(ExceptionTable obj) {
    visit((Attribute) obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java


示例12: visitExceptionTable

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
public void visitExceptionTable(ExceptionTable obj) {
    visit(obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java


示例13: getMethod

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
/**
 * Get method object. Never forget to call setMaxStack() or setMaxStack(max), respectively,
 * before calling this method (the same applies for max locals).
 *
 * @return method object
 */
public Method getMethod() {
    String signature = getSignature();
    int name_index = cp.addUtf8(name);
    int signature_index = cp.addUtf8(signature);
    /* Also updates positions of instructions, i.e., their indices
     */
    byte[] byte_code = null;
    if (il != null) {
        byte_code = il.getByteCode();
    }
    LineNumberTable lnt = null;
    LocalVariableTable lvt = null;
    /* Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.)
     */
    if ((variable_vec.size() > 0) && !strip_attributes) {
        addCodeAttribute(lvt = getLocalVariableTable(cp));
    }
    if ((line_number_vec.size() > 0) && !strip_attributes) {
        addCodeAttribute(lnt = getLineNumberTable(cp));
    }
    Attribute[] code_attrs = getCodeAttributes();
    /* Each attribute causes 6 additional header bytes
     */
    int attrs_len = 0;
    for (int i = 0; i < code_attrs.length; i++) {
        attrs_len += (code_attrs[i].getLength() + 6);
    }
    CodeException[] c_exc = getCodeExceptions();
    int exc_len = c_exc.length * 8; // Every entry takes 8 bytes
    Code code = null;
    if ((il != null) && !isAbstract() && !isNative()) {
        // Remove any stale code attribute
        Attribute[] attributes = getAttributes();
        for (int i = 0; i < attributes.length; i++) {
            Attribute a = attributes[i];
            if (a instanceof Code) {
                removeAttribute(a);
            }
        }
        code = new Code(cp.addUtf8("Code"), 8 + byte_code.length + // prologue byte code
                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
            .getConstantPool());
    // Undo effects of adding attributes
    if (lvt != null) {
        removeCodeAttribute(lvt);
    }
    if (lnt != null) {
        removeCodeAttribute(lnt);
    }
    if (code != null) {
        removeAttribute(code);
    }
    if (et != null) {
        removeAttribute(et);
    }
    return m;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:74,代码来源:MethodGen.java


示例14: visitExceptionTable

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
public void visitExceptionTable(ExceptionTable obj) {
    tostring = toString(obj);
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:4,代码来源:StringRepresentation.java


示例15: writeMethod

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
private final void writeMethod( Method method, int method_number ) throws IOException {
    // Get raw signature
    String signature = method.getSignature();
    // Get array of strings containing the argument types 
    String[] args = Utility.methodSignatureArgumentTypes(signature, false);
    // Get return type string
    String type = Utility.methodSignatureReturnType(signature, false);
    // Get method name
    String name = method.getName(), html_name;
    // Get method's access flags
    String access = Utility.accessToString(method.getAccessFlags());
    // Get the method's attributes, the Code Attribute in particular
    Attribute[] attributes = method.getAttributes();
    /* HTML doesn't like names like <clinit> and spaces are places to break
     * lines. Both we don't want...
     */
    access = Utility.replace(access, " ", "&nbsp;");
    html_name = Class2HTML.toHTML(name);
    file.print("<TR VALIGN=TOP><TD><FONT COLOR=\"#FF0000\"><A NAME=method" + method_number
            + ">" + access + "</A></FONT></TD>");
    file.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" + "<A HREF=" + class_name
            + "_code.html#method" + method_number + " TARGET=Code>" + html_name
            + "</A></TD>\n<TD>(");
    for (int i = 0; i < args.length; i++) {
        file.print(Class2HTML.referenceType(args[i]));
        if (i < args.length - 1) {
            file.print(", ");
        }
    }
    file.print(")</TD></TR>");
    // Check for thrown exceptions
    for (int i = 0; i < attributes.length; i++) {
        attribute_html.writeAttribute(attributes[i], "method" + method_number + "@" + i,
                method_number);
        byte tag = attributes[i].getTag();
        if (tag == ATTR_EXCEPTIONS) {
            file.print("<TR VALIGN=TOP><TD COLSPAN=2></TD><TH ALIGN=LEFT>throws</TH><TD>");
            int[] exceptions = ((ExceptionTable) attributes[i]).getExceptionIndexTable();
            for (int j = 0; j < exceptions.length; j++) {
                file.print(constant_html.referenceConstant(exceptions[j]));
                if (j < exceptions.length - 1) {
                    file.print(", ");
                }
            }
            file.println("</TD></TR>");
        } else if (tag == ATTR_CODE) {
            Attribute[] c_a = ((Code) attributes[i]).getAttributes();
            for (int j = 0; j < c_a.length; j++) {
                attribute_html.writeAttribute(c_a[j], "method" + method_number + "@" + i + "@"
                        + j, method_number);
            }
        }
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:55,代码来源:MethodHTML.java


示例16: visitExceptionTable

import org.apache.bcel.classfile.ExceptionTable; //导入依赖的package包/类
public void visitExceptionTable(ExceptionTable e) {
	String[] names = e.getExceptionNames();
	for (int i = 0; i < names.length; i++)
		out.println("    throws " + names[i].replace('.', '/'));
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:6,代码来源:DecompilingVisitor.java



注:本文中的org.apache.bcel.classfile.ExceptionTable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Message类代码示例发布时间:2022-05-22
下一篇:
Java DebugUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap