Closed mpkorstanje closed 3 years ago
A variation of this problem also prevents DataTableType
registrations from working on Java 12+.
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()
.
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: https://github.com/cucumber/cucumber-jvm/issues/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.
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?
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.
Hi guys, any news on this? We're stuck upgrading jdk...
@aznavour not unless you are looking to contribute. Though you'd have to start with https://github.com/jhalterman/typetools/issues/52.
Same here waiting on this to use jdk 14 or 15
The Cucumber team does not have resources available to fix this. We will deprecate cucumber-java8 at some point in the future. See: https://github.com/cucumber/cucumber-jvm/issues/2174
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...
Good point. Could you create an issue in https://github.com/cucumber/docs and reference:
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 https://github.com/jhalterman/typetools/issues/52,cucumber-java
should not be affected. They're separate modules since v4.0.0.Resolving this requires fixing https://github.com/jhalterman/typetools/issues/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.