Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable JarInfer handler by default (#261)
This is mostly so that we can have a somewhat-functional NullAway on JDK 11 sooner (see #259). But also, removing a handler may give a small performance boost. With this change, you need to pass `-XepOpt:NullAway:JarInferEnabled=true` to enable JarInfer. Also, we separate out the JarInfer tests into their own module, so that there is no direct dependence from the `nullaway` module to the `jarinfer` libraries. This will enable us to get the `:nullaway:test` target passing on JDK 11 sooner.
- Loading branch information
Showing
10 changed files
with
142 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (C) 2017. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
plugins { | ||
id "java" | ||
// For code coverage: | ||
id 'jacoco' | ||
id 'com.github.kt3k.coveralls' | ||
} | ||
|
||
sourceCompatibility = "1.8" | ||
targetCompatibility = "1.8" | ||
|
||
dependencies { | ||
testCompile deps.test.junit4 | ||
testCompile(deps.build.errorProneTestHelpers) { | ||
exclude group: "junit", module: "junit" | ||
} | ||
testCompile project(":nullaway") | ||
testCompile project(":jar-infer:test-java-lib-jarinfer") | ||
|
||
} | ||
|
||
|
||
test { | ||
maxHeapSize = "1024m" | ||
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}" | ||
} | ||
|
||
// From https://github.com/kt3k/coveralls-gradle-plugin | ||
jacocoTestReport { | ||
reports { | ||
xml.enabled = true // coveralls plugin depends on xml format report | ||
html.enabled = true | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...ay-integration-test/src/test/java/com/uber/nullaway/jarinfer/JarInferIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.uber.nullaway.jarinfer; | ||
|
||
import com.google.errorprone.CompilationTestHelper; | ||
import com.uber.nullaway.NullAway; | ||
import java.util.Arrays; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public class JarInferIntegrationTest { | ||
|
||
@Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); | ||
|
||
private CompilationTestHelper compilationHelper; | ||
|
||
@Before | ||
public void setup() { | ||
compilationHelper = CompilationTestHelper.newInstance(NullAway.class, getClass()); | ||
} | ||
|
||
@Test | ||
public void jarinferLoadStubsTest() { | ||
compilationHelper | ||
.setArgs( | ||
Arrays.asList( | ||
"-d", | ||
temporaryFolder.getRoot().getAbsolutePath(), | ||
"-XepOpt:NullAway:AnnotatedPackages=com.uber", | ||
"-XepOpt:NullAway:JarInferEnabled=true", | ||
"-XepOpt:NullAway:UnannotatedSubPackages=com.uber.nullaway.[a-zA-Z0-9.]+.unannotated")) | ||
.addSourceLines( | ||
"Test.java", | ||
"package com.uber;", | ||
"import javax.annotation.Nullable;", | ||
"import com.uber.nullaway.jarinfer.toys.unannotated.Toys;", | ||
"class Test {", | ||
" void test1(@Nullable String s) {", | ||
" // BUG: Diagnostic contains: passing @Nullable parameter 's'", | ||
" Toys.test1(s, \"let's\", \"try\");", | ||
" }", | ||
"}") | ||
.doTest(); | ||
} | ||
|
||
@Test | ||
public void jarinferNullableReturnsTest() { | ||
compilationHelper | ||
.setArgs( | ||
Arrays.asList( | ||
"-d", | ||
temporaryFolder.getRoot().getAbsolutePath(), | ||
"-XepOpt:NullAway:AnnotatedPackages=com.uber", | ||
"-XepOpt:NullAway:UnannotatedSubPackages=com.uber.nullaway.[a-zA-Z0-9.]+.unannotated", | ||
"-XepOpt:NullAway:JarInferEnabled=true", | ||
"-XepOpt:NullAway:JarInferUseReturnAnnotations=true")) | ||
.addSourceLines( | ||
"Test.java", | ||
"package com.uber;", | ||
"import javax.annotation.Nullable;", | ||
"import com.uber.nullaway.jarinfer.toys.unannotated.Toys;", | ||
"class Test {", | ||
" void test1(@Nullable String s) {", | ||
" // BUG: Diagnostic contains: passing @Nullable parameter 'Toys.getString(false, s)'", | ||
" Toys.test1(Toys.getString(false, s), \"let's\", \"try\");", | ||
" }", | ||
"}") | ||
.doTest(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters