本文整理汇总了Java中org.jf.dexlib2.iface.ExceptionHandler.getExceptionType方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionHandler.getExceptionType方法的具体用法?Java ExceptionHandler.getExceptionType怎么用?Java ExceptionHandler.getExceptionType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jf.dexlib2.iface.ExceptionHandler
的用法示例。
在下文中一共展示了ExceptionHandler.getExceptionType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareTo
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
@Override
public int compareTo(@Nonnull ExceptionHandler o) {
int res;
String exceptionType = getExceptionType();
if (exceptionType == null) {
if (o.getExceptionType() != null) {
return 1;
}
} else {
String otherExceptionType = o.getExceptionType();
if (otherExceptionType == null) {
return -1;
}
res = exceptionType.compareTo(o.getExceptionType());
if (res != 0) return res;
}
return Ints.compare(getHandlerCodeAddress(), o.getHandlerCodeAddress());
}
示例2: addHandler
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
public void addHandler(@Nonnull EH handler) {
for (ExceptionHandler existingHandler: exceptionHandlers) {
String existingType = existingHandler.getExceptionType();
String newType = handler.getExceptionType();
if (existingType == null) {
if (newType == null) {
if (existingHandler.getHandlerCodeAddress() != handler.getHandlerCodeAddress()) {
throw new InvalidTryException(
"Multiple overlapping catch all handlers with different handlers");
}
return;
}
} else if (existingType.equals(newType)) {
// dalvik doesn't reject cases when there are multiple catches with the same exception
// but different handlers. In practice, the first handler "wins". Since the later
// handler will never be used, we don't add it.
return;
}
}
exceptionHandlers.add(handler);
}
示例3: addHandler
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
public void addHandler(@Nonnull EH handler) {
for (ExceptionHandler existingHandler: exceptionHandlers) {
String existingType = existingHandler.getExceptionType();
String newType = handler.getExceptionType();
// Don't add it if we already have a handler of the same type
if (existingType == null) {
if (newType == null) {
if (existingHandler.getHandlerCodeAddress() != handler.getHandlerCodeAddress()) {
throw new InvalidTryException(
"Multiple overlapping catch all handlers with different handlers");
}
return;
}
} else if (existingType.equals(newType)) {
if (existingHandler.getHandlerCodeAddress() != handler.getHandlerCodeAddress()) {
throw new InvalidTryException(
"Multiple overlapping catches for %s with different handlers", existingType);
}
return;
}
}
exceptionHandlers.add(handler);
}
示例4: usedTypes
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
/**
* Return the types that are used in this body.
*/
public Set<Type> usedTypes() {
Set<Type> types = new HashSet<Type>();
for (DexlibAbstractInstruction i : instructions)
types.addAll(i.introducedTypes());
if(tries!=null) {
for (TryBlock<? extends ExceptionHandler> tryItem : tries) {
List<? extends ExceptionHandler> hList = tryItem.getExceptionHandlers();
for (ExceptionHandler handler: hList) {
String exType = handler.getExceptionType();
if (exType == null) // for handler which capture all Exceptions
continue;
types.add(DexType.toSoot(exType));
}
}
}
return types;
}
示例5: compareTo
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
@Override
public int compareTo( ExceptionHandler o) {
int res;
String exceptionType = getExceptionType();
if (exceptionType == null) {
if (o.getExceptionType() != null) {
return 1;
}
} else {
String otherExceptionType = o.getExceptionType();
if (otherExceptionType == null) {
return -1;
}
res = exceptionType.compareTo(o.getExceptionType());
if (res != 0) return res;
}
return Ints.compare(getHandlerCodeAddress(), o.getHandlerCodeAddress());
}
示例6: addHandler
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
public void addHandler( EH handler) {
for (ExceptionHandler existingHandler: exceptionHandlers) {
String existingType = existingHandler.getExceptionType();
String newType = handler.getExceptionType();
if (existingType == null) {
if (newType == null) {
if (existingHandler.getHandlerCodeAddress() != handler.getHandlerCodeAddress()) {
throw new InvalidTryException(
"Multiple overlapping catch all handlers with different handlers");
}
return;
}
} else if (existingType.equals(newType)) {
// dalvik doesn't reject cases when there are multiple catches with the same exception
// but different handlers. In practice, the first handler "wins". Since the later
// handler will never be used, we don't add it.
return;
}
}
exceptionHandlers.add(handler);
}
示例7: compare
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
@Override
public int compare(ExceptionHandler o1, ExceptionHandler o2) {
String exceptionType1 = o1.getExceptionType();
if (exceptionType1 == null) {
if (o2.getExceptionType() != null) {
return 1;
}
return 0;
} else {
String exceptionType2 = o2.getExceptionType();
if (exceptionType2 == null) {
return -1;
}
return exceptionType1.compareTo(o2.getExceptionType());
}
}
示例8: of
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
public static ImmutableExceptionHandler of(ExceptionHandler exceptionHandler) {
if (exceptionHandler instanceof ImmutableExceptionHandler) {
return (ImmutableExceptionHandler)exceptionHandler;
}
return new ImmutableExceptionHandler(
exceptionHandler.getExceptionType(),
exceptionHandler.getHandlerCodeAddress());
}
示例9: compare
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
@Override public int compare(ExceptionHandler o1, ExceptionHandler o2) {
String exceptionType1 = o1.getExceptionType();
if (exceptionType1 == null) {
if (o2.getExceptionType() != null) {
return 1;
}
return 0;
} else {
String exceptionType2 = o2.getExceptionType();
if (exceptionType2 == null) {
return -1;
}
return exceptionType1.compareTo(o2.getExceptionType());
}
}
示例10: of
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
public static ImmutableExceptionHandler of(ExceptionHandler exceptionHandler) {
if (exceptionHandler instanceof ImmutableExceptionHandler) {
return (ImmutableExceptionHandler) exceptionHandler;
}
return new ImmutableExceptionHandler(
exceptionHandler.getExceptionType(),
exceptionHandler.getHandlerCodeAddress());
}
示例11: analyzeMoveException
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
private void analyzeMoveException(@Nonnull AnalyzedInstruction analyzedInstruction) {
int instructionAddress = getInstructionAddress(analyzedInstruction);
RegisterType exceptionType = RegisterType.UNKNOWN_TYPE;
for (TryBlock<? extends ExceptionHandler> tryBlock : methodImpl.getTryBlocks()) {
for (ExceptionHandler handler : tryBlock.getExceptionHandlers()) {
if (handler.getHandlerCodeAddress() == instructionAddress) {
String type = handler.getExceptionType();
if (type == null) {
exceptionType = RegisterType.getRegisterType(RegisterType.REFERENCE,
classPath.getClass("Ljava/lang/Throwable;"));
} else {
exceptionType = RegisterType.getRegisterType(RegisterType.REFERENCE, classPath.getClass(type))
.merge(exceptionType);
}
}
}
}
if (exceptionType.category == RegisterType.UNKNOWN) {
throw new AnalysisException("move-exception must be the first instruction in an exception handler block");
}
setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, exceptionType);
}
示例12: addTraps
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
/**
* Add the traps of this body.
*
* Should only be called at the end jimplify.
*/
private void addTraps() {
for (TryBlock<? extends ExceptionHandler> tryItem : tries) {
int startAddress = tryItem.getStartCodeAddress();
Debug.printDbg(" start : 0x", Integer.toHexString(startAddress));
int length = tryItem.getCodeUnitCount();//.getTryLength();
Debug.printDbg(" length: 0x", Integer.toHexString(length));
Debug.printDbg(" end : 0x", Integer.toHexString(startAddress + length));
int endAddress = startAddress + length;// - 1;
Unit beginStmt = instructionAtAddress(startAddress).getUnit();
// (startAddress + length) typically points to the first byte of the first instruction after the try block
// except if there is no instruction after the try block in which case it points to the last byte of the last
// instruction of the try block. Removing 1 from (startAddress + length) always points to "somewhere" in
// the last instruction of the try block since the smallest instruction is on two bytes (nop = 0x0000).
Unit endStmt = instructionAtAddress (endAddress).getUnit();
// if the try block ends on the last instruction of the body, add a
// nop instruction so Soot can include
// the last instruction in the try block.
if (jBody.getUnits().getLast() == endStmt
&& instructionAtAddress(endAddress - 1).getUnit() == endStmt) {
Unit nop = Jimple.v().newNopStmt();
jBody.getUnits().insertAfter(nop, endStmt);
endStmt = nop;
}
Debug.printDbg("begin instruction (0x",
Integer.toHexString(startAddress), "): ",
instructionAtAddress(startAddress).getUnit(), " --- ",
beginStmt);
Debug.printDbg("end instruction (0x",
Integer.toHexString(endAddress), "): ",
instructionAtAddress(endAddress).getUnit(), " --- ",
endStmt);
List<? extends ExceptionHandler> hList = tryItem.getExceptionHandlers();
for (ExceptionHandler handler: hList) {
int handlerAddress = handler.getHandlerCodeAddress();
Debug.printDbg("handler (0x",
Integer.toHexString(handlerAddress),
"): ",
instructionAtAddress (handlerAddress).getUnit(),
" --- ",
handlerAddress > 0 ? instructionAtAddress (handlerAddress-1).getUnit() : "<unknown>");
String exceptionType = handler.getExceptionType();
if (exceptionType == null)
exceptionType = "Ljava/lang/Throwable;";
Type t = DexType.toSoot(exceptionType);
// exceptions can only be of RefType
if (t instanceof RefType) {
SootClass exception = ((RefType) t).getSootClass();
DexlibAbstractInstruction instruction = instructionAtAddress(handler.getHandlerCodeAddress());
if (! (instruction instanceof MoveExceptionInstruction))
Debug.printDbg("First instruction of trap handler unit not MoveException but " , instruction.getClass());
else
((MoveExceptionInstruction) instruction).setRealType(this, exception.getType());
Trap trap = Jimple.v().newTrap(exception, beginStmt, endStmt, instruction.getUnit());
jBody.getTraps().add(trap);
}
}
}
}
示例13: getExceptionType
import org.jf.dexlib2.iface.ExceptionHandler; //导入方法依赖的package包/类
@Nullable
@Override
public CharSequence getExceptionType(@Nonnull ExceptionHandler handler) {
return handler.getExceptionType();
}