Whilst tidying up my project by removing what I believed to be unnecessary code, I removed a constructor of the form
public MyClass(int a, int b)
leaving in place the other constructor
public MyClass(double c, double d)
There was a call to the int, int constructor which I hadn’t noticed, yet it compiled and ran but invoked the double, double version, quite properly causing an exception handler I had written to be thrown. MyClass doesn’t extend any other class.
By what rules does Java cause this invisible automatic cast to happen?
By this rule: http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.2
It’s a widening conversion.