本文整理汇总了Java中org.apache.bcel.classfile.CodeException类的典型用法代码示例。如果您正苦于以下问题:Java CodeException类的具体用法?Java CodeException怎么用?Java CodeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeException类属于org.apache.bcel.classfile包,在下文中一共展示了CodeException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:24,代码来源:PreorderVisitor.java
示例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;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:26,代码来源:Util.java
示例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()));
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:17,代码来源:DontCatchIllegalMonitorStateException.java
示例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;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:30,代码来源:FindNullDeref.java
示例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()));
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:DontCatchIllegalMonitorStateException.java
示例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];
}
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:15,代码来源:StringCodeAnalysis.java
示例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);
}
开发者ID:cniweb,项目名称:ant-contrib,代码行数:15,代码来源:VisitorImpl.java
示例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;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:14,代码来源:PreorderVisitor.java
示例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;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:29,代码来源:DumbMethods.java
示例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;";
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:9,代码来源:OpcodeStack.java
示例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;
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:30,代码来源:DumbMethods.java
示例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;
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:16,代码来源:MethodGen.java
示例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)
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:8,代码来源:Pass2Verifier.java
示例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;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:7,代码来源:DismantleBytecode.java
示例15: getSurroundingTryBlock
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public CodeException getSurroundingTryBlock(int pc) {
return getSurroundingTryBlock(null, pc);
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:PreorderVisitor.java
示例16: visit
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public void visit(CodeException obj) {
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:3,代码来源:BetterVisitor.java
示例17: visitCodeException
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
public void visitCodeException(CodeException obj) {
visit(obj);
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java
示例18: getSizeOfSurroundingTryBlock
import org.apache.bcel.classfile.CodeException; //导入依赖的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;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:45,代码来源:Util.java
示例19: flush
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
/**
* Flush out cached state at the end of a method.
*/
private void flush() {
if (pendingAbsoluteValueBug != null) {
absoluteValueAccumulator.accumulateBug(pendingAbsoluteValueBug, pendingAbsoluteValueBugSourceLine);
pendingAbsoluteValueBug = null;
pendingAbsoluteValueBugSourceLine = null;
}
accumulator.reportAccumulatedBugs();
if (sawLoadOfMinValue)
absoluteValueAccumulator.clearBugs();
else
absoluteValueAccumulator.reportAccumulatedBugs();
if (gcInvocationBugReport != null && !sawCurrentTimeMillis) {
// Make sure the GC invocation is not in an exception handler
// for OutOfMemoryError.
boolean outOfMemoryHandler = false;
for (CodeException handler : exceptionTable) {
if (gcInvocationPC < handler.getHandlerPC() || gcInvocationPC > handler.getHandlerPC() + OOM_CATCH_LEN) {
continue;
}
int catchTypeIndex = handler.getCatchType();
if (catchTypeIndex > 0) {
ConstantPool cp = getThisClass().getConstantPool();
Constant constant = cp.getConstant(catchTypeIndex);
if (constant instanceof ConstantClass) {
String exClassName = (String) ((ConstantClass) constant).getConstantValue(cp);
if (exClassName.equals("java/lang/OutOfMemoryError")) {
outOfMemoryHandler = true;
break;
}
}
}
}
if (!outOfMemoryHandler) {
bugReporter.reportBug(gcInvocationBugReport);
}
}
sawCurrentTimeMillis = false;
gcInvocationBugReport = null;
exceptionTable = null;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:48,代码来源:DumbMethods.java
示例20: sawOpcode
import org.apache.bcel.classfile.CodeException; //导入依赖的package包/类
@Override
public void sawOpcode(int seen) {
// System.out.println(state + " " + getPC() + " " + OPCODE_NAMES[seen]);
if (countDown == 2 && seen == GOTO) {
CodeException tryBlock = getSurroundingTryBlock(getPC());
if (tryBlock != null && tryBlock.getEndPC() == getPC())
pendingBug.lowerPriority();
}
if (countDown > 0) {
countDown--;
if (countDown == 0) {
if (seen == MONITOREXIT)
pendingBug.lowerPriority();
bugReporter.reportBug(pendingBug);
pendingBug = null;
}
}
if (seen == PUTFIELD) {
if (syncField != null && getPrevOpcode(1) != ALOAD_0 && syncField.equals(getXFieldOperand())) {
OpcodeStack.Item value = stack.getStackItem(0);
int priority = Priorities.HIGH_PRIORITY;
if (value.isNull())
priority = Priorities.NORMAL_PRIORITY;
pendingBug = new BugInstance(this, "ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD", priority)
.addClassAndMethod(this).addField(syncField).addSourceLine(this);
countDown = 2;
}
}
if (seen == MONITOREXIT) {
pendingBug = null;
countDown = 0;
}
if (seen == MONITORENTER)
syncField = null;
switch (state) {
case 0:
if (seen == ALOAD_0)
state = 1;
break;
case 1:
if (seen == GETFIELD) {
state = 2;
field = getXFieldOperand();
} else
state = 0;
break;
case 2:
if (seen == DUP)
state = 3;
else
state = 0;
break;
case 3:
if (isRegisterStore())
state = 4;
else
state = 0;
break;
case 4:
if (seen == MONITORENTER) {
state = 0;
syncField = field;
} else
state = 0;
break;
}
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:76,代码来源:SynchronizingOnContentsOfFieldToProtectField.java
注:本文中的org.apache.bcel.classfile.CodeException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论