September, 2008 Archive

Spaces flipping with X11 in OS X

September 10th, 2008 by David Saff in Uncategorized

Say you are using your MacBook to run Eclipse and some xterms from a Linux box through X11, and you distribute your X11 windows to different spaces.  (You’re probably using NX, so that you aren’t motivated by latency to throw a cat out the window after every mouse click…)  Every few moments, your monitor suddenly and violently flips to what feels like a random space.

I’m lucky enough to sit near Matthew Gray, who brainstormed this solution:

The combination of X11 + Spaces treats the UI Layer on which tooltips appear as a separate application: if you move Eclipse, but not the tooltips layer, Spaces will flip to the old space every time it even thinks about displaying a tooltip (sometimes, it appears, even without any actual tooltip being shown).  This is easy to miss, since the tooltip will go away as soon as you move the mouse.

The fix is one of those things that should never work, but does.  It also requires some skill.  Move the mouse to a place in the Eclipse window that should pop up a tooltip.  Keep the mouse very still while your Mac flips to the new space.  Now, without moving the mouse, press F8 to Show Spaces (if you still have the default keys enabled).  Now, carefully pick up the tool tip (which should still be showing, but very small), and drag it into the same space as Eclipse.

Of course, it would be great if X11 + OS X could work out a better way to play together, but this works for now.

Checking Exceptions with Theories

September 9th, 2008 by David Saff in Uncategorized

Robert Rees was astute enough to point out that it can be difficult to combine the expected-exception feature of JUnit 4 with Theories.  What if we want to say that any Comparable in our system should throw a null pointer exception if compared with null?  (By the way, it appears this is neither required nor disallowed by the Comparable contract.)

The current answer is a bit ugly: you need to combine the @Test and @Theory annotations:

@Theory @Test(expected=NullPointerException.class)
public void compareToNullThrowsNpe(Comparable c) {