kohsuke / metainf-services

Generates META-INF/services files automatically
http://metainf-services.kohsuke.org/
69 stars 26 forks source link

Class loading problem during processing #8

Open dmlloyd opened 10 years ago

dmlloyd commented 10 years ago

If the annotation processor isn't linked with the compile-time dependencies of whatever you're building, then you will get CNFEs when it runs because of usage of the javax.lang.model.element.Element#getAnnotation method. The fix is to use the much more boring javax.lang.model.element.Element#getAnnotationMirrors method instead, and iterate the list until the right annotation is found, and then use the returned TypeMirror of the AnnotationValue to do type determination.

dmlloyd commented 10 years ago

I've pushed up a fix here https://github.com/dmlloyd/metainf-services/tree/safe-apis which depends on my patch for #6 / #7 - use it if you want to, or don't.

jglick commented 10 years ago

Did not follow all of https://github.com/dmlloyd/metainf-services/commit/0d2f2a9b4495c627332dc06c264fcce943b175b5 (seems like some method inlining along with the primary change), but looks right to me.