本文整理汇总了Java中org.apache.bcel.classfile.CodeException类的典型用法代码示例。如果您正苦于以下问题:Java CodeException类的具体用法?Java CodeException怎么用?Java CodeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeException类属于org.apache.bcel.classfile包,在下文中一共展示了CodeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSurroundingCaughtExceptions
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public Set<String> getSurroundingCaughtExceptions(int pc, int maxTryBlockSize) {
HashSet<String> result = new HashSet<String>();
if (code == null)
throw new IllegalStateException("Not visiting Code");
int size = maxTryBlockSize;
if (code.getExceptionTable() == null)
return result;
for (CodeException catchBlock : code.getExceptionTable()) {
int startPC = catchBlock.getStartPC();
int endPC = catchBlock.getEndPC();
if (pc >= startPC && pc <= endPC) {
int thisSize = endPC - startPC;
if (size > thisSize) {
result.clear();
size = thisSize;
Constant kind = constantPool.getConstant(catchBlock.getCatchType());
result.add("C" + catchBlock.getCatchType());
} else if (size == thisSize)
result.add("C" + catchBlock.getCatchType());
}
}
return result;
}
示例2: getSurroundingTryBlock
import org.apache.bcel.classfile.CodeException; //导入依赖的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;
}
示例3: visit
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
@Override
public void visit(CodeException obj) {
int type = obj.getCatchType();
if (type == 0)
return;
String name = getConstantPool().constantToString(getConstantPool().getConstant(type));
if (DEBUG) {
String msg = "Catching " + name + " in " + getFullyQualifiedMethodName();
if (msgs.add(msg))
System.out.println(msg);
}
if (name.equals("java.lang.IllegalMonitorStateException"))
bugReporter.reportBug(new BugInstance(this, "IMSE_DONT_CATCH_IMSE", HIGH_PRIORITY).addClassAndMethod(this)
.addSourceLine(this.classContext, this, obj.getHandlerPC()));
}
示例4: uniqueLocations
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
/**
* @param derefLocationSet
* @return
*/
private boolean uniqueLocations(Collection<Location> derefLocationSet) {
boolean uniqueDereferenceLocations = false;
CodeException[] exceptionTable = method.getCode().getExceptionTable();
if (exceptionTable == null)
return true;
checkForCatchAll: {
for (CodeException e : exceptionTable)
if (e.getCatchType() == 0)
break checkForCatchAll;
return true;
}
LineNumberTable table = method.getLineNumberTable();
if (table == null)
uniqueDereferenceLocations = true;
else {
BitSet linesMentionedMultipleTimes = classContext.linesMentionedMultipleTimes(method);
for (Location loc : derefLocationSet) {
int lineNumber = table.getSourceLine(loc.getHandle().getPosition());
if (lineNumber > 0 && !linesMentionedMultipleTimes.get(lineNumber))
uniqueDereferenceLocations = true;
}
}
return uniqueDereferenceLocations;
}
示例5: visit
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public void visit(CodeException obj) {
int type = obj.getCatchType();
if (type == 0) return;
String name = getConstantPool().constantToString(getConstantPool().getConstant(type));
if (DEBUG) {
String msg = "Catching " + name + " in " + getFullyQualifiedMethodName();
if (msgs.add(msg))
System.out.println(msg);
}
if (name.equals("java.lang.IllegalMonitorStateException"))
bugReporter.reportBug(new BugInstance(this, "IMSE_DONT_CATCH_IMSE", HIGH_PRIORITY)
.addClassAndMethod(this)
.addSourceLine(this, obj.getHandlerPC()));
}
示例6: getExceptionScope
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public int[] getExceptionScope(){
try {
CodeException[] exceptionTable = this.code.getExceptionTable();
int[] exception_scop = new int[exceptionTable.length * 2];
for (int i = 0; i < exceptionTable.length; i++) {
exception_scop[i * 2] = exceptionTable[i].getStartPC();
exception_scop[i * 2 + 1] = exceptionTable[i].getEndPC();
}
return exception_scop;
}catch (Exception e){
// e.printStackTrace();
}
return new int[0];
}
示例7: visitCodeException
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public void visitCodeException(CodeException c) {
c.toString(pool, false);
int catch_type = c.getCatchType();
if (catch_type == 0)
return;
String temp = pool.getConstantString(catch_type, Constants.CONSTANT_Class);
String str = Utility.compactClassName(temp, false);
log(" catch=" + str, Project.MSG_DEBUG);
design.checkClass(str);
}
示例8: visitCode
import org.apache.bcel.classfile.CodeException; //导入依赖的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;
}
示例9: visit
import org.apache.bcel.classfile.CodeException; //导入依赖的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;
}
示例10: getExceptionSig
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public static String getExceptionSig(DismantleBytecode dbc, CodeException e) {
if (e.getCatchType() == 0)
return "Ljava/lang/Throwable;";
Constant c = dbc.getConstantPool().getConstant(e.getCatchType());
if (c instanceof ConstantClass)
return "L" + ((ConstantClass) c).getBytes(dbc.getConstantPool()) + ";";
return "Ljava/lang/Throwable;";
}
示例11: visit
import org.apache.bcel.classfile.CodeException; //导入依赖的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;
}
示例12: getCodeExceptions
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
/**
* @return code exceptions for `Code' attribute
*/
private CodeException[] getCodeExceptions() {
int size = exception_vec.size();
CodeException[] c_exc = new CodeException[size];
try {
for (int i = 0; i < size; i++) {
CodeExceptionGen c = (CodeExceptionGen) exception_vec.get(i);
c_exc[i] = c.getCodeException(cp);
}
} catch (ArrayIndexOutOfBoundsException e) {
}
return c_exc;
}
示例13: visitCodeException
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public void visitCodeException(CodeException obj){
// Code constraints are checked in Pass3 (3a and 3b).
// This does not represent an Attribute but is only
// related to internal BCEL data representation.
// see visitCode(Code)
}
示例14: atCatchBlock
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public boolean atCatchBlock() {
for (CodeException e : getCode().getExceptionTable())
if (e.getHandlerPC() == getPC())
return true;
return false;
}
示例15: getSurroundingTryBlock
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public CodeException getSurroundingTryBlock(int pc) {
return getSurroundingTryBlock(null, pc);
}