Skip to content

Commit

Permalink
Add support for jakarta.inject-api (#439)
Browse files Browse the repository at this point in the history
Since moving to Jakarte EE project under the Eclipse Foundation there has been a move from the old `javax.*` namespace to the `jakarta.*` namespace for many of the APIs previously belonging to Java EE.

Additionally to the well-known `javax.inject.Inject` there's now also `jakarta.inject.Inject` which should be recognized automatically by NullAway.
  • Loading branch information
joschi committed Jan 4, 2021
1 parent 6aa6271 commit 7164a48
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions gradle/dependencies.gradle
Expand Up @@ -26,9 +26,10 @@ def versions = [
]

def apt = [
autoValue : ["com.google.auto.value:auto-value:${versions.autoValue}", "com.google.auto.value:auto-value-annotations:${versions.autoValue}"],
autoService : "com.google.auto.service:auto-service:1.0-rc3",
javaxInject : "javax.inject:javax.inject:1",
autoValue : ["com.google.auto.value:auto-value:${versions.autoValue}", "com.google.auto.value:auto-value-annotations:${versions.autoValue}"],
autoService : "com.google.auto.service:auto-service:1.0-rc3",
jakartaInject : "jakarta.inject:jakarta.inject-api:2.0.0",
javaxInject : "javax.inject:javax.inject:1",
]

def build = [
Expand Down
1 change: 1 addition & 0 deletions nullaway/build.gradle
Expand Up @@ -46,6 +46,7 @@ dependencies {
testCompile deps.test.cfCompatQual
testCompile project(":test-java-lib")
testCompile deps.test.inferAnnotations
testCompile deps.apt.jakartaInject
testCompile deps.apt.javaxInject
testCompile deps.test.rxjava2
testCompile deps.test.commonsLang
Expand Down
Expand Up @@ -115,6 +115,7 @@ final class ErrorProneCLIFlagsConfig extends AbstractConfig {

static final ImmutableSet<String> DEFAULT_EXCLUDED_FIELD_ANNOT =
ImmutableSet.of(
"jakarta.inject.Inject", // no explicit initialization when there is dependency injection
"javax.inject.Inject", // no explicit initialization when there is dependency injection
"com.google.errorprone.annotations.concurrent.LazyInit",
"org.checkerframework.checker.nullness.qual.MonotonicNonNull");
Expand Down
Expand Up @@ -24,7 +24,6 @@

import com.facebook.infer.annotation.Initializer;
import com.google.errorprone.annotations.concurrent.LazyInit;
import javax.inject.Inject;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.junit.Before;
import org.junit.BeforeClass;
Expand All @@ -46,7 +45,9 @@ class T1 {

Object k;

@Inject Object m;
@jakarta.inject.Inject Object m;

@javax.inject.Inject Object n;

@LazyInit Object lazy;

Expand Down

0 comments on commit 7164a48

Please sign in to comment.