Skip to content

Commit 99fd162

Browse files
committed
[CALCITE-4199] Add CheckerFramework to GitHub Actions CI
CheckerFramework needs an annotated JDK, so it is not activated by default
1 parent cb576e1 commit 99fd162

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+925
-7
lines changed

.github/workflows/main.yml

+18
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@ jobs:
147147
job-id: errprone
148148
arguments: --scan --no-parallel --no-daemon -PenableErrorprone classes
149149

150+
linux-checkerframework:
151+
name: 'CheckerFramework (JDK 11)'
152+
runs-on: ubuntu-latest
153+
steps:
154+
- uses: actions/checkout@v2
155+
with:
156+
fetch-depth: 50
157+
- name: 'Set up JDK 11'
158+
uses: actions/setup-java@v1
159+
with:
160+
java-version: 11
161+
- name: 'Run CheckerFramework'
162+
uses: burrunan/gradle-cache-action@v1
163+
with:
164+
job-id: checkerframework-jdk11
165+
arguments: --scan --no-parallel --no-daemon -PenableCheckerframework classes
166+
150167
linux-slow:
151168
# Run slow tests when the commit is on master or it is requested explicitly by adding an
152169
# appropriate label in the PR
@@ -166,6 +183,7 @@ jobs:
166183
with:
167184
job-id: jdk8
168185
arguments: --scan --no-parallel --no-daemon testSlow
186+
169187
linux-druid:
170188
if: github.event.action != 'labeled'
171189
name: 'Linux (JDK 8) Druid Tests'

bom/build.gradle.kts

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ dependencies {
5353
// dependency on it during compilation
5454
apiv("com.alibaba.database:innodb-java-reader")
5555
apiv("com.beust:jcommander")
56+
apiv("org.checkerframework:checker-qual", "checkerframework")
5657
apiv("com.datastax.cassandra:cassandra-driver-core")
5758
apiv("com.esri.geometry:esri-geometry-api")
5859
apiv("com.fasterxml.jackson.core:jackson-databind")
5960
apiv("com.github.kstyrc:embedded-redis")
6061
apiv("com.github.stephenc.jcip:jcip-annotations")
61-
apiv("com.google.code.findbugs:jsr305", "findbugs.jsr305")
62+
apiv("com.google.errorprone:error_prone_annotations", "errorprone")
63+
apiv("com.google.errorprone:error_prone_type_annotations", "errorprone")
6264
apiv("com.google.guava:guava")
6365
apiv("com.google.protobuf:protobuf-java", "protobuf")
6466
apiv("com.google.uzaygezen:uzaygezen-core", "uzaygezen")

build.gradle.kts

+44
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ plugins {
3737
// Verification
3838
checkstyle
3939
calcite.buildext
40+
id("org.checkerframework") apply false
4041
id("com.github.autostyle")
4142
id("org.nosphere.apache.rat")
4243
id("com.github.spotbugs")
@@ -65,6 +66,7 @@ val lastEditYear by extra(lastEditYear())
6566

6667
// Do not enable spotbugs by default. Execute it only when -Pspotbugs is present
6768
val enableSpotBugs = props.bool("spotbugs")
69+
val enableCheckerframework by props()
6870
val enableErrorprone by props()
6971
val skipCheckstyle by props()
7072
val skipAutostyle by props()
@@ -454,6 +456,8 @@ allprojects {
454456
replace("junit5: Assert.fail", "org.junit.Assert.fail", "org.junit.jupiter.api.Assertions.fail")
455457
}
456458
replaceRegex("side by side comments", "(\n\\s*+[*]*+/\n)(/[/*])", "\$1\n\$2")
459+
replaceRegex("jsr305 nullable -> checkerframework", "javax\\.annotation\\.Nullable", "org.checkerframework.checker.nullness.qual.Nullable")
460+
replaceRegex("jsr305 nonnull -> checkerframework", "javax\\.annotation\\.Nonnull", "org.checkerframework.checker.nullness.qual.NonNull")
457461
importOrder(
458462
"org.apache.calcite.",
459463
"org.apache.",
@@ -552,6 +556,43 @@ allprojects {
552556
}
553557
}
554558
}
559+
if (enableCheckerframework) {
560+
apply(plugin = "org.checkerframework")
561+
dependencies {
562+
"checkerFramework"("org.checkerframework:checker:${"checkerframework".v}")
563+
// CheckerFramework annotations might be used in the code as follows:
564+
// dependencies {
565+
// "compileOnly"("org.checkerframework:checker-qual")
566+
// "testCompileOnly"("org.checkerframework:checker-qual")
567+
// }
568+
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
569+
// only needed for JDK 8
570+
"checkerFrameworkAnnotatedJDK"("org.checkerframework:jdk8")
571+
}
572+
}
573+
configure<org.checkerframework.gradle.plugin.CheckerFrameworkExtension> {
574+
skipVersionCheck = true
575+
// See https://checkerframework.org/manual/#introduction
576+
checkers.add("org.checkerframework.checker.nullness.NullnessChecker")
577+
// Below checkers take significant time and they do not provide much value :-/
578+
// checkers.add("org.checkerframework.checker.optional.OptionalChecker")
579+
// checkers.add("org.checkerframework.checker.regex.RegexChecker")
580+
// https://checkerframework.org/manual/#creating-debugging-options-progress
581+
// extraJavacArgs.add("-Afilenames")
582+
extraJavacArgs.addAll(listOf("-Xmaxerrs", "10000"))
583+
// Consider Java assert statements for nullness and other checks
584+
extraJavacArgs.add("-AassumeAssertionsAreEnabled")
585+
// https://checkerframework.org/manual/#stub-using
586+
extraJavacArgs.add("-Astubs=" +
587+
fileTree("$rootDir/src/main/config/checkerframework") {
588+
include("**/*.astub")
589+
}.asPath
590+
)
591+
if (project.path == ":core") {
592+
extraJavacArgs.add("-AskipDefs=^org\\.apache\\.calcite\\.sql\\.parser\\.impl\\.")
593+
}
594+
}
595+
}
555596

