I tested your code and it works as expected. Of course it suffers from the same issue as mine: If the VM crashes, it won't deactivate the workaround in Compiz.
For example, this leaves the workaround active if it was deactivated:
public static void main(final String[] args) throws LWJGLException, InterruptedException {
Display.setDisplayMode(Display.getDesktopDisplayMode());
Display.setFullscreen(true);
Display.create();
while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
Display.update();
Thread.sleep(50);
}
// Crash Java VM
Object[] o = null;
while (true) {
o = new Object[]{o};
}
}
I considered writing the state to disk before changing it, to be able to recover in case of a crash. However that's not exactly reliable either (Will the program in question ever run properly again? Has the user changed his mind, i.e. does he now want the workaround to stay active? etc.). Plus it's hard to tell how long the workaround will stay in Compiz.