• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ThrowStmt类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中soot.jimple.ThrowStmt的典型用法代码示例。如果您正苦于以下问题:Java ThrowStmt类的具体用法?Java ThrowStmt怎么用?Java ThrowStmt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ThrowStmt类属于soot.jimple包,在下文中一共展示了ThrowStmt类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: internalTransform

import soot.jimple.ThrowStmt; //导入依赖的package包/类
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
	LocalCreation lc = new LocalCreation(b.getLocals(), "ex");
	
	for (Iterator<Unit> unitIt = b.getUnits().snapshotIterator(); unitIt.hasNext(); ) {
		Unit u = unitIt.next();
		
		// Check for a null exception
		if (u instanceof ThrowStmt) {
			ThrowStmt throwStmt = (ThrowStmt) u;
			if (throwStmt.getOp() == NullConstant.v()
					|| throwStmt.getOp().equals(IntConstant.v(0))
					|| throwStmt.getOp().equals(LongConstant.v(0))) {
				createThrowStmt(b, throwStmt, lc);
			}
		}
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:19,代码来源:DexNullThrowTransformer.java


示例2: propagateNormalFlow

import soot.jimple.ThrowStmt; //导入依赖的package包/类
@Override
public KillGenInfo propagateNormalFlow(Trackable trackable, Unit curr, Unit succ) {
	if (curr instanceof ReturnStmt) {
		Value retValue = getBase(((ReturnStmt) curr).getOp());
		if (retValue instanceof Constant) {
			return kill();
		} else {
			ReturnValueTaint retValTaint = (ReturnValueTaint) trackable;
			if (AnalysisUtil.isAssignable(retValTaint.type, retValue.getType()))
				return propagate(new Taint(curr, trackable, retValue, retValTaint.type));
			else
				return kill();
		}
	} else if (curr instanceof ThrowStmt)
		return kill();

	throw new IllegalStateException();
}
 
开发者ID:johanneslerch,项目名称:FlowTwist,代码行数:19,代码来源:ReturnValuePropagator.java


示例3: methodIsAndroidStub

import soot.jimple.ThrowStmt; //导入依赖的package包/类
/**
 * Checks whether the given method is a library stub method
 * @param method The method to check
 * @return True if the given method is an Android library stub, false
 * otherwise
 */
private boolean methodIsAndroidStub(SootMethod method) {		
	if (!(Options.v().src_prec() == Options.src_prec_apk
			&& method.getDeclaringClass().isLibraryClass()
			&& SystemClassHandler.isClassInSystemPackage(
					method.getDeclaringClass().getName())))
		return false;
	
	// Check whether there is only a single throw statement
	for (Unit u : method.getActiveBody().getUnits()) {
		if (u instanceof DefinitionStmt) {
			DefinitionStmt defStmt = (DefinitionStmt) u;
			if (!(defStmt.getRightOp() instanceof ThisRef)
					&& !(defStmt.getRightOp() instanceof ParameterRef)
					&& !(defStmt.getRightOp() instanceof NewExpr))
				return false;
		}
		else if (u instanceof InvokeStmt) {
			InvokeStmt stmt = (InvokeStmt) u;
			
			// Check for exception constructor invocations
			SootMethod callee = stmt.getInvokeExpr().getMethod();
			if (!callee.getSubSignature().equals("void <init>(java.lang.String)"))
				// Check for super class constructor invocation
				if (!(method.getDeclaringClass().hasSuperclass()
						&& callee.getDeclaringClass() == method.getDeclaringClass().getSuperclass()
						&& callee.getName().equals("<init>")))
					return false;
		}
		else if (!(u instanceof ThrowStmt))
			return false;
	}
	return true;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:40,代码来源:InterproceduralConstantValuePropagator.java


示例4: caseThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
public void caseThrowStmt(ThrowStmt stmt) {
	if (uses) {
		if (stmt.getOp() instanceof Local) {
			TypeVariable op = resolver.typeVariable((Local) stmt.getOp());

			op.addParent(resolver.typeVariable(RefType.v("java.lang.Throwable")));
		}
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:10,代码来源:ConstraintCollector.java


示例5: caseThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
@Override
public void caseThrowStmt(ThrowStmt stmt) {
	Value exception = stmt.getOp();
       constantV.setOrigStmt(stmt);
	Register exceptionReg = regAlloc.asImmediate(exception, constantV);
       addInsn(new Insn11x(Opcode.THROW, exceptionReg), stmt);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:8,代码来源:StmtVisitor.java


示例6: buildHeadsAndTails

import soot.jimple.ThrowStmt; //导入依赖的package包/类
/**
 * Utility method, to be called only after the unitToPreds and unitToSuccs
 * maps have been built. It defines the graph's set of heads to include the
 * first {@link Unit} in the graph's body, together with all the
 * <code>Unit</code>s in <code>additionalHeads</code>. It defines the
 * graph's set of tails to include all <code>Unit</code>s which represent
 * some sort of return bytecode or an <code>athrow</code> bytecode which may
 * escape the method.
 */
private void buildHeadsAndTails(Set<Unit> additionalHeads) {
	List<Unit> headList = new ArrayList<Unit>(additionalHeads.size() + 1);
	headList.addAll(additionalHeads);

	if (unitChain.isEmpty())
		throw new IllegalStateException("No body for method "
				+ body.getMethod().getSignature());

	Unit entryPoint = unitChain.getFirst();
	if (!headList.contains(entryPoint)) {
		headList.add(entryPoint);
	}

	List<Unit> tailList = new ArrayList<Unit>();
	for (Unit u : unitChain) {
		if (u instanceof soot.jimple.ReturnStmt
				|| u instanceof soot.jimple.ReturnVoidStmt
				|| u instanceof soot.baf.ReturnInst
				|| u instanceof soot.baf.ReturnVoidInst) {
			tailList.add(u);
		} else if (u instanceof soot.jimple.ThrowStmt
				|| u instanceof soot.baf.ThrowInst) {
			Collection<ExceptionDest> dests = getExceptionDests(u);
			int escapeMethodCount = 0;
			for (ExceptionDest dest : dests) {
				if (dest.getTrap() == null) {
					escapeMethodCount++;
				}
			}
			if (escapeMethodCount > 0) {
				tailList.add(u);
			}
		}
	}
	tails = Collections.unmodifiableList(tailList);
	heads = Collections.unmodifiableList(headList);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:47,代码来源:ExceptionalUnitGraph.java


示例7: testJThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
@Test
public void testJThrowStmt() {

    // First test with an argument that is included in
    // PERENNIAL_THROW_EXCEPTIONS.
    ThrowStmt s = Jimple.v().newThrowStmt(Jimple.v().newLocal("local0", 
                RefType.v("java.lang.NullPointerException")));
    Set expectedRep = new ExceptionHashSet(utility.PERENNIAL_THROW_EXCEPTIONS);
    expectedRep.remove(utility.NULL_POINTER_EXCEPTION);
    expectedRep.add(AnySubType.v(utility.NULL_POINTER_EXCEPTION));
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET,
                unitAnalysis.mightThrow(s)));
    assertEquals(utility.PERENNIAL_THROW_EXCEPTIONS_PLUS_SUPERTYPES,
            utility.catchableSubset(unitAnalysis.mightThrow(s)));

    // Throw a local of type IncompatibleClassChangeError.
    Local local = Jimple.v().newLocal("local1", 
            utility.INCOMPATIBLE_CLASS_CHANGE_ERROR);
    s.setOp(local);
    expectedRep = new ExceptionHashSet(utility.THROW_PLUS_INCOMPATIBLE_CLASS_CHANGE);
    expectedRep.remove(utility.INCOMPATIBLE_CLASS_CHANGE_ERROR);
    expectedRep.add(AnySubType.v(utility.INCOMPATIBLE_CLASS_CHANGE_ERROR));
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET,
                unitAnalysis.mightThrow(s)));
    assertEquals(utility.THROW_PLUS_INCOMPATIBLE_CLASS_CHANGE_PLUS_SUBTYPES_PLUS_SUPERTYPES, 
            utility.catchableSubset(unitAnalysis.mightThrow(s)));

    // Throw a local of unknown type.
    local = Jimple.v().newLocal("local1", soot.UnknownType.v());
    s.setOp(local);
    assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_THROWABLES_REP, 
                Collections.EMPTY_SET,
                unitAnalysis.mightThrow(s)));
    assertEquals(utility.ALL_TEST_THROWABLES, 
            utility.catchableSubset(unitAnalysis.mightThrow(s)));
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:37,代码来源:UnitThrowAnalysisTest.java


示例8: findExceptionType

import soot.jimple.ThrowStmt; //导入依赖的package包/类
private SootClass findExceptionType(ThrowStmt s) {
		if (s.getOp() instanceof NewExpr) {
			NewExpr ne = (NewExpr) s.getOp();
			return ne.getBaseType().getSootClass();
		} else if (s.getOp() instanceof Local) {
			Local l = (Local) s.getOp();
			if (l.getType() instanceof RefType) {
				return ((RefType) l.getType()).getSootClass();
			}
		}
//		System.err.println("Unexpected value in throw stmt " + s.getOp());
		return Scene.v().loadClass("java.lang.Throwable", SootClass.SIGNATURES);
	}
 
开发者ID:SRI-CSL,项目名称:bixie,代码行数:14,代码来源:SootStmtSwitch.java


示例9: caseThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
@Override
public void caseThrowStmt(ThrowStmt arg0) {
	injectLabelStatements(arg0);

	// find the type of the exception that is thrown.
	SootClass c = findExceptionType(arg0);

	arg0.getOp().apply(this.valueswitch);
	Expression right = this.valueswitch.getExpression();
	// assign the value from arg0.getOp() to the $exception variable of
	// the current procedure.
	// Note that this only works because soot moves the "new" statement
	// to a new local variable.
	AssignmentTranslation.translateAssignment(this,
			this.procInfo.getExceptionVariable(), right);
	// Add a goto statement to the exceptional successors.
	List<Trap> traps = new LinkedList<Trap>();
	List<Trap> finally_traps = new LinkedList<Trap>(); // TODO: do we have
	TranslationHelpers.getReachableTraps(arg0,
			this.procInfo.getSootMethod(), traps, finally_traps);
	// TODO, maybe we need to consider the case that
	// we don't know the exact type of arg0.getOp at this point?
	for (Trap trap : traps) {
		if (GlobalsCache.v().isSubTypeOrEqual(c, trap.getException())) {
			this.boogieStatements.add(this.pf.mkGotoStatement(GlobalsCache
					.v().getUnitLabel((Stmt) trap.getHandlerUnit())));
			return;
		}
	}
	this.boogieStatements.add(this.pf.mkReturnStatement());

}
 
开发者ID:SRI-CSL,项目名称:bixie,代码行数:33,代码来源:SootStmtSwitch.java


示例10: isBranch

import soot.jimple.ThrowStmt; //导入依赖的package包/类
public static boolean isBranch(Unit u){
    if(u instanceof IfStmt ||
            u instanceof GotoStmt ||
            u instanceof SwitchStmt ||
            u instanceof ThrowStmt ||
            u instanceof ReturnStmt ||
            u instanceof ReturnVoidStmt)
        return true;
    return false;
}
 
开发者ID:petablox-project,项目名称:petablox,代码行数:11,代码来源:SootUtilities.java


示例11: findExceptionType

import soot.jimple.ThrowStmt; //导入依赖的package包/类
private SootClass findExceptionType(ThrowStmt s) {
	if (s.getOp() instanceof NewExpr) {
		NewExpr ne = (NewExpr) s.getOp();
		return ne.getBaseType().getSootClass();
	} else if (s.getOp() instanceof Local) {
		Local l = (Local) s.getOp();
		if (l.getType() instanceof RefType) {
			return ((RefType) l.getType()).getSootClass();
		}
	}
	System.err.println("Unexpected value in throw stmt " + s.getOp());
	return Scene.v().loadClass("java.lang.Throwable", SootClass.SIGNATURES);
}
 
开发者ID:martinschaef,项目名称:jar2bpl,代码行数:14,代码来源:SootStmtSwitch.java


示例12: caseThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
@Override
public void caseThrowStmt(ThrowStmt stmt) {
	throw new RuntimeException("todo");
	
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:6,代码来源:JimpleStmtVisitorImpl.java


示例13: fixExceptions

import soot.jimple.ThrowStmt; //导入依赖的package包/类
private void fixExceptions(SootMethod caller, Unit callSite, Set<SootClass> doneSet) {
	ThrowAnalysis ta = Options.v().src_prec() == Options.src_prec_apk
			? DalvikThrowAnalysis.v() : UnitThrowAnalysis.v();
	ThrowableSet throwSet = ta.mightThrow(callSite);
	
	for (final Trap t : caller.getActiveBody().getTraps())
		if (doneSet.add(t.getException())
				&& throwSet.catchableAs(t.getException().getType())) {
			SootMethod thrower = exceptionThrowers.get(t.getException());
			if (thrower == null) {
				if (exceptionClass == null) {
					exceptionClass = new SootClass("FLOWDROID_EXCEPTIONS", Modifier.PUBLIC);
					Scene.v().addClass(exceptionClass);
				}
				
				// Create the new method
				thrower = new SootMethod("throw" + exceptionThrowers.size(),
						Collections.<Type>emptyList(), VoidType.v());
				thrower.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
				
				final Body body = Jimple.v().newBody(thrower);
				thrower.setActiveBody(body);
				final SootMethod meth = thrower;
				
				IEntryPointCreator epc = new BaseEntryPointCreator() {
	
					@Override
					public Collection<String> getRequiredClasses() {
						return Collections.emptySet();
					}
	
					@Override
					protected SootMethod createDummyMainInternal(SootMethod emptySootMethod) {
				 		LocalGenerator generator = new LocalGenerator(body);
						
				 		// Create the counter used for the opaque predicate
						int conditionCounter = 0;
						Value intCounter = generator.generateLocal(IntType.v());
						AssignStmt assignStmt = new JAssignStmt(intCounter, IntConstant.v(conditionCounter));
						body.getUnits().add(assignStmt);
						
						Stmt afterEx = Jimple.v().newNopStmt();
						IfStmt ifStmt = Jimple.v().newIfStmt(Jimple.v().newEqExpr(intCounter,
								IntConstant.v(conditionCounter)), afterEx);
						body.getUnits().add(ifStmt);
						conditionCounter++;
						
						Local lcEx = generator.generateLocal(t.getException().getType());
						AssignStmt assignNewEx = Jimple.v().newAssignStmt(lcEx,
								Jimple.v().newNewExpr(t.getException().getType()));
						body.getUnits().add(assignNewEx);

						InvokeStmt consNewEx = Jimple.v().newInvokeStmt(Jimple.v().newVirtualInvokeExpr(lcEx,
								Scene.v().makeConstructorRef(exceptionClass, Collections.<Type>emptyList())));
						body.getUnits().add(consNewEx);
						
						ThrowStmt throwNewEx = Jimple.v().newThrowStmt(lcEx);
						body.getUnits().add(throwNewEx);
						
						body.getUnits().add(afterEx);
						return meth;
					}
									
				};
				epc.createDummyMain(thrower);
				exceptionThrowers.put(t.getException(), thrower);
				exceptionClass.addMethod(thrower);
			}
			
			// Call the exception thrower after the old call site
			Stmt throwCall = Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(thrower.makeRef()));
			caller.getActiveBody().getUnits().insertBefore(throwCall, callSite);
		}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:75,代码来源:InterproceduralConstantValuePropagator.java


示例14: caseThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
public void caseThrowStmt(ThrowStmt stmt) {
	String varName = printValueAssignment(stmt.getOp(),"op");
	printStmt(stmt, varName);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:5,代码来源:StmtTemplatePrinter.java


示例15: caseThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
public void caseThrowStmt(ThrowStmt stmt)
{
	stmt.setOp(this.uv.visit(
		stmt.getOp(), RefType.v("java.lang.Throwable"), stmt));
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:6,代码来源:UseChecker.java


示例16: caseThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
public void caseThrowStmt(ThrowStmt stmt) {
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:3,代码来源:ConstraintChecker.java


示例17: mightThrowImplicitly

import soot.jimple.ThrowStmt; //导入依赖的package包/类
public ThrowableSet mightThrowImplicitly(ThrowStmt t) {
return implicitThrowExceptions;
   }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:4,代码来源:UnitThrowAnalysis.java


示例18: caseThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
@Override
public void caseThrowStmt(ThrowStmt s) {
    result = mightThrowImplicitly(s);
    result = result.add(mightThrowExplicitly(s));
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:6,代码来源:UnitThrowAnalysis.java


示例19: testGThrowStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
@Test
public void testGThrowStmt() {
    ThrowStmt s = Grimp.v().newThrowStmt(Grimp.v().newLocal("local0", 
                RefType.v("java.util.zip.ZipException")));

    Set expectedRep = new ExceptionHashSet(utility.PERENNIAL_THROW_EXCEPTIONS);
    expectedRep.add(AnySubType.v(Scene.v().getRefType("java.util.zip.ZipException")));
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET,
                unitAnalysis.mightThrow(s)));

    Set expectedCatch = new ExceptionHashSet(utility.PERENNIAL_THROW_EXCEPTIONS_PLUS_SUPERTYPES);
    // We don't need to add java.util.zip.ZipException, since it is not
    // in the universe of test Throwables.
    assertEquals(expectedCatch, 
            utility.catchableSubset(unitAnalysis.mightThrow(s)));

    // Now throw a new IncompatibleClassChangeError.
    s = Grimp.v().newThrowStmt(
            Grimp.v().newNewInvokeExpr(
                utility.INCOMPATIBLE_CLASS_CHANGE_ERROR,
                Scene.v().makeMethodRef(utility.INCOMPATIBLE_CLASS_CHANGE_ERROR.getSootClass(),
                    "void <init>", Collections.EMPTY_LIST, 
                    VoidType.v(), false),
                new ArrayList()
                )
            );
    assertTrue(ExceptionTestUtility.sameMembers(utility.THROW_PLUS_INCOMPATIBLE_CLASS_CHANGE, 
                Collections.EMPTY_SET,
                unitAnalysis.mightThrow(s)));
    assertEquals(utility.THROW_PLUS_INCOMPATIBLE_CLASS_CHANGE_PLUS_SUPERTYPES, 
            utility.catchableSubset(unitAnalysis.mightThrow(s)));

    // Throw a local of type IncompatibleClassChangeError.
    Local local = Grimp.v().newLocal("local1", 
            utility.INCOMPATIBLE_CLASS_CHANGE_ERROR);
    s.setOp(local);
    expectedRep = new ExceptionHashSet(utility.PERENNIAL_THROW_EXCEPTIONS);
    expectedRep.remove(utility.INCOMPATIBLE_CLASS_CHANGE_ERROR);
    expectedRep.add(AnySubType.v(utility.INCOMPATIBLE_CLASS_CHANGE_ERROR));
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET,
                unitAnalysis.mightThrow(s)));
    assertEquals(utility.THROW_PLUS_INCOMPATIBLE_CLASS_CHANGE_PLUS_SUBTYPES_PLUS_SUPERTYPES, 
            utility.catchableSubset(unitAnalysis.mightThrow(s)));

    // Throw a local of unknown type.
    local = Jimple.v().newLocal("local1", soot.UnknownType.v());
    s.setOp(local);
    assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_THROWABLES_REP, 
                Collections.EMPTY_SET,
                unitAnalysis.mightThrow(s)));
    assertEquals(utility.ALL_TEST_THROWABLES, 
            utility.catchableSubset(unitAnalysis.mightThrow(s)));
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:54,代码来源:UnitThrowAnalysisTest.java


示例20: isJumpStmt

import soot.jimple.ThrowStmt; //导入依赖的package包/类
private boolean isJumpStmt(Stmt st) {
	return ( st instanceof ThrowStmt || st instanceof GotoStmt || st instanceof ReturnStmt);	
}
 
开发者ID:SRI-CSL,项目名称:bixie,代码行数:4,代码来源:SootBodyTransformer.java



注:本文中的soot.jimple.ThrowStmt类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PathExistsException类代码示例发布时间:2022-05-22
下一篇:
Java DexBackedFieldReference类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap