के साथ "निरंतर पूल इंडेक्स पर गलत प्रकार" अपवाद प्राप्त करना मैं ककड़ी की जावा 8 बोली के लिए एक उदाहरण प्रोजेक्ट सेट अप करने का प्रयास कर रहा हूं। मेरी समस्या यह है कि मुझे यह नहीं चल रहा है। मुझे हमेशा अपवादों का निम्नलिखित पदानुक्रम मिलता है:हमेशा ककड़ी-जावा 8
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.068 sec <<< FAILURE! - in soy.wimmer.CucumberIT
Feature: Cucumber with Java8 Time elapsed: 0.051 sec <<< ERROR!
cucumber.runtime.CucumberException: Failed to instantiate class soy.wimmer.CucumberStepdefs
[…]
Caused by: java.lang.reflect.InvocationTargetException: null
[…]
Caused by: cucumber.runtime.CucumberException: java.lang.IllegalArgumentException: Wrong type at constant pool index
[…]
Caused by: java.lang.IllegalArgumentException: Wrong type at constant pool index
at sun.reflect.ConstantPool.getMemberRefInfoAt0(Native Method)
at sun.reflect.ConstantPool.getMemberRefInfoAt(ConstantPool.java:47)
at cucumber.runtime.java8.ConstantPoolTypeIntrospector.getTypeString(ConstantPoolTypeIntrospector.java:37)
at cucumber.runtime.java8.ConstantPoolTypeIntrospector.getGenericTypes(ConstantPoolTypeIntrospector.java:27)
at cucumber.runtime.java.Java8StepDefinition.<init>(Java8StepDefinition.java:45)
at cucumber.runtime.java.JavaBackend.addStepDefinition(JavaBackend.java:162)
at cucumber.api.java8.En.Given(En.java:190)
at soy.wimmer.CucumberStepdefs.<init>(CucumberStepdefs.java:8)
[…]
Results :
Tests in error:
Failed to instantiate class soy.wimmer.CucumberStepdefs
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
मुझे कोई संकेत नहीं है कि मुझे यह त्रुटि क्यों मिलती है और न ही इसे कैसे ठीक किया जाए।
मैंने मैवेन प्रोजेक्ट में सबकुछ पैक किया है। लेआउट कि तरह है:
./src/test/java/soy/wimmer/CucumberIT.java
./src/test/java/soy/wimmer/CucumberStepdefs.java
./src/test/resources/cucumber/cucumber-java8.feature
./pom.xml
निर्भरता मैं pom.xml में शामिल हैं:
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java8</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
इसके अतिरिक्त pom.xml केवल संकलक और फेल सेफ प्लगइन लोड करता है।
CucumberIT.java की मेरी परिभाषा:
package soy.wimmer;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:cucumber")
public class CucumberIT {
}
मेरे सुविधा परिभाषा:
Feature: Cucumber with Java8
As a developer
I want to use Cucumber-java8
So that I have nicer step definitions
Scenario: Let's try it
Given I have some dummy code
When I try to test it
Then it should work with cucumber-java8
और ये मेरे कदम परिभाषाएं दी गई हैं:
package soy.wimmer;
import cucumber.api.PendingException;
import cucumber.api.java8.En;
public class CucumberStepdefs implements En {
public CucumberStepdefs() {
Given("^I have some dummy code$",() -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
When("^I try to test it$",() -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
Then("^it should work with cucumber-java(\\d+)$", (Integer arg1) -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
}
}
किसी भी विचार है कि मैं क्या कर रहा हूँ यहाँ गलत है?
ठीक है, अपवाद संदेश में वास्तविक प्रकार की कमी है, लेकिन मुझे लगता है कि यह '18' टाइप है और [यह उत्तर] (http://stackoverflow.com/a/23625762/2711488) लागू होता है। संक्षेप में, ऐसा लगता है कि ककड़ी जावा 8 के लिए उपयुक्त नहीं है, वास्तव में, यह 100% जावा 7 संगत भी नहीं है ... – Holger
यह एक Invokedynamic हो सकता है क्योंकि कक्षा के निर्माता में लैम्ब्डा अभिव्यक्तियां हैं। लेकिन मैंने pom.xml में स्रोत और लक्ष्य संस्करण 1.8 के लिए कंपाइलर को कॉन्फ़िगर किया है और यह चरण परिभाषाएं है और इसलिए स्थानीय स्तर पर संकलित एक वर्ग है, नहीं? –
जैसा कि लिंक किए गए उत्तर में कहा गया है, मुद्दा * कंपाइलर नहीं है।समस्या यह है कि एक * रनटाइम * उपकरण है जो संकलित कक्षा फ़ाइल, उर्फ बाइटकोड को संसाधित करने का प्रयास करता है। 'IllegalArgumentException' को फेंकने वाली विधि को देखें। – Holger