本文整理汇总了Java中org.apache.bcel.classfile.Code.getExceptionTable方法的典型用法代码示例。如果您正苦于以下问题:Java Code.getExceptionTable方法的具体用法?Java Code.getExceptionTable怎么用?Java Code.getExceptionTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.Code
的用法示例。
在下文中一共展示了Code.getExceptionTable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSurroundingTryBlock
import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
public static @CheckForNull
CodeException getSurroundingTryBlock(ConstantPool constantPool, Code code, @CheckForNull String vmNameOfExceptionClass, int pc) {
int size = Integer.MAX_VALUE;
if (code.getExceptionTable() == null)
return null;
CodeException result = null;
for (CodeException catchBlock : code.getExceptionTable()) {
if (vmNameOfExceptionClass != null) {
Constant catchType = constantPool.getConstant(catchBlock.getCatchType());
if (catchType == null || catchType instanceof ConstantClass
&& !((ConstantClass) catchType).getBytes(constantPool).equals(vmNameOfExceptionClass))
continue;
}
int startPC = catchBlock.getStartPC();
int endPC = catchBlock.getEndPC();
if (pc >= startPC && pc <= endPC) {
int thisSize = endPC - startPC;
if (size > thisSize) {
size = thisSize;
result = catchBlock;
}
}
}
return result;
}
示例2: visitCode
import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
@Override
public void visitCode(Code obj) {
code = obj;
super.visitCode(obj);
CodeException[] exceptions = obj.getExceptionTable();
for (CodeException exception : exceptions)
exception.accept(this);
Attribute[] attributes = obj.getAttributes();
for (Attribute attribute : attributes)
attribute.accept(this);
visitAfter(obj);
code = null;
}
示例3: visit
import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
@Override
public void visit(Method method) {
String cName = getDottedClassName();
// System.out.println(getFullyQualifiedMethodName());
isPublicStaticVoidMain = method.isPublic() && method.isStatic() && getMethodName().equals("main")
|| cName.toLowerCase().indexOf("benchmark") >= 0;
prevOpcodeWasReadLine = false;
Code code = method.getCode();
if (code != null) {
this.exceptionTable = code.getExceptionTable();
}
if (this.exceptionTable == null) {
this.exceptionTable = new CodeException[0];
}
primitiveObjCtorSeen = null;
ctorSeen = false;
randomNextIntState = 0;
checkForBitIorofSignedByte = false;
isEqualsObject = getMethodName().equals("equals") && getMethodSig().equals("(Ljava/lang/Object;)Z") && !method.isStatic();
sawInstanceofCheck = false;
reportedBadCastInEquals = false;
freshRandomOnTos = false;
sinceBufferedInputStreamReady = 100000;
sawCheckForNonNegativeSignedByte = -1000;
sawLoadOfMinValue = false;
}
示例4: visit
import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
@Override
public void visit(Method method) {
String cName = getDottedClassName();
// System.out.println(getFullyQualifiedMethodName());
isPublicStaticVoidMain = method.isPublic() && method.isStatic() && getMethodName().equals("main")
|| cName.toLowerCase().indexOf("benchmark") >= 0;
prevOpcodeWasReadLine = false;
Code code = method.getCode();
if (code != null) {
this.exceptionTable = code.getExceptionTable();
}
if (this.exceptionTable == null) {
this.exceptionTable = new CodeException[0];
}
primitiveObjCtorSeen = null;
ctorSeen = false;
randomNextIntState = 0;
checkForBitIorofSignedByte = false;
isEqualsObject = getMethodName().equals("equals") && getMethodSig().equals("(Ljava/lang/Object;)Z") && !method.isStatic();
sawInstanceofCheck = false;
reportedBadCastInEquals = false;
freshRandomOnTos = false;
sinceBufferedInputStreamReady = 100000;
sawCheckForNonNegativeSignedByte = -1000;
sawLoadOfMinValue = false;
previousMethodCall = null;
}
示例5: getSizeOfSurroundingTryBlock
import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
public static int getSizeOfSurroundingTryBlock(ConstantPool constantPool, Code code,
@CheckForNull String vmNameOfExceptionClass, int pc) {
int size = Integer.MAX_VALUE;
int tightStartPC = 0;
int tightEndPC = Integer.MAX_VALUE;
if (code.getExceptionTable() == null)
return size;
for (CodeException catchBlock : code.getExceptionTable()) {
if (vmNameOfExceptionClass != null) {
Constant catchType = constantPool.getConstant(catchBlock.getCatchType());
if (catchType == null || catchType instanceof ConstantClass
&& !((ConstantClass) catchType).getBytes(constantPool).equals(vmNameOfExceptionClass))
continue;
}
int startPC = catchBlock.getStartPC();
int endPC = catchBlock.getEndPC();
if (pc >= startPC && pc <= endPC) {
int thisSize = endPC - startPC;
if (size > thisSize) {
size = thisSize;
tightStartPC = startPC;
tightEndPC = endPC;
}
}
}
if (size == Integer.MAX_VALUE)
return size;
// try to guestimate number of lines that correspond
size = (size + 7) / 8;
LineNumberTable lineNumberTable = code.getLineNumberTable();
if (lineNumberTable == null)
return size;
int count = 0;
for (LineNumber line : lineNumberTable.getLineNumberTable()) {
if (line.getStartPC() > tightEndPC)
break;
if (line.getStartPC() >= tightStartPC)
count++;
}
return count;
}
示例6: getSizeOfSurroundingTryBlock
import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
public static int getSizeOfSurroundingTryBlock(ConstantPool constantPool, Code code,
@CheckForNull @SlashedClassName String vmNameOfExceptionClass, int pc) {
int size = Integer.MAX_VALUE;
int tightStartPC = 0;
int tightEndPC = Integer.MAX_VALUE;
if (code.getExceptionTable() == null)
return size;
for (CodeException catchBlock : code.getExceptionTable()) {
if (vmNameOfExceptionClass != null) {
Constant catchType = constantPool.getConstant(catchBlock.getCatchType());
if (catchType == null) continue;
if (catchType instanceof ConstantClass) {
String name = ((ConstantClass) catchType).getBytes(constantPool);
if (!name.equals(vmNameOfExceptionClass))
continue;
}
}
int startPC = catchBlock.getStartPC();
int endPC = catchBlock.getEndPC();
if (pc >= startPC && pc <= endPC) {
int thisSize = endPC - startPC;
if (size > thisSize) {
size = thisSize;
tightStartPC = startPC;
tightEndPC = endPC;
}
}
}
if (size == Integer.MAX_VALUE)
return size;
// try to guestimate number of lines that correspond
size = (size + 7) / 8;
LineNumberTable lineNumberTable = code.getLineNumberTable();
if (lineNumberTable == null)
return size;
int count = 0;
for (LineNumber line : lineNumberTable.getLineNumberTable()) {
if (line.getStartPC() > tightEndPC)
break;
if (line.getStartPC() >= tightStartPC)
count++;
}
return count;
}