8370800: Downgrade cant.attach.type.annotations diagnostics to warnings - #28018
8370800: Downgrade cant.attach.type.annotations diagnostics to warnings#28018cushon wants to merge 12 commits into
Conversation
|
👋 Welcome back cushon! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
|
So, overall, I am not convinced this is a good move. Yes, we have some existing cases where missing stuff produces just warnings in the class reader, but these are cases where annotations, or their attributes, are missing. Not when the actual field/method type is missing. I.e. in the test case, not producing an error for missing But, even if we decided to ignore the missing class error, the implementation is, sadly, wrong. We cannot just ignore the leads to: I think that if you really want to ignore the Second problem is that catching the |
|
Thanks very much for the review!
I had been thinking about it similarly, that it would be better to report and error and just add the missing transitive deps. I've heard feedback about a couple of cases where the code owners didn't want to do that, because the deps were only used for thinks like Overall it might make sense to move this back to a draft and collect more feedback in the bug.
Thanks! I experimented with doing that and it avoids the crash, and I have pushed those changes to the PR, but I realize that doesn't fully solve the issues you raised and this needs more thought and discussion.
Yes, I guess to continue with this approach of trying to recover from the I do think that's a somewhat rare issue. If these diagnostics did end up getting downgraded to warnings, compilations that are relying on accurate type annotation information would likely want to promote them to errors. And the examples in the bug weren't generally trying to read the type annotations, they just wanted compilation to succeed with incomplete classpaths. |
|
|
|
I added a comment to https://bugs.openjdk.org/browse/JDK-8370800 with some more analysis. I think the core of the new behaviour that is surprising and potentially undesirable is
I wonder if a better approach here is to continue to report That would mean that if the only place javac needing a missing class was to attach type annotations, a regular compilation would succeed, but a compilation with an annotation processor that tried to read those type annotations would still get a I have uploaded a new draft where @lahodaj do you think that approach might have any merit? |
I have been doing some more testing with this and it seems to work. I adjusted the initial approach to ensure it's only deferring attaching type annotations to symbol completion for non-class members, classes are still completed eagerly, which has the desired behaviour for type annotations and also avoids interactions with how annotation processing resets completers for class symbols. |
|
I have realized this approach doesn't work for all cases, because there are public APIs that allow accessing type annotations on an |
In particular,
in general I'm still unsure if using the completion mechanism for |
|
I was looking into this a bit more. I am afraid I don't see any really good solution. So, out of the not-so-good solutions, the original solution seems least problematic. (With the @jddarcy, what do you think? Sorry for the fuss. |
|
@jddarcy has indicated that a compatibility and specification (CSR) request is needed for this pull request. @cushon please create a CSR request for issue JDK-8370800 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
|
I am leaning towards holding off on changes here until there's a clear consensus about which of the approaches in is best. Are there any more thoughts on the approaches discussed in #28018 (comment)? I think using symbol completion has the most desirable behaviour, but completers have more implementation complexity and risk. Downgrading the diagnostics to warnings is easier to reason about, but doesn't as precisely address the problem. |
|
@cushon This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
/touch I've heard of at least one more recent example of a cant.attach.type.annotations diagnostic requiring a workaround. I think the symbol completion option here has the best ergonomics, but also still have concerns about the downsides of using field/method completers for this. I'd like to leave this open for a bit longer to keep thinking about it. |
|
@cushon The pull request is being re-evaluated and the inactivity timeout has been reset. |
|
@cushon This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
/touch |
|
@cushon The pull request is being re-evaluated and the inactivity timeout has been reset. |
|
@cushon This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
/touch |
|
@cushon The pull request is being re-evaluated and the inactivity timeout has been reset. |
|
@cushon This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
/touch |
|
@cushon The pull request is being re-evaluated and the inactivity timeout has been reset. |
|
@cushon This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
@cushon This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
|
/open |
|
@cushon This pull request is now open |
|
@cushon This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
/touch |
|
@cushon The pull request is being re-evaluated and the inactivity timeout has been reset. |
Hi, please consider this fix for JDK-8370800: Downgrade cant.attach.type.annotations diagnostics to warnings.
As discussed in the, this reduces the compatibility impact of these diagnostics for builds that deliberately omit transitive annotation dependencies, for example if they are only referenced through javadoc
@linktags, or by frameworks that conditionally load the classes.The PR changes the existing error diagnostic to an unconditional warning. Another alternative would be to make it an optional xlint diagnostic, perhaps as part of
-Xlint:classfile, or as another category.Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28018/head:pull/28018$ git checkout pull/28018Update a local copy of the PR:
$ git checkout pull/28018$ git pull https://git.openjdk.org/jdk.git pull/28018/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28018View PR using the GUI difftool:
$ git pr show -t 28018Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28018.diff
Using Webrev
Link to Webrev Comment