public void internClass(final ClassDef clz) { curPool.mark(); curPool.internClass(clz); if (hasOverflowed()) { // reset to state before overflow occurred curPool.reset(); // we need a new dexpool newDexPool(); // re-execute on new pool since the last execution was dropped // NOTE: We do not want to call internClass recursively here, this // might end in an endless loop // if the class is to large for a single dex file! curPool.internClass(clz); // If a single class causes an overflow, we're really out of luck if (curPool.hasOverflowed()) { throw new RuntimeException("Class is bigger than a single dex file can be"); } } }
DexPool dexPool = new DexPool(Opcodes.getDefault()); dexPool.internClass(class1); dexPool.mark(); dexPool.internClass(class2); dexPool.reset();