You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
The problem is reproducible when a source file is compiled partially against previously compiled classes.
Consider an example:
@EActivity
class Base {
// class body
}
@EActivity
class Sub extends Base {
// class body
}
If both sources are compiled together, the generation result is as expected. If class Sub is changed and compiled against previously compiled Base class, the generated code lacks stuff that corresponds to Base class.
Debugging processor's sources shows that com.googlecode.androidannotations.model.ModelExtractor assumes that instances of javax.lang.model.type.DeclaredType have correctly overridden equals() and hashCode() methods, which is not true for some of javac's internal data structures (at least for com.sun.tools.javac.code.Type$ClassType).
Please consider method in com.googlecode.androidannotations.model.ModelExtractor:
private void extractAnnotations(AnnotationElementsHolder extractedModel, Set<DeclaredType> annotationTypesToCheck, TypeElement rootTypeElement, Element ancestorEnclosedElement)
The following check
if (annotationTypesToCheck.contains(annotationType)) {
// code
}
does not pass, because annotationTypesToCheck contains one instance of @EActivity mirror, and "annotationType" reference points to another instance of the same mirror.
This definitely looks like javac problem, as all instances of DeclaredType are expected to correctly define equals() and hashCode(), but unfortunately this is unlikely be fixed in the nearest future and there are many already existing JDK installations with this problem.
My proposal is that AndroidAnnotationProcessor in this case (and in all similar cases) should use either String types or wrapper classes with correctly defined equals() and hashCode()
Meanwhile this problem makes the annotation processor virtually unusable in combination with javac compiler in all situations when the code is compiled only partially.
Please do not hesitate to contact me directly at eugene.zhuravlev (at) jetbrains.com if you have any additional questions
The text was updated successfully, but these errors were encountered:
Thank you for all these great details ! I've reproduced successfully
You are welcome! With all these quick fixes from you more and more people
will benefit from the tool.
Is that issue related to the support of Intellij IDEA ?
Yes. One of implications for me personally is that there will be less
complains in our issue tracker that "we do not work with AndroidAnnotations
properly" :-)
The problem is reproducible when a source file is compiled partially against previously compiled classes.
Consider an example:
If both sources are compiled together, the generation result is as expected. If class Sub is changed and compiled against previously compiled Base class, the generated code lacks stuff that corresponds to Base class.
Debugging processor's sources shows that com.googlecode.androidannotations.model.ModelExtractor assumes that instances of javax.lang.model.type.DeclaredType have correctly overridden equals() and hashCode() methods, which is not true for some of javac's internal data structures (at least for com.sun.tools.javac.code.Type$ClassType).
Please consider method in com.googlecode.androidannotations.model.ModelExtractor:
The following check
does not pass, because annotationTypesToCheck contains one instance of @EActivity mirror, and "annotationType" reference points to another instance of the same mirror.
This definitely looks like javac problem, as all instances of DeclaredType are expected to correctly define equals() and hashCode(), but unfortunately this is unlikely be fixed in the nearest future and there are many already existing JDK installations with this problem.
My proposal is that AndroidAnnotationProcessor in this case (and in all similar cases) should use either String types or wrapper classes with correctly defined equals() and hashCode()
Meanwhile this problem makes the annotation processor virtually unusable in combination with javac compiler in all situations when the code is compiled only partially.
Please do not hesitate to contact me directly at eugene.zhuravlev (at) jetbrains.com if you have any additional questions
The text was updated successfully, but these errors were encountered: