ArrayEncodedValue staticInitializers = getStaticInitializers(poolClassDef); if (staticInitializers != null) { dexPool.encodedArraySection.intern(staticInitializers); internCode(method); internDebug(method); dexPool.annotationSetSection.intern(method.getAnnotations());
internCode(method); internDebug(method); annotationSetPool.intern(method.getAnnotations());
/** * Interns a class into this DexPool * @param classDef The class to intern */ public void internClass(ClassDef classDef) { classSection.intern(classDef); }
@Nonnull @Override public ClassPool getClassSection() { return new ClassPool(DexPool.this); }
/** * Interns a class into this DexPool * @param classDef The class to intern */ public void internClass(ClassDef classDef) { classSection.intern(classDef); }
@Nonnull @Override public ClassPool getClassSection() { return new ClassPool(DexPool.this); }
ArrayEncodedValue staticInitializers = getStaticInitializers(poolClassDef); if (staticInitializers != null) { dexPool.encodedArraySection.intern(staticInitializers); internCode(method); internDebug(method); dexPool.annotationSetSection.intern(method.getAnnotations());
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException { DexPool dexPool = makeDexPool(); for (ClassDef classDef: input.getClasses()) { ((ClassPool)dexPool.classSection).intern(classDef); } dexPool.writeTo(new FileDataStore(new File(path))); }
public static DexPool makeDexPool(int api) { StringPool stringPool = new StringPool(); TypePool typePool = new TypePool(stringPool); FieldPool fieldPool = new FieldPool(stringPool, typePool); TypeListPool typeListPool = new TypeListPool(typePool); ProtoPool protoPool = new ProtoPool(stringPool, typePool, typeListPool); MethodPool methodPool = new MethodPool(stringPool, typePool, protoPool); AnnotationPool annotationPool = new AnnotationPool(stringPool, typePool, fieldPool, methodPool); AnnotationSetPool annotationSetPool = new AnnotationSetPool(annotationPool); ClassPool classPool = new ClassPool(stringPool, typePool, fieldPool, methodPool, annotationSetPool, typeListPool); return new DexPool(api, stringPool, typePool, protoPool, fieldPool, methodPool, classPool, typeListPool, annotationPool, annotationSetPool); }
public <C extends ClassDef> void writeClassesTo( List<C> classList, DexDataStoreFactory store) throws IOException { int dexNum = 0; DexPool dexPool = new DexPool(opcodes); ClassPool clsPool = dexPool.classSection; classList.sort(Comparator.comparing(ClassDef::getType)); for (ClassDef classDef : classList) { int numMethodIds = dexPool.methodSection.getItemCount(); int numFieldIds = dexPool.fieldSection.getItemCount(); int constantPoolSize = classDef.getDirectMethodCount() + classDef.getVirtualMethodCount() + classDef.getStaticFieldCount() + classDef.getInstanceFieldCount(); int maxMethodIdsInDex = numMethodIds + constantPoolSize + MAX_METHOD_ADDED_DURING_DEX_CREATION; int maxFieldIdsInDex = numFieldIds + constantPoolSize + MAX_FIELD_ADDED_DURING_DEX_CREATION; if (maxMethodIdsInDex > mMaxNumberOfIdxPerDex || maxFieldIdsInDex > mMaxNumberOfIdxPerDex) { dexPool.writeTo(store.getDataStore(dexNum)); dexNum++; dexPool = new DexPool(opcodes); clsPool = dexPool.classSection; } clsPool.intern(classDef); } dexPool.writeTo(store.getDataStore(dexNum)); }