Esempio n. 1
0
 @Test(expected = CompilerException.class)
 public void testResolveTargetMethodSignatureGenericWithUnresolvedDirectTypeVariable()
     throws Exception {
   SootMethod target = toSootClass(F.class).getMethodByName("run");
   SootMethod m = toSootClass(Runners.class).getMethodByName("runner8");
   SootMethodType mType = new SootMethodType(m);
   ObjCBlockPlugin.resolveTargetMethodSignature(m, target, mType.getGenericParameterTypes()[0]);
 }
Esempio n. 2
0
 private Type signatureToType(String desc) {
   String rawDesc = desc.replaceAll("<.*>", "");
   String internalName = rawDesc.replaceAll("^\\[*", "");
   int dims = rawDesc.length() - internalName.length();
   internalName = Types.getInternalNameFromDescriptor(internalName);
   soot.Type sootType = SootResolver.v().makeClassRef(internalName.replace('/', '.')).getType();
   for (int i = 0; i < dims; i++) {
     sootType = sootType.makeArrayType();
   }
   SootMethod m = new SootMethod("foo", Arrays.asList(sootType), VoidType.v());
   m.addTag(new SignatureTag("(" + desc + ")V"));
   SootMethodType mType = new SootMethodType(m);
   return mType.getGenericParameterTypes()[0];
 }
Esempio n. 3
0
  private void testResolveTargetMethodSignature(
      String runnerMethodName, Type expectedReturnType, Type... expectedParamTypes) {

    SootMethod m = toSootClass(Runners.class).getMethodByName(runnerMethodName);
    SootMethodType mType = new SootMethodType(m);
    SootMethod target = ObjCBlockPlugin.getBlockTargetMethod(m, 0);
    Type[] types =
        ObjCBlockPlugin.resolveTargetMethodSignature(
            m, target, mType.getGenericParameterTypes()[0]);
    assertEquals(target.getParameterCount() + 1, types.length);
    assertEquals(expectedReturnType, types[0]);
    for (int i = 0; i < types.length - 1; i++) {
      assertEquals(expectedParamTypes[i], types[i + 1]);
    }
  }