Search in sources :

Example 1 with TryData

use of jadx.api.plugins.input.data.impl.TryData in project jadx by skylot.

the class DexCodeReader method getTries.

@Override
public List<ITry> getTries() {
    int triesOffset = getTriesOffset();
    if (triesOffset == -1) {
        return Collections.emptyList();
    }
    int triesCount = getTriesCount();
    Map<Integer, ICatch> catchHandlers = getCatchHandlers(triesOffset + 8 * triesCount, in.copy());
    in.pos(triesOffset);
    List<ITry> triesList = new ArrayList<>(triesCount);
    for (int i = 0; i < triesCount; i++) {
        int startAddr = in.readInt();
        int insnsCount = in.readUShort();
        int handlerOff = in.readUShort();
        ICatch catchHandler = catchHandlers.get(handlerOff);
        if (catchHandler == null) {
            throw new DexException("Catch handler not found by byte offset: " + handlerOff);
        }
        triesList.add(new TryData(startAddr, startAddr + insnsCount - 1, catchHandler));
    }
    return triesList;
}
Also used : ITry(jadx.api.plugins.input.data.ITry) DexException(jadx.plugins.input.dex.DexException) ArrayList(java.util.ArrayList) TryData(jadx.api.plugins.input.data.impl.TryData) ICatch(jadx.api.plugins.input.data.ICatch)

Aggregations

ICatch (jadx.api.plugins.input.data.ICatch)1 ITry (jadx.api.plugins.input.data.ITry)1 TryData (jadx.api.plugins.input.data.impl.TryData)1 DexException (jadx.plugins.input.dex.DexException)1 ArrayList (java.util.ArrayList)1