cucumber/cucumber-jvm — Issue #102: abstract Stepdef classes causes a crash during initialization
Author: avh4
Created: 2011-12-04 19:56:24+00:00
State: open

The existence of an abstract class with a `@When`, `@Then` or `@Given` annotation causes cucumber-jvm to crash.

I would expect such classes to be silently ignored.

```java
public abstract class MyStepdefsBase {
@When("^the users starts the application$")
public void startApplication() {
// ...
}
}

public class ExtendedStepdefs extends MyStepdefsBase {
@When("^three uses log in$")
public void multipleUserLogin() {
// ...
}
}
```

Having the above in a project will cause the following crash:

```
org.picocontainer.injectors.AbstractInjector$NotConcreteRegistrationException: Bad Access: 'MyStepdefsBase' is not instantiable
at org.picocontainer.injectors.AbstractInjector.checkConcrete(AbstractInjector.java:86)
at org.picocontainer.injectors.AbstractInjector.(AbstractInjector.java:67)
at org.picocontainer.injectors.SingleMemberInjector.(SingleMemberInjector.java:43)
at org.picocontainer.injectors.ConstructorInjector.(ConstructorInjector.java:104)
at org.picocontainer.injectors.ConstructorInjection.createComponentAdapter(ConstructorInjection.java:59)
at org.picocontainer.injectors.AdaptingInjection.defaultInjectionAdapter(AdaptingInjection.java:121)
at org.picocontainer.injectors.AdaptingInjection.createComponentAdapter(AdaptingInjection.java:107)
at org.picocontainer.behaviors.AbstractBehaviorFactory.createComponentAdapter(AbstractBehaviorFactory.java:44)
at org.picocontainer.behaviors.Caching.createComponentAdapter(Caching.java:46)
at org.picocontainer.DefaultPicoContainer.addComponent(DefaultPicoContainer.java:536)
at org.picocontainer.DefaultPicoContainer.addComponent(DefaultPicoContainer.java:501)
at org.picocontainer.DefaultPicoContainer.addComponent(DefaultPicoContainer.java:488)
at cucumber.runtime.java.picocontainer.PicoFactory.createInstances(PicoFactory.java:17)
at cucumber.runtime.java.JavaBackend.buildWorld(JavaBackend.java:41)
at cucumber.runtime.Runtime.buildBackendWorlds(Runtime.java:124)
at cucumber.runtime.World.buildBackendWorldsAndRunBeforeHooks(World.java:34)
at cucumber.runtime.model.CucumberScenario.buildWorldAndRunBeforeHooks(CucumberScenario.java:30)
at cucumber.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:51)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at cucumber.junit.Cucumber.run(Cucumber.java:111)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.remove(ArrayList.java:387)
at cucumber.junit.JUnitReporter.match(JUnitReporter.java:30)
at cucumber.runtime.World.runStep(World.java:86)
at cucumber.runtime.model.CucumberScenario.runStep(CucumberScenario.java:72)
at cucumber.junit.ExecutionUnitRunner.runChild(ExecutionUnitRunner.java:78)
at cucumber.junit.ExecutionUnitRunner.runChild(ExecutionUnitRunner.java:18)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at cucumber.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:68)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at cucumber.junit.Cucumber.run(Cucumber.java:111)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

java.lang.IllegalStateException: Cannot stop. Current container state was: CONSTRUCTED
at org.picocontainer.lifecycle.DefaultLifecycleState.stopping(DefaultLifecycleState.java:72)
at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java:787)
at cucumber.runtime.java.picocontainer.PicoFactory.disposeInstances(PicoFactory.java:23)
at cucumber.runtime.java.JavaBackend.disposeWorld(JavaBackend.java:46)
at cucumber.runtime.Runtime.disposeBackendWorlds(Runtime.java:130)
at cucumber.runtime.World.runAfterHooksAndDisposeBackendWorlds(World.java:63)
at cucumber.runtime.model.CucumberScenario.runAfterHooksAndDisposeWorld(CucumberScenario.java:76)
at cucumber.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:70)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at cucumber.junit.Cucumber.run(Cucumber.java:111)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
```