TryListBuilder { public void addHandler(int startAddress, int endAddress, EH handler) { TryBounds<EH> bounds = getBoundingRanges(startAddress, endAddress); MutableTryBlock<EH> startBlock = bounds.start; MutableTryBlock<EH> endBlock = bounds.end; int previousEnd = startAddress; MutableTryBlock<EH> tryBlock = startBlock; do { if (tryBlock.startCodeAddress > previousEnd) { MutableTryBlock<EH> newBlock = new MutableTryBlock<EH>(previousEnd, tryBlock.startCodeAddress); tryBlock.prepend(newBlock); tryBlock = newBlock; } tryBlock.addHandler(handler); previousEnd = tryBlock.endCodeAddress; tryBlock = tryBlock.next; } while (tryBlock.prev != endBlock); } TryListBuilder(); static List<TryBlock<EH>> massageTryBlocks(
            List<? extends TryBlock<? extends EH>> tryBlocks); void addHandler(int startAddress, int endAddress, EH handler); List<TryBlock<EH>> getTryBlocks();  }
@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)); }
@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(); }