public ClassType findClassType(String name) { List<ReferenceType> cls = this.findClasses(name); ReferenceType cl = null; if (!cls.isEmpty()) { if (cls.size() > 1) { DalvikUtils.LOGGER.warn( "found more than one class; solution not implemented, taking the first"); } cl = cls.get(0); } return (ClassType) cl; }
public DalvikUtils(VirtualMachine vm, int threadIndex) { this.vm = vm; this.name = this.vm.name(); // TODO dont know if this should be defaulted or exception thrown if ((threadIndex < 0) || (threadIndex >= this.vm.allThreads().size())) { threadIndex = 0; DalvikUtils.LOGGER.warn( "out of bounds condition with given argument value : " + threadIndex + " using default value of 0"); } this.currentThread = this.vm.allThreads().get(threadIndex); this.eventRequestManager = this.vm.eventRequestManager(); }
public Value getSystemClassLoader(ThreadReference tr) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { DalvikUtils.LOGGER.info( "attempting to get the system class loader (Class.getSystemClassLoader)"); Value toreturn = null; ClassType cl = this.findClassType("java.lang.ClassLoader"); if (cl != null) { List<Method> getSCLMS = cl.methodsByName("getSystemClassLoader"); Method getSCL = getSCLMS.get(0); if (getSCL != null) { Value result = cl.invokeMethod(tr, getSCL, new ArrayList<Value>(), 0); toreturn = result; } } return toreturn; }
// TODO this is not sufficient only does method names not line locations public Location resolveLocation(String location) { DalvikUtils.LOGGER.warn("line locations not yet implemented!"); location = location.trim(); Location loc = null; int endIdx = location.lastIndexOf("."); if (endIdx != -1) { String className = location.substring(0, endIdx); ReferenceType cr = this.findClassType(className); if (cr != null) { for (Method m : cr.allMethods()) { // TODO need to think on this comparison ... if (m.toString().contains(location)) { loc = m.location(); break; } } } } return loc; }