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

BootstrapMethodError when capturing constructor ref to local classes

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P2
    • Resolution: Fixed
    • 8, 8-repo-lambda
    • 8
    • core-libs
    • 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
      ]]>

      Attachments

        Issue Links

          Activity

            People

              rfield Robert Field
              briangoetz Brian Goetz
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: