FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ws-win-gpb 2.6.34.8-0.2-desktop #1 SMP PREEMPT 2011-04-06 18:11:26 +0200 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
define an inner class in a base class
instantiate the inner class in a derived class
with lambda "InnerClass::new" and an exception occurs
exception is
Caused by: java.lang.invoke.LambdaConversionException: Type mismatch in captured lambda parameter 0: expecting class Foo, found class FooBase
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Foo.java
java Foo
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no exception
ACTUAL -
Exception:
Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
at java.lang.invoke.CallSite.makeSite(CallSite.java:328)
at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:296)
at Foo.run(Foo.java:20)
at Foo.main(Foo.java:13)
Caused by: java.lang.invoke.LambdaConversionException: Type mismatch in captured lambda parameter 0: expecting class Foo, found class FooBase
at java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:256)
at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:303)
at java.lang.invoke.CallSite.makeSite(CallSite.java:289)
... 3 more
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.List;
import java.util.ArrayList;
class FooBase {
class TestString {
String str;
TestString(String strin) {
str = strin;
}
}
}
class Foo extends FooBase {
public static void main(String[] args) {
new Foo().run();
}
Foo() {
super();
}
void run() {
List<String> list = new ArrayList<>();
list.stream().forEach(TestString::new);
}
}
---------- END SOURCE ----------