/** * Get astubx style method signature. {FullyQualifiedEnclosingType}: {UnqualifiedMethodReturnType} * {methodName} ([{UnqualifiedArgumentType}*]) * * @param mtd Method reference. * @return String Method signature. */ // TODO: handle generics and inner classes private static String getSignature(IMethod mtd) { String classType = mtd.getDeclaringClass().getName().toString().replaceAll("/", "\\.").substring(1); classType = classType.replaceAll("\\$", "\\."); // handle inner class String returnType = mtd.isInit() ? null : getSimpleTypeName(mtd.getReturnType()); String strArgTypes = ""; int argi = mtd.isStatic() ? 0 : 1; // Skip 'this' parameter for (; argi < mtd.getNumberOfParameters(); argi++) { strArgTypes += getSimpleTypeName(mtd.getParameterType(argi)); if (argi < mtd.getNumberOfParameters() - 1) strArgTypes += ", "; } return classType + ":" + (returnType == null ? "void " : returnType + " ") + mtd.getName().toString() + "(" + strArgTypes + ")"; } /**
&& !mtd.isNative() && !isAllPrimitiveTypes(mtd) && !mtd.getDeclaringClass() .getClassLoader() .getName()
/** * @param method the method to be called for this entrypoint */ protected Entrypoint(IMethod method) { if (method == null) { throw new IllegalArgumentException("method is null"); } this.method = method; assert method.getDeclaringClass() != null : "null declaring class"; }
private static IMethod getPublicDefaultCtor(IClass klass) { IMethod ctorMethod = klass.getMethod(defCtorSelector); if (ctorMethod != null && ctorMethod.isPublic() && ctorMethod.getDeclaringClass() == klass) { return ctorMethod; } return null; }
/** * subclasses may wish to override! */ @Override protected CGNode makeFakeWorldClinitNode() throws CancelException { return findOrCreateNode(new FakeWorldClinitMethod(fakeRootMethod.getDeclaringClass(), options, cache), Everywhere.EVERYWHERE); }
private static IMethod getCallTargetMethod(IMethod method) { if(method.getName().equals(JavaScriptMethods.ctorAtom)) { method = method.getDeclaringClass().getMethod(AstMethodReference.fnSelector); if(method != null) return method; } return method; }
/** * If the function is defined in a class that extends an Activity. */ public boolean isActivity() { IClassHierarchy cha = getClassHierarchy(); final TypeReference activity = AndroidTypes.Activity; return cha.isSubclassOf(method.getDeclaringClass(), cha.lookupClass(activity)); }
protected TypeInference(IR ir, boolean doPrimitives) { if (ir == null) { throw new IllegalArgumentException("ir is null"); } this.language = ir.getMethod().getDeclaringClass().getClassLoader().getLanguage(); this.cha = ir.getMethod().getDeclaringClass().getClassHierarchy(); this.ir = ir; this.doPrimitives = doPrimitives; this.BOTTOM = new ConeType(cha.getRootClass()); initialize(); solve(); }
protected ModVisitor<T, ? extends ExtendedHeapModel> makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) { return n.getMethod().getDeclaringClass().getClassLoader().getLanguage().makeModVisitor(n, result, pa, h, ignoreAllocHeapDefs); //return new ModVisitor<>(n, result, h, pa, ignoreAllocHeapDefs); }
/** * Generate a {@link MethodSummary} which is the "standard" representation of a method * that does nothing. Subclasses may override this method to implement alternative semantics * concerning what "do nothing" means. */ public MethodSummary generateNoOp(MethodReference m, boolean isStatic) { Language l = cha.resolveMethod(m).getDeclaringClass().getClassLoader().getLanguage(); return new NoOpSummary(l, m, isStatic); }
/** * Generate a {@link MethodSummary} which is the "standard" representation of a method * that does nothing. Subclasses may override this method to implement alternative semantics * concerning what "do nothing" means. */ public MethodSummary generateNoOp(MethodReference m, boolean isStatic) { Language l = cha.resolveMethod(m).getDeclaringClass().getClassLoader().getLanguage(); return new NoOpSummary(l, m, isStatic); }
private boolean isRelevantMethod(IMethod target) { return !target.isAbstract() && (!applicationOnly || cha.getScope().isApplicationLoader(target.getDeclaringClass().getClassLoader())); }
protected ModVisitor<T, ? extends ExtendedHeapModel> makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) { return n.getMethod().getDeclaringClass().getClassLoader().getLanguage().makeModVisitor(n, result, pa, h, ignoreAllocHeapDefs); //return new ModVisitor<>(n, result, h, pa, ignoreAllocHeapDefs); }
@Override public TypeReference[] getParameterTypes(int i) { assert i == 0; if (getMethod().isStatic()) { return new TypeReference[0]; } else { return new TypeReference[] { getMethod().getDeclaringClass().getReference() }; } }
private boolean isRelevantMethod(IMethod target) { return !target.isAbstract() && (!applicationOnly || cha.getScope().isApplicationLoader(target.getDeclaringClass().getClassLoader())); }
public static LambdaSummaryClass findOrCreate(CGNode caller, SSAInvokeDynamicInstruction inst) { if (! summaries.containsKey(inst.getBootstrap())) { String bootstrapCls = caller.getMethod().getDeclaringClass().getName().toString().replace("/", "$").substring(1); int bootstrapIndex = inst.getBootstrap().getIndexInClassFile(); TypeReference ref = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Lwala/lambda" + '$' + bootstrapCls + '$' + bootstrapIndex); LambdaSummaryClass cls = new LambdaSummaryClass(ref, caller.getClassHierarchy(), inst); caller.getClassHierarchy().addClass(cls); summaries.put(inst.getBootstrap(), cls); } return summaries.get(inst.getBootstrap()); }
public SymbolicPropagator(DexCFG dexCFG, SSAInstruction[] instructions, SSACFG cfg, SSAPiNodePolicy piNodePolicy) { super(dexCFG); this.piNodePolicy = piNodePolicy; this.cfg = cfg; this.creators = new SSAInstruction[0]; this.dexCFG = dexCFG; this.instructions = instructions; this.loader = dexCFG.getMethod().getDeclaringClass().getClassLoader().getReference(); // this.localMap = localMap; init(this.new NodeVisitor(cfg), this.new EdgeVisitor()); }
/** * Add constraints to represent the flow of exceptions to the exceptional return value for this node */ protected void addNodePassthruExceptionConstraints(CGNode node, IRView ir, DefUse du) { // add constraints relating to thrown exceptions that reach the exit block. List<ProgramCounter> peis = getIncomingPEIs(ir, ir.getExitBlock()); PointerKey exception = getPointerKeyForExceptionalReturnValue(node); TypeReference throwableType = node.getMethod().getDeclaringClass().getClassLoader().getLanguage().getThrowableType(); IClass c = node.getClassHierarchy().lookupClass(throwableType); addExceptionDefConstraints(ir, du, node, peis, exception, Collections.singleton(c)); }
@Override protected void processCallingConstraints(CGNode caller, SSAAbstractInvokeInstruction instruction, CGNode target, InstanceKey[][] constParams, PointerKey uniqueCatchKey) { if (JavaScriptLoader.JS.equals(caller.getMethod().getDeclaringClass().getClassLoader().getLanguage())) { JSSSAPropagationCallGraphBuilder.processCallingConstraintsInternal(this, caller, instruction, target, constParams, uniqueCatchKey); } else { super.processCallingConstraints(caller, instruction, target, constParams, uniqueCatchKey); } }
@Override public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) { MutableIntSet s = IntSetUtil.make(); for(int i = 0; i < caller.getIR().getCalls(site)[0].getNumberOfUses(); i++) { if (!caller.getMethod().getDeclaringClass().getClassLoader().getLanguage().methodsHaveDeclaredParameterTypes() || dispatchIndex(site, i)) { s.add(i); } } return s; }