RFR: 8334466: Ambiguous method call with generics may cause FunctionDescriptorLookupError

Vicente Romero vromero at openjdk.org
Tue Jul 23 14:20:01 UTC 2024


javac is crashing while compiling code like:


import java.util.List;

class Test {
    void m() {
        List<X> list = List.of(new X());
        test(list.get(0));
    }

    void test(A<?> a) { }
    void test(B<?> b) { }

    interface A<T extends A<T>> { T a(); }
    interface B<T extends B<T>> { T b(); }
    class X implements A<X>, B<X> {
        public X a() { return null; }
        public X b() { return null; }
    }
}

this is because method Types::findDescriptorType, which is invoked in this particular case, throws `FunctionDescriptorLookupError` which is an internal exception that is supposed to be captured by the client. The client then should interpret the exception depending on the context. This was not happening in the code path stressed by this test case. This PR is fixing this issue

TIA

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

Commit messages:
 - adding comment
 - 8334466: Ambiguous method call with generics may cause FunctionDescriptorLookupError

Changes: https://git.openjdk.org/jdk/pull/20300/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20300&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8334466
  Stats: 38 lines in 3 files changed: 35 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/20300.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20300/head:pull/20300

PR: https://git.openjdk.org/jdk/pull/20300


More information about the compiler-dev mailing list