Skip to content

Commit fc313d6

Browse files
committed
add further requirements to be sure Provider class can be instantiated
1 parent 0d6216a commit fc313d6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cucumber-picocontainer/src/main/java/io/cucumber/picocontainer/PicoFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,17 @@ private static boolean hasDefaultConstructor(Class<?> clazz) {
117117

118118
@SuppressWarnings("unchecked")
119119
private static Class<Provider> checkProperPicoProvider(Class<?> clazz) {
120-
if (!isProvider(clazz) || !hasDefaultConstructor(clazz)) {
120+
if (!isProvider(clazz) || !isInstantiable(clazz) || !hasDefaultConstructor(clazz)) {
121121
throw new CucumberBackendException(String.format("" +
122122
"Glue class %1$s was annotated with @CucumberPicoProvider; marking it as a candidate for declaring a"
123123
+
124124
"PicoContainer Provider instance. Please ensure that all the following requirements are satisfied:\n"
125125
+
126126
"1) the class implements org.picocontainer.injectors.Provider\n" +
127-
"2) the class provides a default constructor.",
127+
"2) the class is public\n" +
128+
"3) the class is not abstract\n" +
129+
"4) the class provides a default constructor\n" +
130+
"5) if nested, the class is static.",
128131
clazz.getName()));
129132
}
130133
return (Class<Provider>) clazz;

0 commit comments

Comments
 (0)