Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7087658

MethodHandles.Lookup.findVirtual is confused by interface methods that are multiply inherited

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Backports

        Description

        Given this test case:

        interface A {
           Iterable m(List<String> ls);
        }

        interface B {
           Iterable<String> m(List l);
        }

        interface AB extends A, B { }

        interface AA extends A { }


        If I do:

               MethodHandle mh1 = MethodHandles.lookup().findVirtual(A.class, "m", MethodType.methodType(Iterable.class, List.class));
               MethodHandle mh2 = MethodHandles.lookup().findVirtual(B.class, "m", MethodType.methodType(Iterable.class, List.class));
               MethodHandle mh3 = MethodHandles.lookup().findVirtual(AB.class, "m", MethodType.methodType(Iterable.class, List.class));
               MethodHandle mh4 = MethodHandles.lookup().findVirtual(AA.class, "m", MethodType.methodType(Iterable.class, List.class));

        I would expect all the lookups to succeed. However, only lookups for A, B, and AA succeed; lookups for AB fail with

         java.lang.NoSuchMethodException: no such method: AB.m(List)Iterable

        It fails the same way when the generics are removed. So it appears to be a problem with an interface multiply inheriting the same method and not overriding it.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  twisti Christian Thalinger
                  Reporter:
                  briangoetz Brian Goetz
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  9 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: