@Test(expected = CompilerException.class) public void testGetTargetBlockMethodNoMethods() throws Exception { ObjCBlockPlugin.getBlockTargetMethod(toSootClass(Runners.class).getMethodByName("runner12"), 0); }
protected static SootMethod getBlockTargetMethod(SootMethod method, int paramIndex) { soot.Type type = method.getParameterType(paramIndex); if (!(type instanceof RefType)) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } SootClass blockType = ((RefType) type).getSootClass(); if (!blockType.isInterface()) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } List<SootMethod> allMethods = collectAbstractMethods(blockType); if (allMethods.isEmpty()) { throw new CompilerException("No abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } if (allMethods.size() > 1) { throw new CompilerException("More than 1 abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } return allMethods.get(0); }
ObjCBlockPlugin extends AbstractCompilerPlugin { protected static SootMethod getBlockTargetMethod(SootMethod method, int paramIndex) { soot.Type type = method.getParameterType(paramIndex); if (!(type instanceof RefType)) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } SootClass blockType = ((RefType) type).getSootClass(); if (!blockType.isInterface()) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } List<SootMethod> allMethods = collectAbstractMethods(blockType); if (allMethods.isEmpty()) { throw new CompilerException("No abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } if (allMethods.size() > 1) { throw new CompilerException("More than 1 abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } return allMethods.get(0); } }
ObjCBlockPlugin extends AbstractCompilerPlugin { protected static SootMethod getBlockTargetMethod(SootMethod method, int paramIndex) { soot.Type type = method.getParameterType(paramIndex); if (!(type instanceof RefType)) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } SootClass blockType = ((RefType) type).getSootClass(); if (!blockType.isInterface()) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } List<SootMethod> allMethods = collectAbstractMethods(blockType); if (allMethods.isEmpty()) { throw new CompilerException("No abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } if (allMethods.size() > 1) { throw new CompilerException("More than 1 abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } return allMethods.get(0); }  }
ObjCBlockPlugin extends AbstractCompilerPlugin { protected static SootMethod getBlockTargetMethod(SootMethod method, int paramIndex) { soot.Type type = method.getParameterType(paramIndex); if (!(type instanceof RefType)) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } SootClass blockType = ((RefType) type).getSootClass(); if (!blockType.isInterface()) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } List<SootMethod> allMethods = collectAbstractMethods(blockType); if (allMethods.isEmpty()) { throw new CompilerException("No abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } if (allMethods.size() > 1) { throw new CompilerException("More than 1 abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } return allMethods.get(0); }  @Override void beforeClass(Config config, Clazz clazz, ModuleBuilder moduleBuilder); }
ObjCBlockPlugin extends AbstractCompilerPlugin { protected static SootMethod getBlockTargetMethod(SootMethod method, int paramIndex) { soot.Type type = method.getParameterType(paramIndex); if (!(type instanceof RefType)) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } SootClass blockType = ((RefType) type).getSootClass(); if (!blockType.isInterface()) { throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type"); } List<SootMethod> allMethods = collectAbstractMethods(blockType); if (allMethods.isEmpty()) { throw new CompilerException("No abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } if (allMethods.size() > 1) { throw new CompilerException("More than 1 abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method); } return allMethods.get(0); }  @Override void beforeClass(Config config, Clazz clazz, ModuleBuilder moduleBuilder); static final String OBJC_PACKAGE; static final String OBJC_ANNOTATIONS_PACKAGE; static final String BLOCK; static final String RUNNABLE_AS_OBJC_BLOCK_MARSHALER; }