Details
-
Bug
-
Resolution: Fixed
-
P2
-
8, 8-repo-lambda
-
b89
-
generic
-
generic
-
Verified
Description
When capturing a constructor ref to a local class, as in this example from java.util.stream.MatchOps:
public static TerminalOp<Long, Boolean> makeLong(LongPredicate predicate, MatchKind matchKind) {
class MatchSink extends BooleanTerminalSink<Long> implements Sink.OfLong {
MatchSink() {
super(matchKind);
}
@Override
public void accept(long t) {
}
}
return new MatchOp<>(StreamShape.LONG_VALUE, matchKind, MatchSink::new);
}
Capture fails at runtime with a BootstrapMethodError that ultimately is caused by:
Caused by: java.lang.invoke.LambdaConversionException: Incorrect number of parameters for static method newinvokespecial java.util.stream.MatchOps$1MatchSink.<init>:(MatchKind,Predicate)void; 0 captured parameters, 0 functional interface method parameters, 2 implementation parameters
at java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:189)
at java.lang.invoke.LambdaMetafactory.metaFactory(LambdaMetafactory.java:190)
at java.lang.invoke.CallSite.makeSite(CallSite.java:283)
... 23 more
]]>
public static TerminalOp<Long, Boolean> makeLong(LongPredicate predicate, MatchKind matchKind) {
class MatchSink extends BooleanTerminalSink<Long> implements Sink.OfLong {
MatchSink() {
super(matchKind);
}
@Override
public void accept(long t) {
}
}
return new MatchOp<>(StreamShape.LONG_VALUE, matchKind, MatchSink::new);
}
Capture fails at runtime with a BootstrapMethodError that ultimately is caused by:
Caused by: java.lang.invoke.LambdaConversionException: Incorrect number of parameters for static method newinvokespecial java.util.stream.MatchOps$1MatchSink.<init>:(MatchKind,Predicate)void; 0 captured parameters, 0 functional interface method parameters, 2 implementation parameters
at java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:189)
at java.lang.invoke.LambdaMetafactory.metaFactory(LambdaMetafactory.java:190)
at java.lang.invoke.CallSite.makeSite(CallSite.java:283)
... 23 more
]]>
Attachments
Issue Links
- blocks
-
JDK-8014316 Use Method Refs in j.u.stream.MatchOps
- Closed