Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage does not support lambda expression #85

Closed
riadmaouchi opened this issue Jul 1, 2015 · 3 comments
Closed

Stage does not support lambda expression #85

riadmaouchi opened this issue Jul 1, 2015 · 3 comments
Milestone

Comments

@riadmaouchi
Copy link

I have implemented a simple step with lambda-expression inside:

public class WhenStage<SELF extends WhenStage<SELF>> extends Stage<SELF> {
  public SELF test() {
        doAnswer(invocationOnMock -> null).when(mockedObject).myMethod();
        return self();
  }

When I launch the test, the following exception occurs:

[Stack Trace]

java.lang.ArrayIndexOutOfBoundsException: 19562
at com.thoughtworks.paranamer.BytecodeReadingParanamer$ClassReader.accept(BytecodeReadingParanamer.java:563)
at com.thoughtworks.paranamer.BytecodeReadingParanamer$ClassReader.access$200(BytecodeReadingParanamer.java:338)
at com.thoughtworks.paranamer.BytecodeReadingParanamer.lookupParameterNames(BytecodeReadingParanamer.java:103)
at com.thoughtworks.paranamer.BytecodeReadingParanamer.lookupParameterNames(BytecodeReadingParanamer.java:69)
at com.tngtech.jgiven.impl.util.ScenarioUtil.getParameterNames(ScenarioUtil.java:51)
at com.tngtech.jgiven.impl.util.ScenarioUtil.mapArgumentsWithParameterNames(ScenarioUtil.java:32)
at com.tngtech.jgiven.impl.ScenarioExecutor$MethodHandler.handleMethod(ScenarioExecutor.java:131)
at com.tngtech.jgiven.impl.intercept.StepMethodInterceptor.intercept(StepMethodInterceptor.java:44)
at

But if I replace lambda expression with anonymous class, all works fine.

@janschaefer janschaefer added this to the v0.7.3 milestone Jul 1, 2015
@janschaefer
Copy link
Contributor

Interesting. This is indeed a severe problem. It seems that the paranamer library does not work with Java 8.

@janschaefer
Copy link
Contributor

Ok. I have fixed the issue. However, it has a little drawback. In order to work for Java 8 correctly, you have to compile your test classes with the -parameters option of javac.

@janschaefer
Copy link
Contributor

Thanks for reporting, btw :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants