Search in sources :

Example 1 with DexException

use of com.tencent.tinker.android.dex.DexException in project tinker by Tencent.

the class InstructionPromoter method visitFillArrayDataPayloadInsn.

@Override
public void visitFillArrayDataPayloadInsn(int currentAddress, int opcode, Object data, int size, int elementWidth) {
    mapAddressIfNeeded(currentAddress);
    this.currentPromotedAddress += 2 + 2;
    switch(elementWidth) {
        case 1:
            {
                int length = ((byte[]) data).length;
                this.currentPromotedAddress += (length >> 1) + (length & 1);
                break;
            }
        case 2:
            {
                this.currentPromotedAddress += ((short[]) data).length * 1;
                break;
            }
        case 4:
            {
                this.currentPromotedAddress += ((int[]) data).length * 2;
                break;
            }
        case 8:
            {
                this.currentPromotedAddress += ((long[]) data).length * 4;
                break;
            }
        default:
            {
                throw new DexException("bogus element_width: " + Hex.u2(elementWidth));
            }
    }
}
Also used : DexException(com.tencent.tinker.android.dex.DexException)

Example 2 with DexException

use of com.tencent.tinker.android.dex.DexException in project tinker by Tencent.

the class InstructionWriter method visitFillArrayDataPayloadInsn.

public void visitFillArrayDataPayloadInsn(int currentAddress, int opcode, Object data, int size, int elementWidth) {
    short opcodeUnit = (short) opcode;
    codeOut.write(opcodeUnit);
    short elementWidthUnit = (short) elementWidth;
    codeOut.write(elementWidthUnit);
    codeOut.writeInt(size);
    switch(elementWidth) {
        case 1:
            {
                codeOut.write((byte[]) data);
                break;
            }
        case 2:
            {
                codeOut.write((short[]) data);
                break;
            }
        case 4:
            {
                codeOut.write((int[]) data);
                break;
            }
        case 8:
            {
                codeOut.write((long[]) data);
                break;
            }
        default:
            {
                throw new DexException("bogus element_width: " + Hex.u2(elementWidth));
            }
    }
}
Also used : DexException(com.tencent.tinker.android.dex.DexException)

Example 3 with DexException

use of com.tencent.tinker.android.dex.DexException in project tinker by Tencent.

the class DexDataBuffer method readStringData.

public StringData readStringData() {
    int off = data.position();
    try {
        int expectedLength = readUleb128();
        String result = Mutf8.decode(this, new char[expectedLength]);
        if (result.length() != expectedLength) {
            throw new DexException("Declared length " + expectedLength + " doesn't match decoded length of " + result.length());
        }
        return new StringData(off, result);
    } catch (UTFDataFormatException e) {
        throw new DexException(e);
    }
}
Also used : DexException(com.tencent.tinker.android.dex.DexException) UTFDataFormatException(java.io.UTFDataFormatException) StringData(com.tencent.tinker.android.dex.StringData)

Example 4 with DexException

use of com.tencent.tinker.android.dex.DexException in project tinker by Tencent.

the class InstructionTransformer method transform.

public short[] transform(short[] encodedInstructions) throws DexException {
    ShortArrayCodeOutput out = new ShortArrayCodeOutput(encodedInstructions.length);
    InstructionPromoter ipmo = new InstructionPromoter();
    InstructionWriter iw = new InstructionWriter(out, ipmo);
    InstructionReader ir = new InstructionReader(new ShortArrayCodeInput(encodedInstructions));
    try {
        // First visit, we collect mappings from original target address to promoted target address.
        ir.accept(new InstructionTransformVisitor(ipmo));
        // Then do the real transformation work.
        ir.accept(new InstructionTransformVisitor(iw));
    } catch (EOFException e) {
        throw new DexException(e);
    }
    return out.getArray();
}
Also used : DexException(com.tencent.tinker.android.dex.DexException) ShortArrayCodeOutput(com.tencent.tinker.android.dx.instruction.ShortArrayCodeOutput) InstructionPromoter(com.tencent.tinker.android.dx.instruction.InstructionPromoter) EOFException(java.io.EOFException) ShortArrayCodeInput(com.tencent.tinker.android.dx.instruction.ShortArrayCodeInput) InstructionReader(com.tencent.tinker.android.dx.instruction.InstructionReader) InstructionWriter(com.tencent.tinker.android.dx.instruction.InstructionWriter)

Aggregations

DexException (com.tencent.tinker.android.dex.DexException)4 StringData (com.tencent.tinker.android.dex.StringData)1 InstructionPromoter (com.tencent.tinker.android.dx.instruction.InstructionPromoter)1 InstructionReader (com.tencent.tinker.android.dx.instruction.InstructionReader)1 InstructionWriter (com.tencent.tinker.android.dx.instruction.InstructionWriter)1 ShortArrayCodeInput (com.tencent.tinker.android.dx.instruction.ShortArrayCodeInput)1 ShortArrayCodeOutput (com.tencent.tinker.android.dx.instruction.ShortArrayCodeOutput)1 EOFException (java.io.EOFException)1 UTFDataFormatException (java.io.UTFDataFormatException)1