The 4.0s are stout. You'll hear lots of high-milage stories, but nothing serious going wrong. Main seal leaks are common, but easy to fix. The tube headers have gone through many design changes through the years, but all seem prone to cracking. Easy to fix by a good welder. Annoying problems, too, with the ignition system, especially the early (through '90) Renix system. High idle and crank-but-no-spark are especially common. Both easy to fix, though frustrating.

Transmissions? The AW4 auto is most common, used from 87-98, maybe later. I don't hear of problems with them, and it seems to be a very reliable and robust transmission for the XJ. I have the AW4, and I'd get it again. The later AX-15 manual transmission seem to be trouble-free. The early Peugeot BA 10/5 isn't well-liked. (more trans info here)