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

cucumber-java8 does not work on OpenJDK 12+ #1817

Closed
mpkorstanje opened this issue Nov 11, 2019 · 11 comments
Closed

cucumber-java8 does not work on OpenJDK 12+ #1817

mpkorstanje opened this issue Nov 11, 2019 · 11 comments

Comments

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Nov 11, 2019

When using OpenJDK 12+ in combination with cucumber-java8 users may experience class cast exceptions. See: Java+Cucumber execution error (java.lang.ClassCastException: class io.cucumber.docstring.DocString cannot be cast to class java.lang.String)

These occur because typetools is unable to read the parameter types from lambdas on OpenJDK 12+. See jhalterman/typetools#52,

cucumber-java should not be affected. They're separate modules since v4.0.0.

Resolving this requires fixing jhalterman/typetools#52 to make TypeTools to work on Java 12+.

Update

The Cucumber team does not have resources available to fix this. We will deprecate cucumber-java8 at some point in the future.

@mpkorstanje mpkorstanje added the 🐛 bug Defect / Bug label Nov 11, 2019
@mpkorstanje mpkorstanje added the 🙏 help wanted Help wanted - not prioritized by core team label Nov 17, 2019
@mpkorstanje mpkorstanje changed the title Cucumber Java8 depends on TypeTools which fails on OpenJDK 12 Cucumber Java8 ClassCastExceptions on OpenJDK 12 Nov 17, 2019
@mpkorstanje
Copy link
Contributor Author

A variation of this problem also prevents DataTableType registrations from working on Java 12+.

@bestbeforetoday
Copy link

In case it helps anyone else, I hit this problem with a project building with OpenJDK 11 when upgrading from cucumber-java8 version 4.7.0 to 5.4.0. I can work around the issue by changing the String parameter in the step definition lambda to a DocString and then grabbing the String from it in the step definition code using docString.getContent().

@bestbeforetoday
Copy link

The fix in PR #1902 seems to have broken Cucumber tests that were previously running fine in OpenJDK 11.0.4, despite the failure message saying:

This version of cucumber-java8 is not compatible with Java 12+
See: #1817

The line that was previously working in Java 11 and is now failing is:

Given("I have deployed a {word} Fabric network", (String tlsType) -> {

I see this problem with cucumber-java8 version 5.7.0.

@mpkorstanje
Copy link
Contributor Author

The fix in PR #1902 seems to have broken Cucumber tests that were previously running fine in OpenJDK 11.0.4

The test set contains comparable step definitions and the are executed successfully in CI on OpenJDK 11.0.2 and locally on OpenJDK 11.0.7. Would you be able to create an MCVE, preferably in the form a of a github repo?

@bestbeforetoday
Copy link

bestbeforetoday commented Jul 31, 2020

This always seemed to pass OK with Java 11 in our build pipeline, which is running Ubuntu 18.04. I only saw the failure on my local MacOS environment. Java 8 worked OK and that's what I typically use for local testing. By chance I've just tried those tests again with Java 11 and the tests are now passing unchanged. The dependency tree still shows io.cucumber:cucumber-java8:jar:5.7.0 but my Java runtime is now OpenJDK 11.0.8+10 (MacOS), which is the only difference I obviously see. I don't know if any of the transient dependencies of cucumber-java8 are different to when I ran previously.

@aznavour
Copy link

Hi guys, any news on this? We're stuck upgrading jdk...

@mpkorstanje
Copy link
Contributor Author

mpkorstanje commented Nov 23, 2020

@aznavour not unless you are looking to contribute. Though you'd have to start with jhalterman/typetools#52.

@plum117
Copy link

plum117 commented Nov 27, 2020

Same here waiting on this to use jdk 14 or 15

@mpkorstanje mpkorstanje changed the title Cucumber Java8 ClassCastExceptions on OpenJDK 12 cucumber-java8 does not work on OpenJDK 12+ Dec 3, 2020
@mpkorstanje mpkorstanje removed Hacktoberfest 🙏 help wanted Help wanted - not prioritized by core team 🐛 bug Defect / Bug labels Dec 3, 2020
@mpkorstanje
Copy link
Contributor Author

The Cucumber team does not have resources available to fix this. We will deprecate cucumber-java8 at some point in the future. See: #2174

@BreezeBlocksTool
Copy link

If it is planned for removal or at least no going to be compatible for java12+, it might be a good idea to say so in the cucumber documentation (https://cucumber.io/docs/installation/java/)... The java8 option is still the first one that's displayed... removing it or at least discouraging the user from using it would seem to be the right thing to do to avoid migrations from the lambda version to the other...

@mpkorstanje
Copy link
Contributor Author

Good point. Could you create an issue in https://github.com/cucumber/docs and reference:

#2279

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

No branches or pull requests

5 participants