public int compare(ClassDefItem a, ClassDefItem b) { return a.getClassType().compareTo(b.getClassType()); } });
/** {@inheritDoc} */ public String getConciseIdentity() { if (parent == null) { return "class_data_item @0x" + Integer.toHexString(getOffset()); } return "class_data_item @0x" + Integer.toHexString(getOffset()) + " (" + parent.getClassType() +")"; }
/** {@inheritDoc} */ public String getConciseIdentity() { if (parent == null) { return "annotation_directory_item @0x" + Integer.toHexString(getOffset()); } return "annotation_directory_item @0x" + Integer.toHexString(getOffset()) + " (" + parent.getClassType() + ")"; }
public DexFileClassMap(DexFile dexFile) { for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) { definedClasses.put(classDefItem.getClassType().getTypeDescriptor(), classDefItem); } }
public void loadDexFile(String dexFilePath, DexFile dexFile) { for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) { try { //TODO: need to check if the class already exists. (and if so, what to do about it?) TempClassInfo tempClassInfo = new TempClassInfo(dexFilePath, classDefItem); tempClasses.put(tempClassInfo.classType, tempClassInfo); } catch (Exception ex) { throw ExceptionWithContext.withContext(ex, String.format("Error while loading class %s", classDefItem.getClassType().getTypeDescriptor())); } } }
public TempClassInfo(String dexFilePath, ClassDefItem classDefItem) { this.dexFilePath = dexFilePath; classType = classDefItem.getClassType().getTypeDescriptor(); isInterface = (classDefItem.getAccessFlags() & AccessFlags.INTERFACE.getValue()) != 0; TypeIdItem superclassType = classDefItem.getSuperclass(); if (superclassType == null) { this.superclassType = null; } else { this.superclassType = superclassType.getTypeDescriptor(); } interfaces = loadInterfaces(classDefItem); ClassDataItem classDataItem = classDefItem.getClassData(); if (classDataItem != null) { boolean[][] _staticMethods = new boolean[1][]; directMethods = loadDirectMethods(classDataItem, _staticMethods); staticMethods = _staticMethods[0]; virtualMethods = loadVirtualMethods(classDataItem); instanceFields = loadInstanceFields(classDataItem); } else { staticMethods = null; directMethods = null; virtualMethods = null; instanceFields = null; } }
if (out.annotates()) { if (!isInternable() && parent != null) { out.annotate(0, parent.getClassType().getTypeDescriptor());
private String getClassName(ClassDefItem classDefItem) { String typeDescriptor = classDefItem.getClassType().getTypeDescriptor(); return typeDescriptor.substring(1, typeDescriptor.length() - 1).replace('/', '.'); }
public DexFileClassMap(DexFile dexFile) { for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) { definedClasses.put(classDefItem.getClassType().getTypeDescriptor(), classDefItem); } }
public Collection<TestCaseEvent> loadTestSuite() throws NoTestCasesFoundException { List<TestCaseEvent> testCaseEvents = dexFileExtractor.getDexFiles(instrumentationApkFile).stream() .map(dexFile -> dexFile.ClassDefsSection.getItems()) .flatMap(Collection::stream) .filter(c -> testClassMatcher.matchesPatterns(c.getClassType().getTypeDescriptor())) .map(this::convertClassToTestCaseEvents) .flatMap(Collection::stream) .collect(toList()); if (testCaseEvents.isEmpty()) { throw new NoTestCasesFoundException("No tests cases were found in the test APK: " + instrumentationApkFile.getAbsolutePath()); } return testCaseEvents; }
public int placeSection(int offset) { currentOffset = offset; if (section.DexFile.getSortAllItems()) { //presort the list, to guarantee a unique ordering Collections.sort(section.items, new Comparator<ClassDefItem>() { public int compare(ClassDefItem a, ClassDefItem b) { return a.getClassType().compareTo(b.getClassType()); } }); } //we need to initialize the offset for all the classes to -1, so we can tell which ones //have been placed for (ClassDefItem classDefItem: section.items) { classDefItem.offset = -1; } for (ClassDefItem classDefItem: section.items) { placeClass(classDefItem); } for (ClassDefItem classDefItem: unplacedClassDefsByType.values()) { section.items.set(classDefItem.getIndex(), classDefItem); } return currentOffset; }
private void loadDexFile(String dexFilePath, DexFile dexFile) { for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) { try { UnresolvedClassInfo unresolvedClassInfo = new UnresolvedClassInfo(dexFilePath, classDefItem); if (!unloadedClasses.containsKey(unresolvedClassInfo.classType)) { unloadedClasses.put(unresolvedClassInfo.classType, unresolvedClassInfo); } } catch (Exception ex) { throw ExceptionWithContext.withContext(ex, String.format("Error while loading class %s", classDefItem.getClassType().getTypeDescriptor())); } } }
public UnresolvedClassInfo(String dexFilePath, ClassDefItem classDefItem) { this.dexFilePath = dexFilePath; classType = classDefItem.getClassType().getTypeDescriptor(); isInterface = (classDefItem.getAccessFlags() & AccessFlags.INTERFACE.getValue()) != 0; TypeIdItem superclassType = classDefItem.getSuperclass(); if (superclassType == null) { this.superclassType = null; } else { this.superclassType = superclassType.getTypeDescriptor(); } interfaces = loadInterfaces(classDefItem); ClassDataItem classDataItem = classDefItem.getClassData(); if (classDataItem != null) { boolean[][] _staticMethods = new boolean[1][]; directMethods = loadDirectMethods(classDataItem, _staticMethods); staticMethods = _staticMethods[0]; virtualMethods = loadVirtualMethods(classDataItem); instanceFields = loadInstanceFields(classDataItem); } else { staticMethods = null; directMethods = null; virtualMethods = null; instanceFields = null; } }