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.*
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.*
- blocks
-
JDK-8012557 Implement lambda methods on interfaces as private
- Closed
-
JDK-8011311 Lambda: Support Private concrete methods in interfaces
- Closed
- duplicates
-
JDK-8011311 Lambda: Support Private concrete methods in interfaces
- Closed