Usages of

com.ibm.wala.types.TypeName.getInnermostElementType()
private CompletedSignatures getCompletedSignatures(List<SourceOrSink> pois) { IClassHierarchy cha = callGraph.getClassHierarchy(); int noOverall = 0; int noMatched = 0; Map<SourceOrSink, JavaMethodSignature> completedSigs = new HashMap<SourceOrSink, JavaMethodSignature>(); List<SourceOrSink> unmatched = new LinkedList<SourceOrSink>(); for (SourceOrSink poi : pois) { String declaringClass = poi.getDeclaringClass(); String incompleteSelector = poi.getMethod(); IClass c = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Primordial, declaringClass.replaceAll(";", ""))); if (c == null) { throw new RuntimeException(declaringClass); } boolean matched = false; for (IMethod m : c.getAllMethods()) { TypeName retTypeName = m.getSelector().getDescriptor().getReturnType(); String retType = m.getSelector().getDescriptor().getReturnType().toString(); String completedSelector = incompleteSelector + retType; if (retTypeName.isClassType() || (retTypeName.isArrayType() && retTypeName.getInnermostElementType().isClassType())) { completedSelector += ";"; } if (m.getSelector().toString().equals(completedSelector)) { completedSigs.put(poi, JavaMethodSignature.fromString(m.getSignature())); noMatched++; matched = true; break; } } if (!matched) { unmatched.add(poi); for (IMethod m : c.getAllMethods()) { System.out.println(m.getSignature()); } } noOverall++; } return new CompletedSignatures(completedSigs, noMatched, noOverall, unmatched); }
protected CompletedSignatures getCompletedSignatures(List<SourceOrSink> pois) { int noOverall = 0; int noMatched = 0; Map<SourceOrSink, MethodReference> completedSigs = new HashMap<SourceOrSink, MethodReference>(); List<SourceOrSink> unmatched = new LinkedList<SourceOrSink>(); for (SourceOrSink poi : pois) { String declaringClass = poi.getDeclaringClass(); String incompleteSelector = poi.getMethod(); IClass c = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Primordial, declaringClass.replaceAll(";", ""))); if (c == null) { throw new RuntimeException(declaringClass); } boolean matched = false; for (IMethod m : c.getAllMethods()) { TypeName retTypeName = m.getSelector().getDescriptor().getReturnType(); String retType = m.getSelector().getDescriptor().getReturnType().toString(); String completedSelector = incompleteSelector + retType; if (retTypeName.isClassType() || (retTypeName.isArrayType() && retTypeName.getInnermostElementType().isClassType())) { completedSelector += ";"; } if (m.getSelector().toString().equals(completedSelector)) { completedSigs.put(poi, m.getReference()); noMatched++; matched = true; break; } } if (!matched) { unmatched.add(poi); for (IMethod m : c.getAllMethods()) { System.out.println(m.getSignature()); } } noOverall++; } return new CompletedSignatures(completedSigs, noMatched, noOverall, unmatched); }
protected CompletedSignatures getCompletedSignatures(List<SourceOrSink> pois) { int noOverall = 0; int noMatched = 0; Map<SourceOrSink, MethodReference> completedSigs = new HashMap<SourceOrSink, MethodReference>(); List<SourceOrSink> unmatched = new LinkedList<SourceOrSink>(); for (SourceOrSink poi : pois) { String declaringClass = poi.getDeclaringClass(); String incompleteSelector = poi.getMethod(); IClass c = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Primordial, declaringClass.replaceAll(";", ""))); if (c == null) { throw new RuntimeException(declaringClass); } boolean matched = false; for (IMethod m : c.getAllMethods()) { TypeName retTypeName = m.getSelector().getDescriptor().getReturnType(); String retType = m.getSelector().getDescriptor().getReturnType().toString(); String completedSelector = incompleteSelector + retType; if (retTypeName.isClassType() || (retTypeName.isArrayType() && retTypeName.getInnermostElementType().isClassType())) { completedSelector += ";"; } if (m.getSelector().toString().equals(completedSelector)) { completedSigs.put(poi, m.getReference()); noMatched++; matched = true; break; } } if (!matched) { unmatched.add(poi); for (IMethod m : c.getAllMethods()) { System.out.println(m.getSignature()); } } noOverall++; } return new CompletedSignatures(completedSigs, noMatched, noOverall, unmatched); }
public static final String type2string(TypeName tName) { if (tName.isArrayType()) { return type2string(tName.getInnermostElementType()) + "[]"; } if (tName.isPrimitiveType()) { switch (tName.toString().charAt(0)) { case 'Z': return "boolean"; case 'S': return "short"; case 'J': return "long"; case 'I': return "int"; case 'F': return "float"; case 'D': return "double"; case 'C': return "char"; case 'B': return "byte"; default: return tName.toString(); } } else { StringBuilder test = new StringBuilder(tName.toString().replace('/', '.')); // remove 'L' in front of object type test.deleteCharAt(0); return test.toString(); } }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes