What does the following program do?

import java.lang.reflect.Method;

public class CloudyReflection {
    public static void main(String[] args) throws Exception {
	Bird b = new Kiwi();
	Method m = b.getClass().getMethod("fly", new Class[] {});
	m.invoke(null, new Object[] {});
    }
}

class Bird {
    public static void fly() {
	System.out.println("Flap, flap, flap ...");
    }
}

class Kiwi extends Bird {
    public static void fly() {
	throw new UnsupportedOperationException("Squawk!");
    }
}

Answer: It calls Kiwi.fly() and squawks. The hope is that the reader will remember that static method calls are resolved on the reference type, not the referent type, and suppose that reflection does the same thing. It doesn't; getClass() returns Kiwi.class and getMethod() returns that class's version of the method.