aboutsummaryrefslogtreecommitdiff
path: root/java/com/google/turbine/binder
diff options
context:
space:
mode:
authorLiam Miller-Cushon <cushon@google.com>2021-03-15 16:31:38 -0700
committerJavac Team <javac-team+copybara@google.com>2021-03-15 16:32:17 -0700
commite80c4787cfa759cbb2aabcbf3dab97424d1a9937 (patch)
tree56f9773be46eac7a4e43164d590eb02fdc7aa813 /java/com/google/turbine/binder
parent0adcd8e8e3ce2517558a919b44ba2c6ab7991503 (diff)
downloadturbine-e80c4787cfa759cbb2aabcbf3dab97424d1a9937.tar.gz
Try out more null-checking
PiperOrigin-RevId: 363057464
Diffstat (limited to 'java/com/google/turbine/binder')
-rw-r--r--java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java48
-rw-r--r--java/com/google/turbine/binder/bytecode/package-info.java18
2 files changed, 42 insertions, 24 deletions
diff --git a/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java b/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java
index a3be4f0..722debf 100644
--- a/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java
+++ b/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java
@@ -58,7 +58,7 @@ import com.google.turbine.type.Type.IntersectionTy;
import java.lang.annotation.RetentionPolicy;
import java.util.Map;
import java.util.function.Function;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jspecify.nullness.Nullable;
/**
* A bound class backed by a class file.
@@ -73,13 +73,13 @@ public class BytecodeBoundClass implements TypeBoundClass {
private final ClassSymbol sym;
private final Env<ClassSymbol, BytecodeBoundClass> env;
private final Supplier<ClassFile> classFile;
- private final String jarFile;
+ private final @Nullable String jarFile;
public BytecodeBoundClass(
ClassSymbol sym,
Supplier<byte[]> bytes,
Env<ClassSymbol, BytecodeBoundClass> env,
- String jarFile) {
+ @Nullable String jarFile) {
this.sym = sym;
this.env = env;
this.jarFile = jarFile;
@@ -123,11 +123,11 @@ public class BytecodeBoundClass implements TypeBoundClass {
return kind.get();
}
- private final Supplier<ClassSymbol> owner =
+ private final Supplier<@Nullable ClassSymbol> owner =
Suppliers.memoize(
- new Supplier<ClassSymbol>() {
+ new Supplier<@Nullable ClassSymbol>() {
@Override
- public ClassSymbol get() {
+ public @Nullable ClassSymbol get() {
for (ClassFile.InnerClass inner : classFile.get().innerClasses()) {
if (sym.binaryName().equals(inner.innerClass())) {
return new ClassSymbol(inner.outerClass());
@@ -187,11 +187,11 @@ public class BytecodeBoundClass implements TypeBoundClass {
return access.get();
}
- private final Supplier<ClassSig> sig =
+ private final Supplier<@Nullable ClassSig> sig =
Suppliers.memoize(
- new Supplier<ClassSig>() {
+ new Supplier<@Nullable ClassSig>() {
@Override
- public ClassSig get() {
+ public @Nullable ClassSig get() {
String signature = classFile.get().signature();
if (signature == null) {
return null;
@@ -222,11 +222,11 @@ public class BytecodeBoundClass implements TypeBoundClass {
return tyParams.get();
}
- private final Supplier<ClassSymbol> superclass =
+ private final Supplier<@Nullable ClassSymbol> superclass =
Suppliers.memoize(
- new Supplier<ClassSymbol>() {
+ new Supplier<@Nullable ClassSymbol>() {
@Override
- public ClassSymbol get() {
+ public @Nullable ClassSymbol get() {
String superclass = classFile.get().superName();
if (superclass == null) {
return null;
@@ -236,7 +236,7 @@ public class BytecodeBoundClass implements TypeBoundClass {
});
@Override
- public ClassSymbol superclass() {
+ public @Nullable ClassSymbol superclass() {
return superclass.get();
}
@@ -258,11 +258,11 @@ public class BytecodeBoundClass implements TypeBoundClass {
return interfaces.get();
}
- private final Supplier<ClassTy> superClassType =
+ private final Supplier<@Nullable ClassTy> superClassType =
Suppliers.memoize(
- new Supplier<ClassTy>() {
+ new Supplier<@Nullable ClassTy>() {
@Override
- public ClassTy get() {
+ public @Nullable ClassTy get() {
if (superclass() == null) {
return null;
}
@@ -275,7 +275,7 @@ public class BytecodeBoundClass implements TypeBoundClass {
});
@Override
- public ClassTy superClassType() {
+ public @Nullable ClassTy superClassType() {
return superClassType.get();
}
@@ -481,11 +481,11 @@ public class BytecodeBoundClass implements TypeBoundClass {
return methods.get();
}
- private final Supplier<AnnotationMetadata> annotationMetadata =
+ private final Supplier<@Nullable AnnotationMetadata> annotationMetadata =
Suppliers.memoize(
- new Supplier<AnnotationMetadata>() {
+ new Supplier<@Nullable AnnotationMetadata>() {
@Override
- public AnnotationMetadata get() {
+ public @Nullable AnnotationMetadata get() {
if ((access() & TurbineFlag.ACC_ANNOTATION) != TurbineFlag.ACC_ANNOTATION) {
return null;
}
@@ -511,7 +511,7 @@ public class BytecodeBoundClass implements TypeBoundClass {
}
});
- private static RetentionPolicy bindRetention(AnnotationInfo annotation) {
+ private static @Nullable RetentionPolicy bindRetention(AnnotationInfo annotation) {
ElementValue val = annotation.elementValuePairs().get("value");
if (val == null) {
return null;
@@ -554,7 +554,7 @@ public class BytecodeBoundClass implements TypeBoundClass {
}
}
- private static ClassSymbol bindRepeatable(AnnotationInfo annotation) {
+ private static @Nullable ClassSymbol bindRepeatable(AnnotationInfo annotation) {
ElementValue val = annotation.elementValuePairs().get("value");
if (val == null) {
return null;
@@ -570,7 +570,7 @@ public class BytecodeBoundClass implements TypeBoundClass {
}
@Override
- public AnnotationMetadata annotationMetadata() {
+ public @Nullable AnnotationMetadata annotationMetadata() {
return annotationMetadata.get();
}
@@ -621,7 +621,7 @@ public class BytecodeBoundClass implements TypeBoundClass {
}
/** The jar file the symbol was loaded from. */
- public String jarFile() {
+ public @Nullable String jarFile() {
return jarFile;
}
diff --git a/java/com/google/turbine/binder/bytecode/package-info.java b/java/com/google/turbine/binder/bytecode/package-info.java
new file mode 100644
index 0000000..d2d9708
--- /dev/null
+++ b/java/com/google/turbine/binder/bytecode/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * 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.
+ */
+
+@org.jspecify.nullness.NullMarked
+package com.google.turbine.binder.bytecode;