Package org.jf.dexlib2.immutable

Examples of org.jf.dexlib2.immutable.ImmutableExceptionHandler


    @Test
    public void testHandlerMerge_DifferentType() {
        TryListBuilder tlb = new TryListBuilder();

        tlb.addHandler(5, 10, new ImmutableExceptionHandler("LException1;", 5));
        tlb.addHandler(0, 15, new ImmutableExceptionHandler("LException2;", 6));

        List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();

        List<? extends TryBlock> expected = ImmutableList.of(
                new ImmutableTryBlock(0, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler("LException2;", 6))),
                new ImmutableTryBlock(5, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler("LException1;", 5),
                                new ImmutableExceptionHandler("LException2;", 6))),
                new ImmutableTryBlock(10, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler("LException2;", 6))));

        Assert.assertEquals(expected, tryBlocks);
    }
View Full Code Here


    @Test
    public void testHandlerMerge_DifferentAddress() {
        TryListBuilder tlb = new TryListBuilder();

        tlb.addHandler(5, 10, new ImmutableExceptionHandler("LException1;", 5));
        tlb.addHandler(0, 15, new ImmutableExceptionHandler("LException1;", 6));
        // no exception should be thrown...
    }
View Full Code Here

    @Test
    public void testHandlerMerge_Exception_Catchall() {
        TryListBuilder tlb = new TryListBuilder();

        tlb.addHandler(5, 10, new ImmutableExceptionHandler("LException1;", 5));
        tlb.addHandler(0, 15, new ImmutableExceptionHandler(null, 6));

        List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();

        List<? extends TryBlock> expected = ImmutableList.of(
                new ImmutableTryBlock(0, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler(null, 6))),
                new ImmutableTryBlock(5, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler("LException1;", 5),
                                new ImmutableExceptionHandler(null, 6))),
                new ImmutableTryBlock(10, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler(null, 6))));

        Assert.assertEquals(expected, tryBlocks);
    }
View Full Code Here

    @Test
    public void testHandlerMerge_Catchall_Exception() {
        TryListBuilder tlb = new TryListBuilder();

        tlb.addHandler(5, 10, new ImmutableExceptionHandler(null, 5));
        tlb.addHandler(0, 15, new ImmutableExceptionHandler("LException1;", 6));

        List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();

        List<? extends TryBlock> expected = ImmutableList.of(
                new ImmutableTryBlock(0, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler("LException1;", 6))),
                new ImmutableTryBlock(5, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler(null, 5),
                                new ImmutableExceptionHandler("LException1;", 6))),
                new ImmutableTryBlock(10, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler("LException1;", 6))));

        Assert.assertEquals(expected, tryBlocks);
    }
View Full Code Here

    @Test
    public void testHandlerMerge_Catchall_Catchall() {
        TryListBuilder tlb = new TryListBuilder();

        tlb.addHandler(5, 10, new ImmutableExceptionHandler(null, 5));
        tlb.addHandler(0, 15, new ImmutableExceptionHandler(null, 5));

        List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();

        List<? extends TryBlock> expected = ImmutableList.of(
                new ImmutableTryBlock(0, 15,
                        ImmutableList.of(
                                new ImmutableExceptionHandler(null, 5))));

        Assert.assertEquals(expected, tryBlocks);
    }
View Full Code Here

    @Test
    public void testHandlerMerge_Catchall_Catchall_DifferentAddress() {
        TryListBuilder tlb = new TryListBuilder();

        tlb.addHandler(5, 10, new ImmutableExceptionHandler(null, 5));
        try {
            tlb.addHandler(0, 15, new ImmutableExceptionHandler(null, 6));
        } catch (TryListBuilder.InvalidTryException ex) {
            return;
        }
        Assert.fail();
    }
View Full Code Here

    @Test
    public void testHandlerMerge_MergeSame() {
        TryListBuilder tlb = new TryListBuilder();

        tlb.addHandler(0, 15, new ImmutableExceptionHandler(null, 6));
        tlb.addHandler(10, 20, new ImmutableExceptionHandler("LException1;", 5));
        tlb.addHandler(20, 30, new ImmutableExceptionHandler("LException1;", 5));
        tlb.addHandler(25, 40, new ImmutableExceptionHandler(null, 6));

        List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = tlb.getTryBlocks();

        List<? extends TryBlock> expected = ImmutableList.of(
                new ImmutableTryBlock(0, 10,
                        ImmutableList.of(
                                new ImmutableExceptionHandler(null, 6))),
                new ImmutableTryBlock(10, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler(null, 6),
                                new ImmutableExceptionHandler("LException1;", 5))),
                new ImmutableTryBlock(15, 10,
                        ImmutableList.of(
                                new ImmutableExceptionHandler("LException1;", 5))),
                new ImmutableTryBlock(25, 5,
                        ImmutableList.of(
                                new ImmutableExceptionHandler("LException1;", 5),
                                new ImmutableExceptionHandler(null, 6))),
                new ImmutableTryBlock(30, 10,
                        ImmutableList.of(
                                new ImmutableExceptionHandler(null, 6))));

        Assert.assertEquals(expected, tryBlocks);
    }
View Full Code Here

        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.PUBLIC.getValue(), null,
                methodImpl);

        ClassDef classDef = new ImmutableClassDef("Lblah;", AccessFlags.PUBLIC.getValue(), "Ljava/lang/Object;", null,
                null, null, null, null, null, ImmutableList.of(method));
View Full Code Here

        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.STATIC.getValue(), null,
                methodImpl);

        ClassDef classDef = new ImmutableClassDef("Lblah;", AccessFlags.PUBLIC.getValue(), "Ljava/lang/Object;", null,
                null, null, null, null, ImmutableList.of(method), null);
View Full Code Here

        List<ImmutableInstruction> instructions = Lists.newArrayList(
                new ImmutableInstruction35mi(Opcode.EXECUTE_INLINE, 1, 0, 0, 0, 0, 0, 0),
                new ImmutableInstruction10x(Opcode.RETURN_VOID));

        ImmutableMethodImplementation methodImpl = new ImmutableMethodImplementation(1, instructions, null, null);
        ImmutableMethod method = new ImmutableMethod("Lblah;", "blah", null, "V", AccessFlags.PRIVATE.getValue(), null,
                methodImpl);

        ClassDef classDef = new ImmutableClassDef("Lblah;", AccessFlags.PUBLIC.getValue(), "Ljava/lang/Object;", null,
                null, null, null, null, ImmutableList.of(method), null);
View Full Code Here

TOP

Related Classes of org.jf.dexlib2.immutable.ImmutableExceptionHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.