-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8359596: Behavior change when both -Xlint:options and -Xlint:-options flags are given #25840
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back acobbs! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@archiecobbs The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
/csr needed |
@jddarcy has indicated that a compatibility and specification (CSR) request is needed for this pull request. @archiecobbs please create a CSR request for issue JDK-8359596 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
The extra checks for "-Xlint:none" are needed now because of JDK-8352612, which changed the behavior of "-Xlint:none" to no longer imply "-nowarn", which allowed the affected warnings to get away with skipping that check.
Adding Possibly at a later stage we should centralize all the handling using an EnumSet which is populated only once before the compiler is invoked. The behaviour should be documented in the javac documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally agree with these changes, but I'm not sure that the code in Lint
(which is not shown in this diff as it has not changed) really adheres to the policy described in the JBS issue that "last option should win". What Lint seems to do is to compute an initial set, like follows:
- if
none
is found, start from the empty set - if
all
is found, start from the "everything" set - if neither is found, start from a "predefined" set which contains some default categories
After that, the initial set is augmented (or reduced) based on the explicit enable/disable options.
I see at least two issues in this logic:
- how is the initial set determined if both
all
andnone
are specified? The "last win" policy might suggest that we use the last of these to determine the initial set, but the code doesn't do that, and I think it gives precedence toall
. - what if the same category is both enabled and disabled? Well, again, the code doesn't really apply a "last win" policy -- instead, for each category, we do this:
// Look for specific overrides
for (LintCategory lc : LintCategory.values()) {
if (options.isExplicitlyEnabled(Option.XLINT, lc)) {
values.add(lc);
} else if (options.isExplicitlyDisabled(Option.XLINT, lc)) {
values.remove(lc);
}
}
That is, for each category we check if it's enabled -- if so we add it to the set. Otherwise if it's disabled, we remove it from the set. So, if a category is both enabled and disabled, it looks like the code should just treat it as enabled?
So, I'm not sure how this fix (or even the previous code, before we changed any of this) adheres/adhered to the "last win" policy?
Ok, I see that this change only really affects how
It does print the lint warning (meaning that So, the real fix of this PR is in using |
Correct - because that "carve out" was already there in the previous behavior, and the whole point of this patch is to restore that previous behavior. Some lint warnings simply don't follow the normal enable/disable logic (which you normally get by using Instead, what I'm trying to do now (in upcoming PR #24584) is simply make these special cases more explicit in the code using new |
Ok, I now see that #24746 did essentially two things:
Part (2) is what created the issue, because by replacing So, this PR reverts the behavioral changes, by having I have to admit I don't really get why |
Note: the same is true for the new methods |
It's to allow for future customization of other lint-related options, in particular Maybe that's a little too leading? I can remove it if you prefer. |
Yeah, I think for now I'd prefer that. I believe each PR should be relatively standalone -- maybe we will go ahead and follow up with the other PR, but I'd prefer to avoid adding more stuff here which is really needed to support that other task. |
My minor contribution to #24746 (which fixed JDK-8354556) accidentally introduced a change in the compiler's behavior when given conflicting lint flags like
-Xlint:options -Xlint:-options
. This PR restores the original behavior.Although this might be considered a weird corner case, many build systems add flags in multiple stages and this can easily result in both flags being added, and so the behavior in this scenario needs to stay consistent.
Basically the code was trying to be too clever; when the original logic is restored, the code gets simpler.
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25840/head:pull/25840
$ git checkout pull/25840
Update a local copy of the PR:
$ git checkout pull/25840
$ git pull https://git.openjdk.org/jdk.git pull/25840/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25840
View PR using the GUI difftool:
$ git pr show -t 25840
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25840.diff
Using Webrev
Link to Webrev Comment