On Wed, 12 Feb 2025 19:17:52 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

> In that example, the setFoo methods are not overridden but overloaded, so all 
> of them are accessible at runtime. When you pass null, Java tries to select 
> the most specific type, which is Integer. You can change that by casting null 
> to Number. see 
> https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.12.2.5

Yes, I know this. 

The question is why `Test$DC.setFoo(java.lang.Number)`  is set as default 
setter, while the default call goes to `Test$AC.setFoo()`? Is this documented, 
or is there specification? I see that no tests exist for this, so it's not 
clear what is the expected behaviour.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/23443#issuecomment-2654710703

Reply via email to