Repository: kythe/kythe
Pull request #4754 (2020-11-12 21:44:30)

style: another batch of ErrorProne checks


Patch:
diff --git a/kythe/java/com/google/devtools/kythe/analyzers/base/CorpusPath.java b/kythe/java/com/google/devtools/kythe/analyzers/base/CorpusPath.java
index 2853428f2..95a5e3610 100644
--- a/kythe/java/com/google/devtools/kythe/analyzers/base/CorpusPath.java
+++ b/kythe/java/com/google/devtools/kythe/analyzers/base/CorpusPath.java
@@ -26,7 +26,9 @@ public final class CorpusPath {
   /** The empty {@link CorpusPath}. */
   public static final CorpusPath EMPTY = new CorpusPath("", "", "");
 
-  private final String corpus, root, path;
+  private final String corpus;
+  private final String root;
+  private final String path;
 
   public CorpusPath(String corpus, String root, String path) {
     Preconditions.checkNotNull(corpus, "corpus must be non-null");
diff --git a/kythe/java/com/google/devtools/kythe/analyzers/java/KytheTreeScanner.java b/kythe/java/com/google/devtools/kythe/analyzers/java/KytheTreeScanner.java
index 06bd71bb6..15cc2b9df 100644
--- a/kythe/java/com/google/devtools/kythe/analyzers/java/KytheTreeScanner.java
+++ b/kythe/java/com/google/devtools/kythe/analyzers/java/KytheTreeScanner.java
@@ -1297,8 +1297,10 @@ public class KytheTreeScanner extends JCTreeScanner<JavaNode, TreeContext> {
     }
   }
 
-  // Cached common java.lang.* nodes.
-  private JavaNode javaLangObjectNode, javaLangEnumNode;
+  // Cached common java.lang.Object node.
+  private JavaNode javaLangObjectNode;
+  // Cached common java.lang.Enum node.
+  private JavaNode javaLangEnumNode;
 
   // Returns a JavaNode representing java.lang.Object.
   private JavaNode getJavaLangObjectNode() {
diff --git a/kythe/java/com/google/devtools/kythe/extractors/java/UsageAsInputReportingFileManager.java b/kythe/java/com/google/devtools/kythe/extractors/java/UsageAsInputReportingFileManager.java
index 4a3e8df4f..2256c5dea 100644
--- a/kythe/java/com/google/devtools/kythe/extractors/java/UsageAsInputReportingFileManager.java
+++ b/kythe/java/com/google/devtools/kythe/extractors/java/UsageAsInputReportingFileManager.java
@@ -174,7 +174,7 @@ class UsageAsInputReportingFileManager extends ForwardingStandardJavaFileManager
     } catch (UnsupportedOperationException err) {
       try {
         return Paths.get(fo.toUri());
-      } catch (Throwable t) {
+      } catch (Throwable unused) {
         throw err; // Re-throw the original error.
       }
     }
diff --git a/kythe/java/com/google/devtools/kythe/platform/shared/CompilationUnits.java b/kythe/java/com/google/devtools/kythe/platform/shared/CompilationUnits.java
index 0e26e4f80..ac5ef84b4 100644
--- a/kythe/java/com/google/devtools/kythe/platform/shared/CompilationUnits.java
+++ b/kythe/java/com/google/devtools/kythe/platform/shared/CompilationUnits.java
@@ -110,7 +110,8 @@ public class CompilationUnits {
     List<FileInput> ri = Lists.newArrayList(orig);
     Collections.sort(ri, (a, b) -> a.getInfo().getDigest().compareTo(b.getInfo().getDigest()));
     // Invariant: All elements at or before i are unique (no duplicates).
-    int i = 0, j = 1;
+    int i = 0;
+    int j = 1;
     while (j < ri.size()) {
       // If ri[j] ≠ ri[i], it is a new element, not a duplicate.  Move it
       // next in sequence after i and advance i; this ensures we keep the
diff --git a/kythe/java/com/google/devtools/kythe/platform/shared/FileDataProvider.java b/kythe/java/com/google/devtools/kythe/platform/shared/FileDataProvider.java
index 7167ba3b1..e981a77ef 100644
--- a/kythe/java/com/google/devtools/kythe/platform/shared/FileDataProvider.java
+++ b/kythe/java/com/google/devtools/kythe/platform/shared/FileDataProvider.java
@@ -25,8 +25,8 @@ import com.google.devtools.kythe.proto.Analysis.FileInfo;
  */
 public interface FileDataProvider extends AutoCloseable {
   /**
-   * Returns a {@link Future<byte[]>} for the contents of the file described by the given path and
-   * digest. If the file cannot be found (and there was no exception), the future will return null.
+   * Returns a {@link Future} for the contents of the file described by the given path and digest.
+   * If the file cannot be found (and there was no exception), the future will return null.
    *
    * <p>If both digest and path are non-null, they should correspond to each other. Implementations
    * can choose to ignore path, digest, or require them both to be present. If an implementation
@@ -36,8 +36,7 @@ public interface FileDataProvider extends AutoCloseable {
   ListenableFuture<byte[]> startLookup(String path, String digest);
 
   /**
-   * Returns a {@link Future<byte[]>} for the contents of the file described by the given {@link
-   * FileInfo}.
+   * Returns a {@link Future} for the contents of the file described by the given {@link FileInfo}.
    *
    * @see startLookup(String, String)
    */
diff --git a/tools/javacopts.bazelrc b/tools/javacopts.bazelrc
index 3326e0ae7..6f5187b6e 100644
--- a/tools/javacopts.bazelrc
+++ b/tools/javacopts.bazelrc
@@ -6,6 +6,7 @@ build --javacopt="-XepExcludedPaths:.*/(external|_javac)/.*"
 build --javacopt="-Xep:AlmostJavadoc"
 build --javacopt="-Xep:AmbiguousMethodReference"
 build --javacopt="-Xep:AnnotateFormatMethod"
+build --javacopt="-Xep:AnnotationPosition"
 build --javacopt="-Xep:ArgumentSelectionDefectChecker"
 build --javacopt="-Xep:ArrayAsKeyOfSetOrMap"
 build --javacopt="-Xep:AssertEqualsArgumentOrderChecker"
@@ -32,6 +33,7 @@ build --javacopt="-Xep:CollectionUndefinedEquality"
 build --javacopt="-Xep:CollectorShouldNotUseState"
 build --javacopt="-Xep:CompareToZero"
 build --javacopt="-Xep:ComplexBooleanConstant"
+build --javacopt="-Xep:ConstantField"
 build --javacopt="-Xep:DateChecker"
 build --javacopt="-Xep:DateFormatConstant"
 build --javacopt="-Xep:DefaultCharset"
@@ -90,14 +92,18 @@ build --javacopt="-Xep:LiteProtoToString"
 build --javacopt="-Xep:LockNotBeforeTry"
 build --javacopt="-Xep:LockOnBoxedPrimitive"
 build --javacopt="-Xep:MathAbsoluteRandom"
+build --javacopt="-Xep:MemberName"
 build --javacopt="-Xep:MissingFail"
 build --javacopt="-Xep:MissingOverride"
 build --javacopt="-Xep:MissingSummary"
+build --javacopt="-Xep:MixedArrayDimensions"
 build --javacopt="-Xep:MixedMutabilityReturnType"
 build --javacopt="-Xep:ModifiedButNotUsed"
 build --javacopt="-Xep:ModifyCollectionInEnhancedForLoop"
 build --javacopt="-Xep:ModifySourceCollectionInStream"
+build --javacopt="-Xep:MultiVariableDeclaration"
 build --javacopt="-Xep:MultipleParallelOrSequentialCalls"
+build --javacopt="-Xep:MultipleTopLevelClasses"
 build --javacopt="-Xep:MultipleUnaryOperatorsInMethodCall"
 build --javacopt="-Xep:MutableConstantField"
 build --javacopt="-Xep:MutableMethodReturnType"
@@ -119,6 +125,7 @@ build --javacopt="-Xep:OptionalNotPresent"
 build --javacopt="-Xep:OrphanedFormatString"
 build --javacopt="-Xep:OutlineNone"
 build --javacopt="-Xep:OverrideThrowableToString"
+build --javacopt="-Xep:PackageLocation"
 build --javacopt="-Xep:ParameterName"
 build --javacopt="-Xep:PreconditionsCheckNotNullRepeated"
 build --javacopt="-Xep:PrimitiveAtomicReference"
@@ -129,6 +136,7 @@ build --javacopt="-Xep:ProtoTimestampGetSecondsGetNano"
 build --javacopt="-Xep:QualifierWithTypeUse"
 build --javacopt="-Xep:ReachabilityFenceUsage"
 build --javacopt="-Xep:ReferenceEquality"
+build --javacopt="-Xep:RemoveUnusedImports"
 build --javacopt="-Xep:ReturnFromVoid"
 build --javacopt="-Xep:RxReturnValueIgnored"
 build --javacopt="-Xep:SameNameButDifferent"
@@ -140,6 +148,7 @@ build --javacopt="-Xep:StaticGuardedByInstance"
 build --javacopt="-Xep:StaticMockMember"
 build --javacopt="-Xep:StringSplitter"
 build --javacopt="-Xep:StronglyTypeTime"
+build --javacopt="-Xep:SwitchDefault"
 build --javacopt="-Xep:SynchronizeOnNonFinalField"
 build --javacopt="-Xep:TestExceptionChecker"
 build --javacopt="-Xep:ThreadJoinLoop"
@@ -154,6 +163,7 @@ build --javacopt="-Xep:TruthConstantAsserts"
 build --javacopt="-Xep:TruthGetOrDefault"
 build --javacopt="-Xep:TypeEqualsChecker"
 build --javacopt="-Xep:TypeNameShadowing"
+build --javacopt="-Xep:TypeParameterNaming"
 build --javacopt="-Xep:TypeParameterShadowing"
 build --javacopt="-Xep:TypeParameterUnusedInFormals"
 build --javacopt="-Xep:URLEqualsHashCode"
@@ -165,9 +175,11 @@ build --javacopt="-Xep:UnnecessaryDefaultInEnumSwitch"
 build --javacopt="-Xep:UnnecessaryLambda"
 build --javacopt="-Xep:UnnecessaryMethodInvocationMatcher"
 build --javacopt="-Xep:UnnecessaryParentheses"
+build --javacopt="-Xep:UnnecessaryStaticImport"
 build --javacopt="-Xep:UnsafeFinalization"
 build --javacopt="-Xep:UnsafeReflectiveConstructionCast"
 build --javacopt="-Xep:UnsynchronizedOverridesSynchronized"
+build --javacopt="-Xep:UnusedException"
 build --javacopt="-Xep:UnusedMethod"
 build --javacopt="-Xep:UnusedNestedClass"
 build --javacopt="-Xep:UnusedVariable"
@@ -180,4 +192,5 @@ build --javacopt="-Xep:VisibleForTestingMisused"
 build --javacopt="-Xep:VisibleForTestingOverride"
 build --javacopt="-Xep:VisibleForTestingUsed"
 build --javacopt="-Xep:WaitNotInLoop"
+build --javacopt="-Xep:WildcardImport"
 build --javacopt="-Xep:WithSignatureDiscouraged"


Test patch:
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/TestPlugin.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/TestPlugin.java
index 7721dfe6f..6d3a53f10 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/TestPlugin.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/TestPlugin.java
@@ -32,11 +32,11 @@ import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
 import java.util.Optional;
 
-@AutoService(Plugin.class)
 /**
  * Kythe {@link Plugin} that emits "special" Kythe nodes for Java methods and fields annotated with
  * {@code @pkg.PluginTests.SpecialAnnotation}.
  */
+@AutoService(Plugin.class)
 public class TestPlugin extends Plugin.Scanner<Void, Void> {
   public TestPlugin() {}
 
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/BUILD b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/BUILD
index faf8c0720..d491a23f6 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/BUILD
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/BUILD
@@ -19,6 +19,10 @@ java_library(
             "PrivateInterfaceMethods.java",
         ],
     ),
+    javacopts = [
+        "-Xep:MultipleTopLevelClasses:OFF",
+        "-Xep:WildcardImport:OFF",
+    ],
     deps = [
         "//kythe/java/com/google/devtools/kythe/common:autovalue",
         "@maven//:com_google_code_findbugs_jsr305",
@@ -455,6 +459,9 @@ java_verifier_test(
 java_library(
     name = "cross_file",
     srcs = ["CrossFile.java"],
+    javacopts = [
+        "-Xep:WildcardImport:OFF",
+    ],
     deps = [":files"],
 )
 
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Callgraph.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Callgraph.java
index eb559a798..06df9cf80 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Callgraph.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Callgraph.java
@@ -1,6 +1,6 @@
 package pkg;
 
-@SuppressWarnings("unused")
+@SuppressWarnings({"unused", "MultiVariableDeclaration"})
 //- @Callgraph defines/binding Class
 //- ClassInitDef.loc/start @^"Callgraph"
 //- ClassInitDef.loc/end @^"Callgraph"
@@ -19,7 +19,7 @@ public class Callgraph {
   //- NonStaticGCall childof SCtor
   //- !{ NonStaticGCall childof Class }
   //- !{ NonStaticGCall childof ClassInit }
-  final int ZERO = g();
+  final int zero = g();
 
   //- StaticGCall.loc/start @^"g()"
   //- StaticGCall.loc/end @$"g()"
@@ -62,7 +62,7 @@ public class Callgraph {
   //- CtorCall ref/call ECtor
   //- CtorCall childof ECtor
   //- CtorCall childof SCtor
-  final Callgraph INSTANCE = new Callgraph();
+  final Callgraph instance = new Callgraph();
 
   //- @Callgraph defines/binding ECtor
   //- ECtor.node/kind function
@@ -119,7 +119,7 @@ public class Callgraph {
     //- NestedClassCall.loc/start @^"g()"
     //- NestedClassCall.loc/end   @$"g()"
     //- NestedClassCall  childof  ImplicitConstructor
-    final int INT = g();
+    final int someInt = g();
 
     static {
       //- NestedClassStaticCall.loc/start @^"g()"
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Comments.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Comments.java
index 9d3c82f58..380cefd8d 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Comments.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Comments.java
@@ -7,11 +7,11 @@ package pkg;
 // - @+6pkg ref/doc Package
 // - @+7Comments defines/binding CommentsClass
 
-@SuppressWarnings("unused")
 /**
  * This is a Javadoc comment with links to {@link String}, {@link java.lang.Integer}, {@link Inner},
  * and {@link pkg}. It references {@value IM_A_LONG}.
  */
+@SuppressWarnings({"unused", "MultiVariableDeclaration"})
 public class Comments implements Comparable<Comments> {
 
   // - @long ref/doc LongBuiltin
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/CrossFile.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/CrossFile.java
index 2f5bcc630..a5ba9916d 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/CrossFile.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/CrossFile.java
@@ -4,11 +4,12 @@ package pkg;
 
 //- @CONSTANT ref/imports ConstantMember
 import static pkg.Files.CONSTANT;
-//- @Inner ref/imports InnerClass
-import static pkg.Files.Inner;
 //- @staticMethod ref/imports StaticMethod
 import static pkg.Files.staticMethod;
 
+//- @Inner ref/imports InnerClass
+import pkg.Files.Inner;
+
 // Make sure wildcard imports don't crash.
 import static pkg.Files.*;
 import pkg.*;
@@ -25,6 +26,9 @@ public class CrossFile {
   //- @OtherDecl ref ODecl
   OtherDecl f3;
 
+  //- @Inner ref InnerClass
+  Inner in;
+
   //- @Inter ref Inter
   Inter i;
 
@@ -37,5 +41,7 @@ public class CrossFile {
     staticMethod();
     //- @CONSTANT ref ConstantMember
     System.out.println(Files.CONSTANT);
+    //- @CONSTANT ref ConstantMember
+    System.out.println(CONSTANT);
   }
 }
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Files.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Files.java
index 2f80b8756..5ef0a2b63 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Files.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Files.java
@@ -7,11 +7,11 @@ package pkg;
 public class Files {
 
   //- @"錨" defines/binding UV
-  int 錨;
+  static final int 錨 = 0;
   //- Anchor=vname(_,"kythe","","kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Files.java","java") defines/binding UV
   //- Anchor.node/kind anchor
-  //- Anchor.loc/start 191
-  //- Anchor.loc/end 194
+  //- Anchor.loc/start 204
+  //- Anchor.loc/end 207
 
   //- @Inner defines/binding InnerClass
   //- InnerClass childof FilesClass
@@ -30,7 +30,7 @@ public class Files {
   public static final Inner INSTANCE = new Inner();
 
   // Ensure this private member does not affect the class node across compilations.
-  private int PRIVATE_MEMBER = -42;
+  private int privateMember = -42;
 
   //- @OtherDecl defines/binding ODecl
   //- ODecl.node/kind sum
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/GenericComments.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/GenericComments.java
index 1044d707b..83cfa33e8 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/GenericComments.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/GenericComments.java
@@ -13,9 +13,9 @@ public class GenericComments<T> {
   //- GClass.code GCCode
   //- GAbsClass.code GCCode
 
-  //- @+2GenericMethod defines/binding GAbsFunction
+  //- @+2genericMethod defines/binding GAbsFunction
   /** M */
-  public static <T> T GenericMethod(T x) { return x; }
+  public static <T> T genericMethod(T x) { return x; }
 
   //- GAbsFunction.node/kind abs
   //- GFunction childof GAbsFunction
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Generics.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Generics.java
index 8d79a06e2..475d9901c 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Generics.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Generics.java
@@ -63,13 +63,13 @@ public class Generics<T> {
   //- OptionalTVar.node/kind absvar
   private static class Optional<T> {}
 
-  //- @BV defines/binding BVar
-  //- BVar.node/kind absvar
+  //- @U defines/binding UVar
+  //- UVar.node/kind absvar
   //- @List ref List
   //- @Inter ref Inter
-  //- BVar bounded/upper.0 List
-  //- BVar bounded/upper.1 Inter
-  private static class Bounded<BV extends java.util.List & Inter> {}
+  //- UVar bounded/upper.0 List
+  //- UVar bounded/upper.1 Inter
+  private static class Bounded<U extends java.util.List & Inter> {}
 
   //- @classTypeVarBound defines/binding _ClassTypeVarBoundFunc
   //- @E defines/binding EVar
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Imports.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Imports.java
index 6003b67d3..067311f41 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Imports.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Imports.java
@@ -3,9 +3,9 @@ package pkg;
 //- @CASE_INSENSITIVE_ORDER ref/imports StringConst
 //- @String ref String
 import static java.lang.String.CASE_INSENSITIVE_ORDER;
-//- @hashCode ref/imports _HashCodeMethod
+//- @isNull ref/imports IsNullMethod
 //- @"java.util" ref UtilPackage
-import static java.util.Objects.hashCode;
+import static java.util.Objects.isNull;
 
 //- @staticMethod ref/imports StaticBool
 //- @staticMethod ref/imports StaticInt
@@ -45,6 +45,13 @@ public class Imports {
     System.err.println(java.util.Map.Entry.class);
     //- @Entry ref MapEntryClass
     System.err.println(Entry.class);
+
+    //- @isNull ref IsNullMethod
+    isNull(CASE_INSENSITIVE_ORDER);
+    isNull(new LinkedList<>());
+
+    //- @staticMethod ref StaticBool
+    staticMethod(member() == staticMember());
   }
 }
 
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/JvmCrossFile.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/JvmCrossFile.java
index de51b073c..ec95ad5f2 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/JvmCrossFile.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/JvmCrossFile.java
@@ -4,13 +4,13 @@ package pkg;
 
 //- @CONSTANT ref/imports ConstantMember
 import static pkg.Files.CONSTANT;
-//- @Inner ref/imports InnerClass
-import static pkg.Files.Inner;
 //- @staticMethod ref/imports StaticMethod
 import static pkg.Files.staticMethod;
 //- @INSTANCE ref/imports InstanceMember
 import static pkg.Files.INSTANCE;
 
+//- @Inner ref/imports InnerClass
+import pkg.Files.Inner;
 import pkg.Files.Inter;
 import pkg.Files.OtherDecl;
 
@@ -43,6 +43,9 @@ public class JvmCrossFile {
   //- @OtherDecl ref ODecl
   OtherDecl f3;
 
+  //- @Inner ref InnerClass
+  Inner in;
+
   //- @Inter ref Inter
   Inter i;
 
@@ -57,6 +60,8 @@ public class JvmCrossFile {
     //- @staticMethod ref StaticMethod
     staticMethod();
     //- @CONSTANT ref ConstantMember
-    System.out.println(Files.CONSTANT);
+    System.out.println(CONSTANT);
+    //- @INSTANCE ref InstanceMember
+    System.out.println(INSTANCE);
   }
 }
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Lambdas.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Lambdas.java
index 1cbaae4bd..44efce590 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Lambdas.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/Lambdas.java
@@ -1,8 +1,5 @@
 package pkg;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
 import java.util.function.Function;
 
 @SuppressWarnings({"unused", "JavaLangClash", "UnnecessaryLambda"})
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/regression/BUILD b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/regression/BUILD
index cb26fd819..dd005cd01 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/regression/BUILD
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/regression/BUILD
@@ -5,6 +5,10 @@ load("//kythe/java/com/google/devtools/kythe/extractors/java/bazel:aspect.bzl",
 java_library(
     name = "regression",
     srcs = glob(["**/*.java"]),
+    javacopts = [
+        "-Xep:AnnotationPosition:OFF",
+        "-Xep:MultipleTopLevelClasses:OFF",
+    ],
     visibility = ["//kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata:__subpackages__"],
 )
 
@@ -17,6 +21,10 @@ extract_java(
 java_library(
     name = "nullable",
     srcs = ["Nullable.java"],
+    javacopts = [
+        "-Xep:AnnotationPosition:OFF",
+        "-Xep:MultipleTopLevelClasses:OFF",
+    ],
 )
 
 java_library(