/** * If exception e is caught at stmt s in body b, return the handler; otherwise, return null. */ static boolean isExceptionCaughtAt(SootClass e, Stmt stmt, Body b) { /* * Look through the traps t of b, checking to see if: - caught exception is e; - and, stmt lies between t.beginUnit and * t.endUnit */ Hierarchy h = new Hierarchy(); Iterator<Trap> trapsIt = b.getTraps().iterator(); while (trapsIt.hasNext()) { Trap t = trapsIt.next(); /* Ah ha, we might win. */ if (h.isClassSubclassOfIncluding(e, t.getException())) { Iterator<Unit> it = b.getUnits().iterator(t.getBeginUnit(), t.getEndUnit()); while (it.hasNext()) { if (stmt.equals(it.next())) { return true; } } } } return false; } }
/** * If exception e is caught at unit u in body b, return true; otherwise, return false. */ public static boolean isExceptionCaughtAt(SootClass e, Unit u, Body b) { /* * Look through the traps t of b, checking to see if: - caught exception is e; - and, unit lies between t.beginUnit and * t.endUnit */ Hierarchy h = Scene.v().getActiveHierarchy(); Chain<Unit> units = b.getUnits(); for (Trap t : b.getTraps()) { /* Ah ha, we might win. */ if (h.isClassSubclassOfIncluding(e, t.getException())) { Iterator<Unit> it = units.iterator(t.getBeginUnit(), units.getPredOf(t.getEndUnit())); while (it.hasNext()) { if (u.equals(it.next())) { return true; } } } } return false; }
public boolean isExceptionPointer(Node v) { if (v.getType() instanceof RefType) { SootClass sc = ((RefType) v.getType()).getSootClass(); if (!sc.isInterface() && Scene.v().getActiveHierarchy().isClassSubclassOfIncluding(sc, Constants.exeception_type.getSootClass())) { return true; } } return false; }
/** * Returns true if the classmember m is visible from code in the class from. */ public boolean isVisible(SootClass from, ClassMember m) { from.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); if (!isVisible(from, m.getDeclaringClass())) { return false; } if (m.isPublic()) { return true; } if (m.isPrivate()) { return from.equals(m.getDeclaringClass()); } if (m.isProtected()) { return isClassSubclassOfIncluding(from, m.getDeclaringClass()) || from.getJavaPackageName().equals(m.getDeclaringClass().getJavaPackageName()); } // m is package return from.getJavaPackageName().equals(m.getDeclaringClass().getJavaPackageName()); }
+ errorSuffix + " in " + body.getMethod())); } else { if (!Scene.v().getActiveHierarchy().isClassSubclassOfIncluding(rightClass, leftClass)) { exception.add( new ValidationException(stmt, "Warning: Bad use of class type" + errorSuffix + " in " + body.getMethod()));
if (baseLocal.getType() instanceof RefType) { SootClass baseClass = ((RefType) baseLocal.getType()).getSootClass(); if (Scene.v().getActiveHierarchy().isClassSubclassOfIncluding(baseClass, RefType.v("java.lang.Exception").getSootClass())) { return null;
/** * Takes a list of SootClasses and adds the RuntimeException class * if the list does not contain RuntimeException or any or its * supertypes. * * @param classes */ private void addRuntimExceptionIfNecessary(List<SootClass> classes) { boolean containRteOrAbove = false; for (SootClass c : classes) { if (hierarchy.isClassSubclassOfIncluding(c, runtimeExceptionClass)) { containRteOrAbove = true; break; } } if (!containRteOrAbove) { classes.add(runtimeExceptionClass); } }
Preconditions.checkArgument(hierarchy.isClassSubclassOfIncluding(t.getException(), throwableClass), "Unexpected type " + t.getException().getJavaStyleName());
private Set<Trap> handleRuntimeException() { Set<Trap> usedTraps = new HashSet<Trap>(); // handle the runtime exceptions first. for (Entry<Unit, List<Pair<Value, SootClass>>> entry : runtimeExceptions.entrySet()) { Unit u = entry.getKey(); List<Trap> surroundingTraps = getTrapsGuardingUnit(u, body); for (Pair<Value, SootClass> pair : entry.getValue()) { Trap trap = null; for (Trap t : surroundingTraps) { if (hierarchy.isClassSubclassOfIncluding(pair.getSecond(), t.getException())) { trap = t; break; } } if (trap != null) { handleCaughtRuntimeException(u, pair.getFirst(), pair.getSecond(), trap); usedTraps.add(trap); } else { // re-throw the exception handleUncaughtRuntimeException(u, pair.getFirst(), pair.getSecond()); } } } return usedTraps; }
/** If exception e is caught at unit u in body b, return true; * otherwise, return false. */ public static boolean isExceptionCaughtAt(SootClass e, Unit u, Body b) { /* Look through the traps t of b, checking to see if: * - caught exception is e; * - and, unit lies between t.beginUnit and t.endUnit */ Hierarchy h = Scene.v().getActiveHierarchy(); Chain units = b.getUnits(); Iterator trapsIt = b.getTraps().iterator(); while (trapsIt.hasNext()) { Trap t = (Trap)trapsIt.next(); /* Ah ha, we might win. */ if (h.isClassSubclassOfIncluding(e, t.getException())) { Iterator it = units.iterator(t.getBeginUnit(), units.getPredOf(t.getEndUnit())); while (it.hasNext()) if (u.equals(it.next())) return true; } } return false; }
/** If exception e is caught at unit u in body b, return true; * otherwise, return false. */ public static boolean isExceptionCaughtAt(SootClass e, Unit u, Body b) { /* Look through the traps t of b, checking to see if: * - caught exception is e; * - and, unit lies between t.beginUnit and t.endUnit */ Hierarchy h = Scene.v().getActiveHierarchy(); Chain units = b.getUnits(); Iterator trapsIt = b.getTraps().iterator(); while (trapsIt.hasNext()) { Trap t = (Trap)trapsIt.next(); /* Ah ha, we might win. */ if (h.isClassSubclassOfIncluding(e, t.getException())) { Iterator it = units.iterator(t.getBeginUnit(), units.getPredOf(t.getEndUnit())); while (it.hasNext()) if (u.equals(it.next())) return true; } } return false; }
/** Returns true if the method m is visible from code in the class from. */ public boolean isVisible( SootClass from, SootMethod m ) { from.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); if( m.isPublic() ) return true; if( m.isPrivate() ) { return from.equals( m.getDeclaringClass() ); } if( m.isProtected() ) { return isClassSubclassOfIncluding( from, m.getDeclaringClass() ); } // m is package return from.getJavaPackageName().equals( m.getDeclaringClass().getJavaPackageName() ); //|| isClassSubclassOfIncluding( from, m.getDeclaringClass() ); }
/** Returns true if the method m is visible from code in the class from. */ public boolean isVisible( SootClass from, SootMethod m ) { from.checkLevel(SootClass.HIERARCHY); m.getDeclaringClass().checkLevel(SootClass.HIERARCHY); if( m.isPublic() ) return true; if( m.isPrivate() ) { return from.equals( m.getDeclaringClass() ); } if( m.isProtected() ) { return isClassSubclassOfIncluding( from, m.getDeclaringClass() ); } // m is package return from.getJavaPackageName().equals( m.getDeclaringClass().getJavaPackageName() ); //|| isClassSubclassOfIncluding( from, m.getDeclaringClass() ); }
for (Trap t : surroundingTraps) { if (hierarchy.isClassSubclassOfIncluding(t.getException(), thrownException) || hierarchy.isClassSubclassOfIncluding(thrownException, t.getException())) { if (!possibleExceptions.contains(t.getException())) { possibleExceptions.add(t.getException()); if (hierarchy.isClassSubclassOfIncluding(exception, t.getException())) { trap = t; break;
+errorSuffix+" in "+getMethod()); } else { if(!Scene.v().getActiveHierarchy().isClassSubclassOfIncluding(rightClass,leftClass)) throw new RuntimeException("Warning: Bad use of class type"+errorSuffix+" in "+getMethod());
+errorSuffix+" in "+getMethod()); } else { if(!Scene.v().getActiveHierarchy().isClassSubclassOfIncluding(rightClass,leftClass)) throw new RuntimeException("Warning: Bad use of class type"+errorSuffix+" in "+getMethod());
Value left = ds.getLeftOp(); Value right = caughtExceptionLocal.get(t.getHandlerUnit()); if (!hierarchy.isClassSubclassOfIncluding(((RefType) right.getType()).getSootClass(), ((RefType) left.getType()).getSootClass())) {
if (hierarchy.isClassSubclassOfIncluding(t.getException(), runtimeExceptionClass) || hierarchy.isClassSubclassOfIncluding(t.getException(), errorExceptionClass)) { if (!possibleExceptions.contains(t.getException())) { possibleExceptions.add(t.getException()); if (hierarchy.isClassSubclassOfIncluding(exceptionClass, t.getException())) { if (!possibleExceptions.contains(t.getException())) { possibleExceptions.add(t.getException()); if (hierarchy.isClassSubclassOfIncluding(t.getException(), sc)) { if (!possibleExceptions.contains(t.getException())) { possibleExceptions.add(t.getException()); if (hierarchy.isClassSubclassOfIncluding(exception, t.getException())) { trap = t; break;
.isClassSubclassOfIncluding(Scene.v().getSootClass(baseType), superclass)) { return methodDescription.getArguments(); } else {