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

invokespecial to a private super-interface instance (default) method gives NoSuchMethodError

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • hs25
    • None
    • hotspot
    • None
    • generic
    • generic

      This appears to because resolution seems to be based on the current class.

      That in:
         final class IDo$$Lambda$1 extends java.lang.invoke.MagicLambdaImpl implements IDo

      This call in val():
               4: invokespecial #19 // Method IDo.lambda$guts$0:()V

      To this method in IDo:
        private void lambda$guts$0();
          descriptor: ()V
          flags: ACC_PRIVATE, ACC_SYNTHETIC

      Fails with:
        Exception in thread "main" java.lang.NoSuchMethodError: IDo$$Lambda$1.lambda$guts$0()V
              at IDo$$Lambda$1.val(Unknown Source)

      It appears to be trying to find the class in the current class rather than the class containing the private method.

      A slightly altered version where IDo$$Lambda$1 does not implement IDo (and thus the bytecodes look identical) succeeds.

      Attachments:
        Source files: Source_*.java
        javap output: *.javap
        Calling class: IDoLambda_*.javap (this is the generated output class for a lambda, but that doesn't matter in this case)
        Called interface: IDo_*.javap
        Code/output demonstrating the bug: *_Fail.*
        Code/output of the version that works: *_Succeed.*




        1. IDo_Fail.javap
          4 kB
          Robert Field
        2. IDo_Succeed.javap
          4 kB
          Robert Field
        3. IDoLambda_Fail.javap
          2 kB
          Robert Field
        4. IDoLambda_Succeed.javap
          2 kB
          Robert Field
        5. Source_Fail.java
          0.3 kB
          Robert Field
        6. Source_Succeed.java
          0.3 kB
          Robert Field

            acorn Karen Kinnear (Inactive)
            rfield Robert Field (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: