/** * Returns a set of exceptions, which might be thrown from this instruction * within this method. * * This does include exceptions dispatched by throw instructions, but not * exceptions from method calls. * * @return a set of exceptions, which might be thrown from this instruction * within this method */ public Set<TypeReference> collectThrownExceptions(SSAInstruction throwingInstruction) { final LinkedHashSet<TypeReference> result = new LinkedHashSet<>(throwingInstruction.getExceptionTypes()); throwingInstruction.visit(new Visitor() { @Override public void visitThrow(SSAThrowInstruction instruction) { addThrown(result, instruction); } }); return result; }
/** * Returns a set of exceptions, which might be thrown from this instruction * within this method. * * This does include exceptions dispatched by throw instructions, but not * exceptions from method calls. * * @return a set of exceptions, which might be thrown from this instruction * within this method */ public Set<TypeReference> collectThrownExceptions(SSAInstruction throwingInstruction) { final LinkedHashSet<TypeReference> result = new LinkedHashSet<>(throwingInstruction.getExceptionTypes()); throwingInstruction.visit(new Visitor() { @Override public void visitThrow(SSAThrowInstruction instruction) { addThrown(result, instruction); } }); return result; }
/** * @param pei a PEI instruction * @param cha governing class hierarchy * @return a set of ConcreteTypeKeys that represent the exceptions the PEI may throw. * @throws IllegalArgumentException if pei is null */ public static InstanceKey[] getInstanceKeysForPEI(SSAInstruction pei, IClassHierarchy cha) { if (pei == null) { throw new IllegalArgumentException("pei is null"); } Collection<TypeReference> types = pei.getExceptionTypes(); // TODO: institute a cache? if (types == null) { return null; } InstanceKey[] result = new InstanceKey[types.size()]; int i = 0; for (TypeReference type : types) { assert type != null; IClass klass = cha.lookupClass(type); result[i++] = new ConcreteTypeKey(klass); } return result; }
/** * @param pei a PEI instruction * @param cha governing class hierarchy * @return a set of ConcreteTypeKeys that represent the exceptions the PEI may throw. * @throws IllegalArgumentException if pei is null */ public static InstanceKey[] getInstanceKeysForPEI(SSAInstruction pei, IClassHierarchy cha) { if (pei == null) { throw new IllegalArgumentException("pei is null"); } Collection<TypeReference> types = pei.getExceptionTypes(); // TODO: institute a cache? if (types == null) { return null; } InstanceKey[] result = new InstanceKey[types.size()]; int i = 0; for (TypeReference type : types) { assert type != null; IClass klass = cha.lookupClass(type); result[i++] = new ConcreteTypeKey(klass); } return result; }
/** * What are the exception types which s may throw? */ private static TypeReference[] computeExceptions(IClassHierarchy cha, IR ir, SSAInstruction s) throws InvalidClassFileException { Collection<TypeReference> c = null; Language l = ir.getMethod().getDeclaringClass().getClassLoader().getLanguage(); if (s instanceof SSAInvokeInstruction) { SSAInvokeInstruction call = (SSAInvokeInstruction) s; c = l.inferInvokeExceptions(call.getDeclaredTarget(), cha); } else { c = s.getExceptionTypes(); } if (c == null) { return null; } else { TypeReference[] exceptions = new TypeReference[c.size()]; Iterator<TypeReference> it = c.iterator(); for (int i = 0; i < exceptions.length; i++) { exceptions[i] = it.next(); } return exceptions; } }
/** * What are the exception types which s may throw? */ private static TypeReference[] computeExceptions(IClassHierarchy cha, IR ir, SSAInstruction s) throws InvalidClassFileException { Collection<TypeReference> c = null; Language l = ir.getMethod().getDeclaringClass().getClassLoader().getLanguage(); if (s instanceof SSAInvokeInstruction) { SSAInvokeInstruction call = (SSAInvokeInstruction) s; c = l.inferInvokeExceptions(call.getDeclaredTarget(), cha); } else { c = s.getExceptionTypes(); } if (c == null) { return null; } else { TypeReference[] exceptions = new TypeReference[c.size()]; Iterator<TypeReference> it = c.iterator(); for (int i = 0; i < exceptions.length; i++) { exceptions[i] = it.next(); } return exceptions; } }
@Override public boolean hasExceptionalEdge(Block src, Block dst) { boolean hasExceptionalEdge = this.cfg.getExceptionalSuccessors(src) .contains(dst); final SSAInstruction relevantInstruction = src.getLastInstruction(); if (hasExceptionalEdge && relevantInstruction != null) { if (weKnowAllExceptions(relevantInstruction)) { final Collection<TypeReference> thrownExceptions = relevantInstruction .getExceptionTypes(); final Collection<FilteredException> filteredExceptions = this.filter .filteredExceptions(relevantInstruction); final boolean isFiltered = ExceptionMatcher.isFiltered( thrownExceptions, filteredExceptions, this.cha); hasExceptionalEdge = !isFiltered; } } return hasExceptionalEdge; }
@Override public boolean hasExceptionalEdge(Block src, Block dst) { boolean hasExceptionalEdge = this.cfg.getExceptionalSuccessors(src) .contains(dst); final SSAInstruction relevantInstruction = src.getLastInstruction(); if (hasExceptionalEdge && relevantInstruction != null) { if (weKnowAllExceptions(relevantInstruction)) { final Collection<TypeReference> thrownExceptions = relevantInstruction .getExceptionTypes(); final Collection<FilteredException> filteredExceptions = this.filter .filteredExceptions(relevantInstruction); final boolean isFiltered = ExceptionMatcher.isFiltered( thrownExceptions, filteredExceptions, this.cha); hasExceptionalEdge = !isFiltered; } } return hasExceptionalEdge; }
public State nullPointerExceptionThrowState(SSAInstruction instruction) { assert instruction != null; if (instruction.isPEI() && instruction.getExceptionTypes().contains( TypeReference.JavaLangNullPointerException)) { final NullPointerState blockState = this.solver.getIn(this.ir .getBasicBlockForInstruction(instruction)); final RelevantVariableFinder finder = new RelevantVariableFinder( instruction); assert finder.getVarNum() >= 0; return blockState.getState(finder.getVarNum()); } return State.NOT_NULL; } }
public State nullPointerExceptionThrowState(SSAInstruction instruction) { assert instruction != null; if (instruction.isPEI() && instruction.getExceptionTypes().contains( TypeReference.JavaLangNullPointerException)) { final NullPointerState blockState = this.solver.getIn(this.ir .getBasicBlockForInstruction(instruction)); final RelevantVariableFinder finder = new RelevantVariableFinder( instruction); assert finder.getVarNum() >= 0; return blockState.getState(finder.getVarNum()); } return State.NOT_NULL; } }
lastInstruction.getExceptionTypes(); lastInstruction.getExceptionTypes(), matcher1); lastInstruction.getExceptionTypes(), matcher2);
Collection<TypeReference> types = pei.getExceptionTypes(); if (types != null) { for (TypeReference type : types) {
Collection<TypeReference> types = pei.getExceptionTypes(); if (types != null) { for (TypeReference type : types) {
Collection<TypeReference> types = pei.getExceptionTypes(); if (types != null) { for (TypeReference type : types) {
Collection<TypeReference> types = pei.getExceptionTypes(); if (types != null) { for (TypeReference type : types) {
Collection<TypeReference> types = pei.getExceptionTypes(); if (types != null) { for (TypeReference type : types) {
Collection<TypeReference> types = pei.getExceptionTypes(); if (types != null) { for (TypeReference type : types) {
Collection<TypeReference> types = pei.getExceptionTypes(); if (types != null) { for (TypeReference type : types) {
Collection<TypeReference> types = pei.getExceptionTypes(); if (types != null) { for (TypeReference type : types) {
Collection<TypeReference> types = pei.getExceptionTypes(); if (types != null) { for (TypeReference type : types) {