-
Notifications
You must be signed in to change notification settings - Fork 121
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
Adding @Retention(RetentionPolicy.RUNTIME) to a java annotation does not correctly recompile downstream classes #630
Comments
The same root cause also causes undercompilation when an annotation is removed, or when it's This should be fixed by extending
|
our We should be able to port this upstream change: clarkware/jdepend@e8271a2?ts=4 (but see also the next two commits in the file's history, which fix up the added note that the sources have mixed tabs & spaces 🙀, hence I added the |
zinc/internal/zinc-classfile/src/main/scala/sbt/internal/inc/classfile/Parser.scala Lines 27 to 28 in 707d949
jdepend switched to the MIT License |
some notes:
so far I wrote a passing test (that tests something involving a dependency between two Java source files that's already handled correctly), then turned it into a failing test that actually tests the right thing, so now I'm ready to embark on an actual fix
|
Porting the jdepend changes isn't entirely straightforward, because our version of Before trying to get the end-to-end scripted test to pass, I should add one or more unit tests to
|
The changes to jdepend only handle @retronym I would have thought that |
We should consider them. I’m not familiar with the goals of j depend, so
not sure if it’s a conscious choice or an oversight.
|
Another weird thing about the upstream JDepend code is that most of the file uses Dale helped me understand aspects of the zinc scripted tests that were puzzling to me; my eventual PR will improve the documentation on that. |
I have the classfile parser reading annotations, and that is sufficient to cause the But although it's necessary to fix Haoyi's scenario ( We also need to change zinc to consider the change to |
What determines what an API change is?
#53 seems to be the last time this stuff was hacked on, primarily 0f77be9 and c9e365b As for sameness of APIs: Static annotations The phrase "static annotation" used in these files and commits was new to me, or at least I hadn't seen it in a long time. This isn't Java terminology, but Scala terminology:
so I think that's out of bounds for me at the moment; I'm focusing on Java-defined annotations. But the fact that The following comment in // The compiler only pickles static annotations, so only include these in the API.
// This way, the API is not sensitive to whether we compiled from source or loaded from classfile.
// (When looking at the sources we see all annotations, but when loading from classes we only see the pickled (static) ones.) This was added by Martin Duhemm in 3792b80 from #630, but he was porting sbt/sbt@d32a0ea and sbt/sbt@698902b (by Krzysztof and Adriaan) — I feel like those commits may be overzealously ignoring annotations that don't extend |
I think I was barking up the wrong tree looking at My next idea for a fix plan is as follows. First, let's back up a bit and think about what we're trying to do here. We have an annotation In normal user code the presence or absence of an annotation on a definition is not an API change and doesn't require recompilation downstream. The most targeted fix possible would say: "addition, removal, or change of the But being quite that targeted is probably overkill. We could loosen it one step and say, "any changes to the annotations on an annotation type declaration causes recompilation downstream". But why not go further and say, "if the classfile parser notices any change at all to an annotation type declaration, recompile downstream". Technically this could cause overcompilation in some cases, but changes to a Java-declared annotation is an unusual case, and overcompilation isn't so bad (it's wasteful but doesn't affect correctness), so I think we could favor simplicity of implementation here. An example where a similar decision was made is
I'm proposing making a similar decision here — err on the side of caution, assume the API changed. How to implement? I haven't done much digging on that yet, but my best guess at the moment is to take |
My PR, #1079, is exactly along the lines of my last remarks above. |
sbt.version=1.2.6
The text was updated successfully, but these errors were encountered: