-
Notifications
You must be signed in to change notification settings - Fork 299
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
Fix JSpecify support on JDK 21 #869
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #869 +/- ##
============================================
- Coverage 87.20% 86.94% -0.26%
- Complexity 1947 1952 +5
============================================
Files 77 77
Lines 6268 6314 +46
Branches 1216 1222 +6
============================================
+ Hits 5466 5490 +24
- Misses 403 420 +17
- Partials 399 404 +5 ☔ View full report in Codecov by Sentry. |
… for both add and drop metadata
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.
Looks great! A few requested changes / comments
nullaway/src/main/java/com/uber/nullaway/generics/PreservedAnnotationTreeVisitor.java
Outdated
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/generics/PreservedAnnotationTreeVisitor.java
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/generics/PreservedAnnotationTreeVisitor.java
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/generics/PreservedAnnotationTreeVisitor.java
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/generics/PreservedAnnotationTreeVisitor.java
Outdated
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/generics/PreservedAnnotationTreeVisitor.java
Outdated
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/generics/PreservedAnnotationTreeVisitor.java
Outdated
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/generics/PreservedAnnotationTreeVisitor.java
Outdated
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/generics/PreservedAnnotationTreeVisitor.java
Show resolved
Hide resolved
} | ||
// This will cause the test tasks to run if the coverage data is requested by the aggregation task | ||
tasks.withType(Test).forEach {task -> | ||
outgoing.artifact(tasks.named(task.name).map { t -> t.extensions.getByType(JacocoTaskExtension).destinationFile }) |
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.
The whole tasks.named(task.name)
thing is a horrible hack to force the test task to run when the coverage report is requested. I'll see if I can find a better way.
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.
Meh, let's leave this hack for now and fix this properly in #871
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.
SGTM!
No, if tests are failing then you can just leave the changes.
…On Nov 30, 2023 at 20:32:49, Abhijit Kulkarni ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In nullaway/src/main/java/com/uber/nullaway/NullAway.java
<#869 (comment)>:
> @@ -476,7 +476,7 @@ public Description matchAssignment(AssignmentTree tree, VisitorState state) {
doUnboxingCheck(state, tree.getExpression());
}
// generics check
- if (lhsType != null && lhsType.getTypeArguments().length() > 0) {
+ if (lhsType != null && lhsType.getTypeArguments().length() > 0 && config.isJSpecifyMode()) {
I tried removing the changes and saw some tests failing, I haven't looked
into it more deeply yet, Should I do that?
—
Reply to this email directly, view it on GitHub
<#869 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABPEUOULW66HFFOKE2R5U3YHFMXDAVCNFSM6AAAAAA72L4ZR2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTONJYHE4DKMJYGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@@ -118,3 +102,23 @@ def testJdk21 = tasks.register("testJdk21", Test) { | |||
tasks.named('check').configure { | |||
dependsOn testJdk21 | |||
} | |||
|
|||
|
|||
// Share the coverage data to be aggregated for the whole product |
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.
This change is required so that test coverage when running tests on JDK 21 gets reported to CodeCov.
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.
Overall LGTM! Just have a minor comment suggestions since we plan to drop JDK 8 in the near future.
} | ||
// This will cause the test tasks to run if the coverage data is requested by the aggregation task | ||
tasks.withType(Test).forEach {task -> | ||
outgoing.artifact(tasks.named(task.name).map { t -> t.extensions.getByType(JacocoTaskExtension).destinationFile }) |
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.
SGTM!
tasks.named('testJdk21', Test).configure { | ||
filter { | ||
// JSpecify Generics tests do not yet pass on JDK 21 | ||
// See https://github.com/uber/NullAway/issues/827 | ||
excludeTestsMatching "com.uber.nullaway.NullAwayJSpecifyGenericsTests" | ||
} | ||
} | ||
|
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.
Nice! 👍
/** | ||
* Utility method to get the current JDK version, that works on Java 8 and above. | ||
* | ||
* @return the current JDK version | ||
*/ | ||
private static int getVersion() { | ||
String version = System.getProperty("java.version"); | ||
if (version.startsWith("1.")) { | ||
version = version.substring(2, 3); | ||
} else { | ||
int dot = version.indexOf("."); | ||
if (dot != -1) { | ||
version = version.substring(0, dot); | ||
} | ||
} | ||
return Integer.parseInt(version); | ||
} |
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.
We won't need this anymore once we drop support for JDK 8, right? Since we can use Runtime.version()
starting from JDK 9 https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Runtime.html#version()
If so maybe worth adding a TODO here for a cleanup reminder since we plan to drop JDK 8 in the near future 😃
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.
Good point! Done in ac250ed
Our JSpecify mode would not run on JDK 21 due some some internal javac API changes. This PR adapts to those changes using code specific to JDK 21.
Fixes #827