public void commit() {
		method.clearCode();

		final CodeGenerator codegen = new CodeGenerator(method);
		visit(codegen);

		final Label endLabel = method.newLabel();
		method.addLabel(endLabel);

		// Add all the handlers back in the same order we got them.
		// This ensures that the correct catch clause will be called
		// when an exception is thrown.
		final Iterator iter = catchBlocks.iterator();

		while (iter.hasNext()) {
			final Block catchBlock = (Block) iter.next();

			final Handler handler = (Handler) handlers.get(catchBlock);
			Assert.isTrue(handler != null);

			Type type = handler.catchType();

			if (type.isNull()) {
				type = null;
			}

			Block begin = null;

			final Iterator blocks = trace().iterator();

			while (blocks.hasNext()) {
				final Block block = (Block) blocks.next();

				if (handler.protectedBlocks().contains(block)) {
					if (begin == null) {
						begin = block;
					}
				} else if (begin != null) {
					final TryCatch tc = new TryCatch(begin.label(), block
							.label(), catchBlock.label(), type);

					method.addTryCatch(tc);

					begin = null;
				}
			}
		}
	}