556597
tasks {
557598
configureEach<Jar> {
@@ -585,6 +626,9 @@ allprojects {
585626
if (werror) {
586627
options.compilerArgs.add("-Werror")
587628
}
629+
if (enableCheckerframework) {
630+
options.forkOptions.memoryMaximumSize = "2g"
631+
}
588632
}
589633
configureEach<Test> {
590634
outputs.cacheIf("test results depend on the database configuration, so we souldn't cache it") {

core/build.gradle.kts

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ dependencies {
4747
implementation("com.fasterxml.jackson.core:jackson-core")
4848
implementation("com.fasterxml.jackson.core:jackson-databind")
4949
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
50-
implementation("com.google.code.findbugs:jsr305"/* optional*/)
50+
implementation("com.google.errorprone:error_prone_annotations")
5151
implementation("com.google.guava:guava")
5252
implementation("com.google.uzaygezen:uzaygezen-core")
5353
implementation("com.jayway.jsonpath:json-path")
@@ -56,6 +56,7 @@ dependencies {
5656
implementation("net.hydromatic:aggdesigner-algorithm")
5757
implementation("org.apache.commons:commons-dbcp2")
5858
implementation("org.apache.commons:commons-lang3")
59+
implementation("org.checkerframework:checker-qual")
5960
implementation("commons-io:commons-io")
6061
implementation("org.codehaus.janino:commons-compiler")
6162
implementation("org.codehaus.janino:janino")

druid/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ dependencies {
2020

2121
implementation("com.fasterxml.jackson.core:jackson-core")
2222
implementation("com.fasterxml.jackson.core:jackson-databind")
23-
implementation("com.google.code.findbugs:jsr305")
2423
implementation("com.google.guava:guava")
2524
implementation("joda-time:joda-time")
2625
implementation("org.apache.calcite.avatica:avatica-core")
2726
implementation("org.apache.commons:commons-lang3")
27+
implementation("org.checkerframework:checker-qual")
2828
implementation("org.slf4j:slf4j-api")
2929

3030
testImplementation(project(":core", "testClasses"))

elasticsearch/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ dependencies {
2828

2929
implementation("com.fasterxml.jackson.core:jackson-core")
3030
implementation("com.fasterxml.jackson.core:jackson-databind")
31-
implementation("com.google.code.findbugs:jsr305")
3231
implementation("com.google.guava:guava")
3332
implementation("org.apache.calcite.avatica:avatica-core")
3433
implementation("org.apache.httpcomponents:httpclient")
3534
implementation("org.apache.httpcomponents:httpcore")
35+
implementation("org.checkerframework:checker-qual")
3636
implementation("org.elasticsearch.client:elasticsearch-rest-client")
3737
implementation("org.slf4j:slf4j-api")
3838

gradle.properties

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ calcite.avatica.version=1.17.0
4242
# publishGradleMetadata=true
4343

4444
# Plugins
45+
org.checkerframework.version=0.5.10
4546
com.github.autostyle.version=3.0
4647
com.github.johnrengelman.shadow.version=5.1.0
4748
com.github.spotbugs.version=2.0.0
@@ -60,6 +61,7 @@ org.owasp.dependencycheck.version=5.2.2
6061
# docker-maven-plugin.version=1.2.0
6162

6263
# Tools
64+
checkerframework.version=3.7.0
6365
checkstyle.version=8.28
6466
spotbugs.version=3.1.11
6567
errorprone.version=2.4.0
@@ -82,8 +84,8 @@ commons-lang3.version=3.8
8284
dropwizard-metrics.version=4.0.5
8385
elasticsearch.version=7.0.1
8486
embedded-redis.version=0.6
87+
errorprone.version=2.4.0
8588
esri-geometry-api.version=2.2.0
86-
findbugs.jsr305.version=3.0.1
8789
foodmart-data-hsqldb.version=0.3
8890
foodmart-data-json.version=0.4
8991
foodmart-queries.version=0.4.1

linq4j/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ dependencies {
1919

2020
implementation("com.google.guava:guava")
2121
implementation("org.apache.calcite.avatica:avatica-core")
22+
implementation("org.checkerframework:checker-qual")
2223
}

piglet/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ dependencies {
2323
api(project(":core"))
2424
api(project(":linq4j"))
2525

26-
implementation("com.google.code.findbugs:jsr305")
2726
implementation("com.google.guava:guava")
2827
implementation("org.apache.calcite.avatica:avatica-core")
2928
implementation("org.apache.hadoop:hadoop-common")
3029
implementation("org.apache.pig:pig::h2")
30+
implementation("org.checkerframework:checker-qual")
3131
implementation("org.slf4j:slf4j-api")
3232

3333
testImplementation(project(":core", "testClasses"))

redis/build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ dependencies {
2121
implementation("com.fasterxml.jackson.core:jackson-core")
2222
implementation("com.fasterxml.jackson.core:jackson-databind")
2323
implementation("com.github.kstyrc:embedded-redis")
24-
implementation("com.google.code.findbugs:jsr305")
2524
implementation("com.google.guava:guava")
2625
implementation("joda-time:joda-time")
2726
implementation("org.apache.calcite.avatica:avatica-core")

settings.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pluginManagement {
1919
fun String.v() = extra["$this.version"].toString()
2020
fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version key.v()
2121

22+
idv("org.checkerframework")
2223
idv("com.github.autostyle")
2324
idv("com.github.johnrengelman.shadow")
2425
idv("com.github.spotbugs")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package java.util;
18+
19+
import java.util.function.Supplier;
20+
import org.checkerframework.checker.nullness.qual.*;
21+
22+
interface Collection<E> {
23+
boolean contains(@Nullable Object o);
24+
boolean remove(@Nullable Object o);
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package java.lang.reflect;
18+
19+
import org.checkerframework.checker.nullness.qual.*;
20+
21+
class Constructor<T> {
22+
public @NonNull T newInstance(@Nullable Object... initargs);
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package java.lang.reflect;
18+
19+
import org.checkerframework.checker.nullness.qual.*;
20+
21+
class Field {
22+
@Nullable Object get(@Nullable Object obj);
23+
int getInt(@Nullable Object obj);
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package java.lang.reflect;
18+
19+
import org.checkerframework.checker.nullness.qual.*;
20+
21+
interface InvocationHandler {
22+
@Nullable Object invoke(Object proxy, Method method, @Nullable Object[] args);
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package java.util;
18+
19+
import java.util.function.Supplier;
20+
import org.checkerframework.checker.nullness.qual.*;
21+
22+
interface List<E> {
23+
boolean contains(@Nullable Object o);
24+
boolean remove(@Nullable Object o);
25+
int indexOf(@Nullable Object o);
26+
int lastIndexOf(@Nullable Object o);
27+
}
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package java.util;
18+
19+
import java.util.function.Supplier;
20+
import org.checkerframework.checker.nullness.qual.*;
21+
22+
interface Map<K, V> {
23+
boolean containsKey(@Nullable Object o);
24+
boolean containsValue(@Nullable Object value);
25+
boolean remove(@Nullable Object key, @Nullable Object value);
26+
@Nullable V remove(@Nullable Object o);
27+
@Nullable V get(@Nullable Object key);
28+
V getOrDefault(@Nullable Object key, V defaultValue);
29+
}

0 commit comments

Comments
 (0)