/** * 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 + ")"; } /**
public SystemServiceModel(final IClassHierarchy cha, final AnalysisOptions options, final IAnalysisCacheView cache, Atom target) { super(cha, options, cache); if (target == null) { throw new IllegalArgumentException("The target requested to create an SystemServiceModel for was null"); } String sName = target.toString(); String cName = Character.toUpperCase(sName.charAt(0)) + sName.substring(1); this.name = Atom.findOrCreateAsciiAtom("startSystemService" + cName); this.target = target.toString(); }
/** * is field a direct (WALA-internal) reference to the global object? */ private static boolean directGlobalObjectRef(FieldReference field) { return field.getName().toString().endsWith(GLOBAL_OBJ_VAR_NAME); }
/** * is field a direct (WALA-internal) reference to the global object? */ private static boolean directGlobalObjectRef(FieldReference field) { return field.getName().toString().endsWith(GLOBAL_OBJ_VAR_NAME); }
@Override public void visitAstGlobalWrite(AstGlobalWrite instruction) { String propName = instruction.getDeclaredField().getName().toString(); // hack to account for global variables assert propName.startsWith("global "); propName = propName.substring("global ".length()); visitPut(instruction.getVal(), propName); }
private enum Explicit { UNSET, IMPLICIT, EXPLICIT, /** An other target was set for an explicit Intent */ MULTI }
public boolean isMemberOf(Atom klass) { return method.getDeclaringClass().getName().toString().startsWith(klass.toString()); //IClassHierarchy cha = getClassHierarchy(); //final TypeReference type = TypeReference.find(ClassLoaderReference.Primordial, klass.toString()); //if (type == null) { // throw new IllegalArgumentException("Unable to look up " + klass.toString()); //} //return cha.isSubclassOf(method.getDeclaringClass(), cha.lookupClass(type)); } /**
private static FieldReference makeNonGlobalFieldReference(FieldReference field) { String nonGlobalFieldName = field.getName().toString().substring(7); field = FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(nonGlobalFieldName), JavaScriptTypes.Root); return field; }
public Intent findOrCreate(final InstanceKey key, String action) { final Intent intent = findOrCreate(key); final Atom foundAction = intent.getAction(); if (! foundAction.equals(Atom.findOrCreateAsciiAtom(action))) { throw new IllegalArgumentException("Actions differ (" + action + ", " + foundAction.toString() + ") for Intent " + key); } return intent; }
public Intent findOrCreate(final InstanceKey key, String action) { final Intent intent = findOrCreate(key); final Atom foundAction = intent.getAction(); if (! foundAction.equals(Atom.findOrCreateAsciiAtom(action))) { throw new IllegalArgumentException("Actions differ (" + action + ", " + foundAction.toString() + ") for Intent " + key); } return intent; }
private void checkThrownExceptions(CGNode node, IntraproceduralExceptionAnalysis analysis) { Set<TypeReference> exceptions = analysis.getExceptions(); String text = "Number of thrown exceptions did not match in " + node.getMethod().getName().toString() + ". The follwoing exceptions were thrown: " + exceptions.toString(); if (node.getMethod().getName().toString().matches("invokeSingle.*") && (!node.getMethod().getName().toString().equals("invokeSingleRecursive2Helper")) && (!node.getMethod().getName().toString().equals("invokeSinglePassThrough"))) { collector.checkThat(text, exceptions.size(), equalTo(1)); } else { collector.checkThat(text, exceptions.size(), equalTo(0)); } }
private static int getNumberOfAppClasses(ClassHierarchy cha){ Iterator<IClass> classes = cha.iterator(); int numberOfClasses = 0; while(classes.hasNext()){ if(classes.next().getClassLoader().getName().toString().equals("Application")) numberOfClasses++; } return numberOfClasses; }
@Override public String toString(SymbolTable symbolTable) { return getValueString(symbolTable, lval) + " (" + pointeeType.getName() + ") " + " = &" + getValueString(symbolTable, addressVal) + ((indexVal != -1) ? '[' + getValueString(symbolTable, indexVal) + ']' : (field != null) ? '.' + field.getName().toString() : ""); }
@Override public String toString(SymbolTable symbolTable) { return getValueString(symbolTable, lval) + " (" + pointeeType.getName() + ") " + " = &" + getValueString(symbolTable, addressVal) + ((indexVal != -1) ? '[' + getValueString(symbolTable, indexVal) + ']' : (field != null) ? '.' + field.getName().toString() : ""); }
private final static CGNode findDoNothingNode(CallGraph cg) { for (CGNode n : cg) { if (n.getMethod().getName().toString().equals("doNothing")) { return n; } } Assertions.UNREACHABLE("Unexpected: failed to find doNothing node"); return null; } }
private final static CGNode findNode(CallGraph cg, String methodName) { for (CGNode n : cg) { if (n.getMethod().getName().toString().equals(methodName)) { return n; } } Assertions.UNREACHABLE("Unexpected: failed to find " + methodName + " node"); return null; }
@Test public void testIntra() { for (CGNode node : cg) { IntraproceduralExceptionAnalysis analysis = new IntraproceduralExceptionAnalysis(node, filter.getFilter(node), cha, pointerAnalysis); if (node.getMethod().getDeclaringClass().getName().getClassName().toString().equals("TestPruning")) { checkThrownExceptions(node, analysis); checkCaughtExceptions(node, analysis); } } }