-
Bug
-
Resolution: Fixed
-
P3
-
None
-
repo-valhalla
public primitive class CheckRefLambda.val {
int theInteger;
public CheckRefLambda(int newValue) {
theInteger = newValue;
}
public Supplier<CheckRefLambda.ref> makeCopier() {
return () -> new CheckRefLambda(this.theInteger + 1);
}
// ...
}
if javac generates the following code where the receiver type is a primitive reference type and the implementation type is the primitive value type of the same primitive class, LambdaConversionException will be thrown:
```
public java.util.function.Supplier<X> makeCopier();
descriptor: ()Ljava/util/function/Supplier;
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokedynamic #7, 0 // InvokeDynamic #0:get:(LX;)Ljava/util/function/Supplier;
6: areturn
LineNumberTable:
line 12: 0
LocalVariableTable:
Start Length Slot Name Signature
0 7 0 this QX;
```
won't bootstrap the lambda, but fails with:
java.lang.BootstrapMethodError: bootstrap method initialization exception
at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:188)
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:315)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:281)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:271)
at CheckRefLambda.makeCopyer(CheckRefLambda.java:42)
at CheckRefLambda.main(CheckRefLambda.java:47)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.invoke.LambdaConversionException: Invalid receiver type primitive CheckRefLambda; not a subtype of implementation type primitive CheckRefLambda
at java.base/java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:271)
at java.base/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:340)
at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:134)
... 11 more
- relates to
-
JDK-8273301 [lworld] Bootstrap of instance-capturing lambda fails for reference favoring primitive types
-
- Closed
-