本文整理汇总了Java中com.sun.org.apache.bcel.internal.classfile.Code类的典型用法代码示例。如果您正苦于以下问题:Java Code类的具体用法?Java Code怎么用?Java Code使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Code类属于com.sun.org.apache.bcel.internal.classfile包,在下文中一共展示了Code类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toString
import com.sun.org.apache.bcel.internal.classfile.Code; //导入依赖的package包/类
/**
* Return string representation close to declaration format, e.g. public
* static void main(String[]) throws IOException'
*
* @return String representation of the method.
*/
@Override
public final String toString() {
final String access = Utility.accessToString(super.getAccessFlags());
String signature = Type.getMethodSignature(super.getType(), arg_types);
signature = Utility.methodSignatureToString(signature, super.getName(), access, true,
getLocalVariableTable(super.getConstantPool()));
final StringBuilder buf = new StringBuilder(signature);
for (final Attribute a : getAttributes()) {
if (!((a instanceof Code) || (a instanceof ExceptionTable))) {
buf.append(" [").append(a).append("]");
}
}
if (throws_vec.size() > 0) {
for (final String throwsDescriptor : throws_vec) {
buf.append("\n\t\tthrows ").append(throwsDescriptor);
}
}
return buf.toString();
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:MethodGen.java
示例2: writeMethod
import com.sun.org.apache.bcel.internal.classfile.Code; //导入依赖的package包/类
private void writeMethod( final Method method, final int method_number ) {
// Get raw signature
final String signature = method.getSignature();
// Get array of strings containing the argument types
final String[] args = Utility.methodSignatureArgumentTypes(signature, false);
// Get return type string
final String type = Utility.methodSignatureReturnType(signature, false);
// Get method name
final String name = method.getName();
String html_name;
// Get method's access flags
String access = Utility.accessToString(method.getAccessFlags());
// Get the method's attributes, the Code Attribute in particular
final 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, " ", " ");
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);
final byte tag = attributes[i].getTag();
if (tag == Const.ATTR_EXCEPTIONS) {
file.print("<TR VALIGN=TOP><TD COLSPAN=2></TD><TH ALIGN=LEFT>throws</TH><TD>");
final 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 == Const.ATTR_CODE) {
final 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:56,代码来源:MethodHTML.java
注:本文中的com.sun.org.apache.bcel.internal.classfile.Code类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论