diff --git a/nullaway/src/main/java/com/uber/nullaway/AbstractConfig.java b/nullaway/src/main/java/com/uber/nullaway/AbstractConfig.java index 31f983f0a8..ec66c965d3 100644 --- a/nullaway/src/main/java/com/uber/nullaway/AbstractConfig.java +++ b/nullaway/src/main/java/com/uber/nullaway/AbstractConfig.java @@ -291,19 +291,6 @@ public boolean isContractAnnotation(String annotationName) { return contractAnnotations.contains(annotationName); } - protected ImmutableSet getKnownInitializers( - ImmutableSet qualifiedNames) { - return qualifiedNames.stream() - .map( - name -> { - int lastDot = name.lastIndexOf('.'); - String methodName = name.substring(lastDot + 1); - String className = name.substring(0, lastDot); - return MethodClassAndName.create(className, methodName); - }) - .collect(ImmutableSet.toImmutableSet()); - } - @AutoValue abstract static class MethodClassAndName { @@ -311,6 +298,13 @@ static MethodClassAndName create(String enclosingClass, String methodName) { return new AutoValue_AbstractConfig_MethodClassAndName(enclosingClass, methodName); } + static MethodClassAndName fromClassDotMethod(String classDotMethod) { + int lastDot = classDotMethod.lastIndexOf('.'); + String methodName = classDotMethod.substring(lastDot + 1); + String className = classDotMethod.substring(0, lastDot); + return MethodClassAndName.create(className, methodName); + } + abstract String enclosingClass(); abstract String methodName(); diff --git a/nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java b/nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java index 06923c3607..2d461cc897 100644 --- a/nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java +++ b/nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java @@ -163,8 +163,9 @@ final class ErrorProneCLIFlagsConfig extends AbstractConfig { sourceClassesToExclude = getFlagStringSet(flags, FL_CLASSES_TO_EXCLUDE); unannotatedClasses = getFlagStringSet(flags, FL_UNANNOTATED_CLASSES); knownInitializers = - getKnownInitializers( - getFlagStringSet(flags, FL_KNOWN_INITIALIZERS, DEFAULT_KNOWN_INITIALIZERS)); + getFlagStringSet(flags, FL_KNOWN_INITIALIZERS, DEFAULT_KNOWN_INITIALIZERS).stream() + .map(MethodClassAndName::fromClassDotMethod) + .collect(ImmutableSet.toImmutableSet()); excludedClassAnnotations = getFlagStringSet( flags, FL_CLASS_ANNOTATIONS_TO_EXCLUDE, DEFAULT_CLASS_ANNOTATIONS_TO_EXCLUDE);