What is the reason for checking the amount of annotations on the classes
See original GitHub issueprivate void checkAnnotationsEqual(Class<?> stepClassWithSpringContext, Class<?> stepClass) {
Annotation[] annotations1 = stepClassWithSpringContext.getAnnotations();
Annotation[] annotations2 = stepClass.getAnnotations();
if (annotations1.length != annotations2.length) {
throw new CucumberException("Annotations differs on glue classes found: " +
stepClassWithSpringContext.getName() + ", " +
stepClass.getName());
}
for (Annotation annotation : annotations1) {
if (!isAnnotationInArray(annotation, annotations2)) {
throw new CucumberException("Annotations differs on glue classes found: " +
stepClassWithSpringContext.getName() + ", " +
stepClass.getName());
}
}
}
What is the technical reason for this?
This check has broken again the compatibility…
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Annotations in Java - GeeksforGeeks
Annotations help to associate metadata (information) to the program elements i.e. instance variables, constructors, methods, classes, etc.
Read more >Detecting the present annotations within the given object ...
First you need to have retention policy on your annotations so you can read them with reflection @Retention(RetentionPolicy.
Read more >An Introduction to Annotations and Annotation Processing in ...
Annotations provide information to a program at compile time or at runtime based on which the program can take further action.
Read more >Annotating a Text - Reading and Study Strategies
Annotating means you are doing the hard work while you read, allowing you to reference your previous work and have a clear jumping-off...
Read more >Java Annotations - Jenkov.com
A Java annotation is a small comment-like construct you can insert before class, method and field declarations. Annotations can be used to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To make the spring transactions (#637) and auto-wiring of one stepdef class to another (which you know of https://github.com/cucumber/cucumber-jvm/issues/569#issuecomment-26699067), the SpringFactory will create bean definitions for all the glue classes in the context defined by one (the first one found) glue class with a
@ContextConfiguration/@ContextHierachy
annotation. As SpringFactory (after #711) works, this one class is the only class that Spring will be aware of and therefor its annotations are applied globally (so to say). This guard is there to prevent the any problems caused by silently not using the annotations the user thinks will be used, it is essentially saying “this won’t work as you think, so let’s not continue”.Is it possible to allow different context definitions on different glue classes? Maybe, but it seems very complex. Is it possible to allow different annotations, but the same context definition, on different glue classes? Maybe not as complex as allowing different contexts, but still complex. At least it looks like this to me.
Links to some discussions about this: https://github.com/cucumber/cucumber-jvm/pull/711#discussion_r12776747 on the mailing list
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.