@Override public int byteCountInDex() { int insnsSize = instructions.length; int res = 4 * SizeOf.USHORT + 2 * SizeOf.UINT + insnsSize * SizeOf.USHORT; if (tries.length > 0) { if ((insnsSize & 1) == 1) { res += SizeOf.USHORT; } res += tries.length * SizeOf.TRY_ITEM; int catchHandlerSize = catchHandlers.length; res += Leb128.unsignedLeb128Size(catchHandlerSize); for (CatchHandler catchHandler : catchHandlers) { int typeIdxAddrPairCount = catchHandler.typeIndexes.length; if (catchHandler.catchAllAddress != -1) { res += Leb128.signedLeb128Size(-typeIdxAddrPairCount) + Leb128.unsignedLeb128Size(catchHandler.catchAllAddress); } else { res += Leb128.signedLeb128Size(typeIdxAddrPairCount); } for (int i = 0; i < typeIdxAddrPairCount; ++i) { res += Leb128.unsignedLeb128Size(catchHandler.typeIndexes[i]) + Leb128.unsignedLeb128Size(catchHandler.addresses[i]); } } } return res; }
@Override public int byteCountInDex() { int insnsSize = instructions.length; int res = 4 * SizeOf.USHORT + 2 * SizeOf.UINT + insnsSize * SizeOf.USHORT; if (tries.length > 0) { if ((insnsSize & 1) == 1) { res += SizeOf.USHORT; } res += tries.length * SizeOf.TRY_ITEM; int catchHandlerSize = catchHandlers.length; res += Leb128.unsignedLeb128Size(catchHandlerSize); for (CatchHandler catchHandler : catchHandlers) { int typeIdxAddrPairCount = catchHandler.typeIndexes.length; if (catchHandler.catchAllAddress != -1) { res += Leb128.signedLeb128Size(-typeIdxAddrPairCount) + Leb128.unsignedLeb128Size(catchHandler.catchAllAddress); } else { res += Leb128.signedLeb128Size(typeIdxAddrPairCount); } for (int i = 0; i < typeIdxAddrPairCount; ++i) { res += Leb128.unsignedLeb128Size(catchHandler.typeIndexes[i]) + Leb128.unsignedLeb128Size(catchHandler.addresses[i]); } } } return res; }