JDK-8238213: javac emits wrong error when calling an non-static overloaded method from static

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Oct 8 10:54:14 UTC 2020


Your example works in Java 7.

I agree that the compatibility impact of fixing something like this 
might be non trivial.

Maurizio

On 08/10/2020 10:44, B. Blaser wrote:
> Testing a few more, I note that a discrepancy with the JLS in this
> area might have deeper consequences beyond wrong diagnostics,
> consider:
>
> public class Test {
>    public static void main(String[] args) {
>      test((Double)5.0);
>    }
>
>    void test(Number n) {
>      System.out.println(Number.class);
>    }
>
>    static void test(Double... d) {
>      System.out.println(Double.class);
>    }
> }
>
> JDK16 currently resolves and runs 'test(Double...)' instead of raising
> a static error as mandated by §15.12 and according to the suggested
> fix.
> I'm not sure where to find JDK7 x86_64 binaries, so maybe you could
> try this one too and share your thoughts?
>
> Bernard
>
> On Mon, 5 Oct 2020 at 12:00, Maurizio Cimadamore
> <maurizio.cimadamore at oracle.com> wrote:
>> Thanks - I've reset the fix version field and reassigned to Vicente - he
>> can perhaps take a look and see what needs to be done to integrate this
>> (this is an area where we would at least need some good testing
>> coverage, perhaps by using the overload test framework that was put in
>> few years ago - see [1] for an example).
>>
>> Maurizio
>>
>> [1] -
>> https://urldefense.com/v3/__https://github.com/openjdk/jdk/blob/master/test/langtools/tools/javac/resolve/tests/InnerOverOuter.java__;!!GqivPVa7Brio!NroBbo6P7_xLMhNZVOf6wYXN3s5oPHH0YN0-aWr9MOW5Sah-sYVAJOG7vakveKhg7XUQRR0$


More information about the compiler-dev mailing list