rubenada commented on code in PR #5213: URL: https://github.com/apache/calcite/pull/5213#discussion_r4664364817
########## site/develop/index.md: ########## @@ -224,42 +224,79 @@ push it. ## Null safety -Apache Calcite uses the Checker Framework to avoid unexpected `NullPointerExceptions`. -You might find a detailed documentation at https://checkerframework.org/ +Apache Calcite annotates its code with [JSpecify](https://jspecify.dev/) and verifies it with +[NullAway](https://github.com/uber/NullAway) to avoid unexpected `NullPointerExceptions`. -Note: only main code is verified for now, so nullness annotation is not enforced in test code. +NullAway verifies the `main` and `jmh` source sets of the modules listed in `nullawayProjects` in +the root `build.gradle.kts`; `:ubenchmark` keeps its code in `jmh`. Test code is not verified. -To execute the Checker Framework locally please use the following command: +Every package in those modules declares `@NullMarked` from `org.jspecify.annotations` in its +`package-info.java`, which makes types non-nullable unless they are annotated `@Nullable`. +A package annotation does not apply to subpackages, so a new package needs a `package-info.java` +of its own: - ./gradlew -PjdkBuildVersion=11 -PenableCheckerframework :linq4j:classes :core:classes + @NullMarked + package org.apache.calcite.adapter.example; -`-PjdkBuildVersion=11` compiles with JDK 11, as CI does; see -[the JDK that compiles Calcite]({{ site.baseurl }}/docs/howto.html#the-jdk-that-compiles-calcite). + import org.jspecify.annotations.NullMarked; + +NullAway analyzes only `@NullMarked` code (`NullAway:OnlyNullMarked`). So that a forgotten +`package-info.java` cannot leave a package unverified, the `RequireExplicitNullMarking` check fails +the build when a class in a verified module is neither `@NullMarked` nor `@NullUnmarked`. + +To verify one more module, add it to `nullawayProjects` and declare `@NullMarked` in its packages. Review Comment: nit: the last commit seems to have removed `nullawayProjects`, should this sentence be removed as well? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
