public class BadCodeDemo { /* The following code misbehaves in Eclipse 3.1M4 when compiled under Java 5 * It should print: * m(int)1 * m(Object)1 * and terminate * Instead, it repeately prints m(int)1 * until stack overflow * * Removal of the unnecessary and unexecuted function m(double) allows the code to execute normally, * as will an explicit cast of Integer to Object in method A.m(int) * * This code executes correctly when compiled with jdk1.5.0.0_01 */ public static void main(String[] args) { A a = new B(); a.m(1); } public interface I { void m(Object o); } public static abstract class A implements I { public final void m(int i) { System.out.println("m(int)" + i); /* if the following line is replaced with m((Object)new Integer(i)); , there is no infinite recursion */ m(new Integer(i)); } /* or, if the following unexecuted method is removed, there is no infinite recursion */ public final void m(double d) { System.out.println("m(double)" + d); m(new Double(d)); } } public static class B extends A { public void m(Object o) { System.out.println("m(Object)" + o); } } }