Annotate bytecode packages for nullness

PiperOrigin-RevId: 386122520
diff --git a/java/com/google/turbine/binder/bytecode/BytecodeBinder.java b/java/com/google/turbine/binder/bytecode/BytecodeBinder.java
index d2383b6..af8a8a3 100644
--- a/java/com/google/turbine/binder/bytecode/BytecodeBinder.java
+++ b/java/com/google/turbine/binder/bytecode/BytecodeBinder.java
@@ -16,6 +16,8 @@
 
 package com.google.turbine.binder.bytecode;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.turbine.binder.bound.EnumConstantValue;
@@ -206,6 +208,7 @@
   public static ModuleInfo bindModuleInfo(String path, Supplier<byte[]> bytes) {
     ClassFile classFile = ClassReader.read(path, bytes.get());
     ClassFile.ModuleInfo module = classFile.module();
+    requireNonNull(module, path);
     return new ModuleInfo(
         module.name(),
         module.version(),
diff --git a/java/com/google/turbine/bytecode/ClassFile.java b/java/com/google/turbine/bytecode/ClassFile.java
index e979edc..141c145 100644
--- a/java/com/google/turbine/bytecode/ClassFile.java
+++ b/java/com/google/turbine/bytecode/ClassFile.java
@@ -33,22 +33,22 @@
 
   private final int access;
   private final String name;
-  private final String signature;
-  private final String superClass;
+  private final @Nullable String signature;
+  private final @Nullable String superClass;
   private final List<String> interfaces;
   private final List<MethodInfo> methods;
   private final List<FieldInfo> fields;
   private final List<AnnotationInfo> annotations;
   private final List<InnerClass> innerClasses;
   private final ImmutableList<TypeAnnotationInfo> typeAnnotations;
-  @Nullable private final ModuleInfo module;
-  @Nullable private final String transitiveJar;
+  private final @Nullable ModuleInfo module;
+  private final @Nullable String transitiveJar;
 
   public ClassFile(
       int access,
       String name,
-      String signature,
-      String superClass,
+      @Nullable String signature,
+      @Nullable String superClass,
       List<String> interfaces,
       List<MethodInfo> methods,
       List<FieldInfo> fields,
@@ -82,12 +82,12 @@
   }
 
   /** The value of the Signature attribute. */
-  public String signature() {
+  public @Nullable String signature() {
     return signature;
   }
 
   /** The super class. */
-  public String superName() {
+  public @Nullable String superName() {
     return superClass;
   }
 
@@ -139,8 +139,8 @@
     private final int access;
     private final String name;
     private final String descriptor;
-    @Nullable private final String signature;
-    private final Const.@Nullable Value value;
+    private final @Nullable String signature;
+    private final @Nullable Value value;
     private final List<AnnotationInfo> annotations;
     private final ImmutableList<TypeAnnotationInfo> typeAnnotations;
 
@@ -149,7 +149,7 @@
         String name,
         String descriptor,
         @Nullable String signature,
-        Value value,
+        @Nullable Value value,
         List<AnnotationInfo> annotations,
         ImmutableList<TypeAnnotationInfo> typeAnnotations) {
       this.access = access;
@@ -730,16 +730,16 @@
         }
       }
 
-      private final TypePath parent;
-      private final TypePath.Kind kind;
+      private final @Nullable TypePath parent;
+      private final TypePath.@Nullable Kind kind;
       private final int index;
 
-      private TypePath(TypePath.Kind kind, TypePath parent) {
+      private TypePath(TypePath.@Nullable Kind kind, @Nullable TypePath parent) {
         // JVMS 4.7.20.2: type_argument_index is 0 if the bound kind is not TYPE_ARGUMENT
         this(0, kind, parent);
       }
 
-      private TypePath(int index, TypePath.Kind kind, TypePath parent) {
+      private TypePath(int index, TypePath.@Nullable Kind kind, @Nullable TypePath parent) {
         this.index = index;
         this.kind = kind;
         this.parent = parent;
@@ -752,13 +752,13 @@
 
       /** The JVMS 4.7.20.2-A serialized value of the type_path_kind. */
       public byte tag() {
-        return (byte) kind.tag;
+        return (byte) requireNonNull(kind).tag;
       }
 
       /** Returns a flattened view of the type path. */
       public ImmutableList<TypePath> flatten() {
         Deque<TypePath> flat = new ArrayDeque<>();
-        for (TypePath curr = this; curr.kind != null; curr = curr.parent) {
+        for (TypePath curr = this; requireNonNull(curr).kind != null; curr = curr.parent) {
           flat.addFirst(curr);
         }
         return ImmutableList.copyOf(flat);
@@ -770,7 +770,7 @@
   public static class ModuleInfo {
 
     private final String name;
-    private final String version;
+    private final @Nullable String version;
     private final int flags;
     private final ImmutableList<RequireInfo> requires;
     private final ImmutableList<ExportInfo> exports;
@@ -781,7 +781,7 @@
     public ModuleInfo(
         String name,
         int flags,
-        String version,
+        @Nullable String version,
         ImmutableList<RequireInfo> requires,
         ImmutableList<ExportInfo> exports,
         ImmutableList<OpenInfo> opens,
@@ -805,7 +805,7 @@
       return flags;
     }
 
-    public String version() {
+    public @Nullable String version() {
       return version;
     }
 
@@ -834,9 +834,9 @@
 
       private final String moduleName;
       private final int flags;
-      private final String version;
+      private final @Nullable String version;
 
-      public RequireInfo(String moduleName, int flags, String version) {
+      public RequireInfo(String moduleName, int flags, @Nullable String version) {
         this.moduleName = moduleName;
         this.flags = flags;
         this.version = version;
@@ -850,7 +850,7 @@
         return flags;
       }
 
-      public String version() {
+      public @Nullable String version() {
         return version;
       }
     }
diff --git a/java/com/google/turbine/bytecode/ClassReader.java b/java/com/google/turbine/bytecode/ClassReader.java
index cb72d3e..5022ff7 100644
--- a/java/com/google/turbine/bytecode/ClassReader.java
+++ b/java/com/google/turbine/bytecode/ClassReader.java
@@ -16,6 +16,8 @@
 
 package com.google.turbine.bytecode;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.errorprone.annotations.CheckReturnValue;
@@ -173,6 +175,7 @@
       String innerName = innerNameIndex != 0 ? constantPool.utf8(innerNameIndex) : null;
       int innerClassAccessFlags = reader.u2();
       if (innerName != null && (thisClass.equals(innerClass) || thisClass.equals(outerClass))) {
+        requireNonNull(outerClass);
         innerclasses.add(
             new ClassFile.InnerClass(innerClass, outerClass, innerName, innerClassAccessFlags));
       }
diff --git a/java/com/google/turbine/bytecode/sig/Sig.java b/java/com/google/turbine/bytecode/sig/Sig.java
index f759269..2e4f154 100644
--- a/java/com/google/turbine/bytecode/sig/Sig.java
+++ b/java/com/google/turbine/bytecode/sig/Sig.java
@@ -59,18 +59,18 @@
   public static class TyParamSig {
 
     private final String name;
-    @Nullable private final TySig classBound;
+    private final @Nullable TySig classBound;
     private final ImmutableList<TySig> interfaceBounds;
 
-    public TyParamSig(String name, TySig classBound, ImmutableList<TySig> interfaceBounds) {
+    public TyParamSig(
+        String name, @Nullable TySig classBound, ImmutableList<TySig> interfaceBounds) {
       this.name = name;
       this.classBound = classBound;
       this.interfaceBounds = interfaceBounds;
     }
 
     /** A single class upper-bound, or {@code null}. */
-    @Nullable
-    public TySig classBound() {
+    public @Nullable TySig classBound() {
       return classBound;
     }
 
diff --git a/java/com/google/turbine/lower/LowerSignature.java b/java/com/google/turbine/lower/LowerSignature.java
index c773a09..eb35dc7 100644
--- a/java/com/google/turbine/lower/LowerSignature.java
+++ b/java/com/google/turbine/lower/LowerSignature.java
@@ -199,11 +199,7 @@
       return null;
     }
     ImmutableList<Sig.TyParamSig> typarams = tyParamSig(info.typeParameterTypes(), env);
-
-    ClassTySig xtnd = null;
-    if (info.superClassType() != null) {
-      xtnd = classTySig((ClassTy) info.superClassType());
-    }
+    ClassTySig xtnd = classTySig((ClassTy) info.superClassType());
     ImmutableList.Builder<ClassTySig> impl = ImmutableList.builder();
     for (Type i : info.interfaceTypes()) {
       impl.add(classTySig((ClassTy) i));