New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StackOverflow in AbstractExtensionFinder.findExtensionAnnotation() #363
Comments
@metaschell
I think that for the moment this is the best solution (simple and without to many modifications). Can you submit a PR? In the future I hope to avoid reflection for this part of PF4J (find extensions). We have all the information (extensions classes, extensions orders, extensions points) at compilation time (in annotation processor) and we can reuse them at runtime (see #207). |
@metaschell |
@decebals I will likely not have time in the next two weeks so if you would like to have that fixed by then, feel free to go ahead. We have a local workaround in place |
This is only the case if you actually use the annotation processor in the build which is not necessarily always the case... In our project we basically only use a custom ServiceLoader-based ExtensionFinder now. |
Nice, thanks for fixing! |
I create an extension and registered it using the
extension.idx
file and the class is properly loaded. My class has no@Extension
annotation though (this should stay like this, I manually created theextensions.idx
file), but when scanning for the@Extension
annotation inorg.pf4j.AbstractExtensionFinder.findExtensionAnnotation(Class<?>)
thefindExtensionAnnotation()
method is calling itself recursively. Theoretically, it should simply returnnull
if there is no such annotation, but the problem here is that if there are any other annotations this leads to a StackOverflowError as any other annotation would have any of thejava.lang.annotations
annotations such as@Scope
,@Retention
, and@Documented
which in turn uses these three annotations again:@MyAnnotation -> @Retention -> @Documented -> @Retention -> @Documented ...
A potential solution would be to not do the recursion for any annotation in the java.lang.* packages.
BTW, it is difficult to work around this problem as all methods are private so they cannot be overridden in order to catch the problem and move on. I understand that this is a philosophical question regarding hiding vs. (partially) exposing internals, but currently there is no way around that unless overriding all of
org.pf4j.AbstractExtensionFinder.find(String)
with all related methods...(Partial) Stacktrace:
Example class:
(note the class would rather implement an interface extending ExtensionPoint, but that should not make a difference here)
Registration file (
META-INF/extensions.idx
)The text was updated successfully, but these errors were encountered: