diff --git a/java/com/google/turbine/binder/CtSymClassBinder.java b/java/com/google/turbine/binder/CtSymClassBinder.java index f687de99..c1f806dd 100644 --- a/java/com/google/turbine/binder/CtSymClassBinder.java +++ b/java/com/google/turbine/binder/CtSymClassBinder.java @@ -47,8 +47,7 @@ /** Constructs a platform {@link ClassPath} from the current JDK's ct.sym file. */ public final class CtSymClassBinder { - @Nullable - public static ClassPath bind(String version) throws IOException { + public static @Nullable ClassPath bind(String version) throws IOException { String javaHome = JAVA_HOME.value(); requireNonNull(javaHome, "attempted to use --release, but JAVA_HOME is not set"); Path ctSym = Paths.get(javaHome).resolve("lib/ct.sym"); diff --git a/java/com/google/turbine/binder/JimageClassBinder.java b/java/com/google/turbine/binder/JimageClassBinder.java index 0c17f2fa..53a6a3ad 100644 --- a/java/com/google/turbine/binder/JimageClassBinder.java +++ b/java/com/google/turbine/binder/JimageClassBinder.java @@ -185,9 +185,8 @@ private class JimageTopLevelIndex implements TopLevelIndex { final Scope topLevelScope = new Scope() { - @Nullable @Override - public LookupResult lookup(LookupKey lookupKey) { + public @Nullable LookupResult lookup(LookupKey lookupKey) { // Find the longest prefix of the key that corresponds to a package name. // TODO(cushon): SimpleTopLevelIndex uses a prefix map for this, does it matter? Scope scope = null; @@ -223,9 +222,8 @@ public Scope scope() { return null; } return new PackageScope() { - @Nullable @Override - public LookupResult lookup(LookupKey lookupKey) { + public @Nullable LookupResult lookup(LookupKey lookupKey) { ClassSymbol sym = packageClassesBySimpleName.get(packageName, lookupKey.first().value()); return sym != null ? new LookupResult(sym, lookupKey) : null; } diff --git a/java/com/google/turbine/binder/Processing.java b/java/com/google/turbine/binder/Processing.java index 5e665778..ec77c768 100644 --- a/java/com/google/turbine/binder/Processing.java +++ b/java/com/google/turbine/binder/Processing.java @@ -79,8 +79,7 @@ /** Top level annotation processing logic, see also {@link Binder}. */ public class Processing { - @Nullable - static BindingResult process( + static @Nullable BindingResult process( TurbineLog log, final ImmutableList initialSources, final ClassPath classpath, @@ -546,8 +545,7 @@ public abstract static class ProcessorInfo { * The classloader to use for annotation processor implementations, and any annotations they * access reflectively. */ - @Nullable - abstract ClassLoader loader(); + abstract @Nullable ClassLoader loader(); /** Command line annotation processing options, passed to javac with {@code -Akey=value}. */ abstract ImmutableMap options(); diff --git a/java/com/google/turbine/binder/bound/ModuleInfo.java b/java/com/google/turbine/binder/bound/ModuleInfo.java index 5eeed049..5dc87202 100644 --- a/java/com/google/turbine/binder/bound/ModuleInfo.java +++ b/java/com/google/turbine/binder/bound/ModuleInfo.java @@ -25,7 +25,7 @@ public class ModuleInfo { private final String name; - @Nullable private final String version; + private final @Nullable String version; private final int flags; private final ImmutableList annos; private final ImmutableList requires; @@ -59,8 +59,7 @@ public String name() { return name; } - @Nullable - public String version() { + public @Nullable String version() { return version; } diff --git a/java/com/google/turbine/binder/bound/TypeBoundClass.java b/java/com/google/turbine/binder/bound/TypeBoundClass.java index 5a145948..1d7a4cc4 100644 --- a/java/com/google/turbine/binder/bound/TypeBoundClass.java +++ b/java/com/google/turbine/binder/bound/TypeBoundClass.java @@ -64,7 +64,7 @@ public interface TypeBoundClass extends HeaderBoundClass { /** A type parameter declaration. */ class TyVarInfo { private final IntersectionTy upperBound; - @Nullable private final Type lowerBound; + private final @Nullable Type lowerBound; private final ImmutableList annotations; public TyVarInfo( @@ -83,8 +83,7 @@ public IntersectionTy upperBound() { } /** The lower bound. */ - @Nullable - public Type lowerBound() { + public @Nullable Type lowerBound() { return lowerBound; } diff --git a/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java b/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java index 83ecc0a0..7317ba4c 100644 --- a/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java +++ b/java/com/google/turbine/binder/bytecode/BytecodeBoundClass.java @@ -137,9 +137,8 @@ public TurbineTyKind kind() { } }); - @Nullable @Override - public ClassSymbol owner() { + public @Nullable ClassSymbol owner() { return owner.get(); } diff --git a/java/com/google/turbine/binder/lookup/CompoundScope.java b/java/com/google/turbine/binder/lookup/CompoundScope.java index 17b923bc..bedf7751 100644 --- a/java/com/google/turbine/binder/lookup/CompoundScope.java +++ b/java/com/google/turbine/binder/lookup/CompoundScope.java @@ -24,7 +24,7 @@ public class CompoundScope implements Scope { private final Scope scope; - @Nullable private final Scope base; + private final @Nullable Scope base; private CompoundScope(Scope scope, @Nullable Scope base) { this.scope = checkNotNull(scope); diff --git a/java/com/google/turbine/binder/lookup/CompoundTopLevelIndex.java b/java/com/google/turbine/binder/lookup/CompoundTopLevelIndex.java index 16f34c34..e7fa45f6 100644 --- a/java/com/google/turbine/binder/lookup/CompoundTopLevelIndex.java +++ b/java/com/google/turbine/binder/lookup/CompoundTopLevelIndex.java @@ -42,9 +42,8 @@ public static CompoundTopLevelIndex of(TopLevelIndex... indexes) { private final Scope scope = new Scope() { - @Nullable @Override - public LookupResult lookup(LookupKey lookupKey) { + public @Nullable LookupResult lookup(LookupKey lookupKey) { // Return the first matching symbol. for (TopLevelIndex index : indexes) { LookupResult result = index.scope().lookup(lookupKey); diff --git a/java/com/google/turbine/binder/lookup/SimpleTopLevelIndex.java b/java/com/google/turbine/binder/lookup/SimpleTopLevelIndex.java index 4de08205..179f6039 100644 --- a/java/com/google/turbine/binder/lookup/SimpleTopLevelIndex.java +++ b/java/com/google/turbine/binder/lookup/SimpleTopLevelIndex.java @@ -40,7 +40,7 @@ public static class Node { return children.get(bit); } - @Nullable private final ClassSymbol sym; + private final @Nullable ClassSymbol sym; // TODO(cushon): the set of children is typically going to be small, consider optimizing this // to use a denser representation where appropriate. @@ -133,8 +133,7 @@ private SimpleTopLevelIndex(Node root) { final Scope scope = new Scope() { @Override - @Nullable - public LookupResult lookup(LookupKey lookupKey) { + public @Nullable LookupResult lookup(LookupKey lookupKey) { Node curr = root; while (true) { curr = curr.lookup(lookupKey.first().value()); diff --git a/java/com/google/turbine/bytecode/ClassFile.java b/java/com/google/turbine/bytecode/ClassFile.java index 2d79341c..af5ee12f 100644 --- a/java/com/google/turbine/bytecode/ClassFile.java +++ b/java/com/google/turbine/bytecode/ClassFile.java @@ -122,14 +122,12 @@ public ImmutableList typeAnnotations() { } /** A module attribute. */ - @Nullable - public ModuleInfo module() { + public @Nullable ModuleInfo module() { return module; } /** The original jar of a repackaged transitive class. */ - @Nullable - public String transitiveJar() { + public @Nullable String transitiveJar() { return transitiveJar; } @@ -177,8 +175,7 @@ public String descriptor() { } /** The value of Signature attribute. */ - @Nullable - public String signature() { + public @Nullable String signature() { return signature; } @@ -240,7 +237,7 @@ public static class MethodInfo { private final int access; private final String name; private final String descriptor; - @Nullable private final String signature; + private final @Nullable String signature; private final List exceptions; private final AnnotationInfo.@Nullable ElementValue defaultValue; private final List annotations; @@ -287,8 +284,7 @@ public String descriptor() { } /** The value of Signature attribute. */ - @Nullable - public String signature() { + public @Nullable String signature() { return signature; } diff --git a/java/com/google/turbine/bytecode/ClassReader.java b/java/com/google/turbine/bytecode/ClassReader.java index 3510d174..e3ade24d 100644 --- a/java/com/google/turbine/bytecode/ClassReader.java +++ b/java/com/google/turbine/bytecode/ClassReader.java @@ -55,7 +55,7 @@ public static ClassFile read(@Nullable String path, byte[] bytes) { return new ClassReader(path, bytes).read(); } - @Nullable private final String path; + private final @Nullable String path; private final ByteReader reader; private ClassReader(@Nullable String path, byte[] bytes) { diff --git a/java/com/google/turbine/lower/Lower.java b/java/com/google/turbine/lower/Lower.java index 0000ff60..ad1be7c8 100644 --- a/java/com/google/turbine/lower/Lower.java +++ b/java/com/google/turbine/lower/Lower.java @@ -505,8 +505,7 @@ private ImmutableList lowerAnnotations(ImmutableList a return lowered.build(); } - @Nullable - private AnnotationInfo lowerAnnotation(AnnoInfo annotation) { + private @Nullable AnnotationInfo lowerAnnotation(AnnoInfo annotation) { Boolean visible = isVisible(annotation.sym()); if (visible == null) { return null; @@ -519,8 +518,7 @@ private AnnotationInfo lowerAnnotation(AnnoInfo annotation) { * Returns true if the annotation is visible at runtime, false if it is not visible at runtime, * and {@code null} if it should not be retained in bytecode. */ - @Nullable - private Boolean isVisible(ClassSymbol sym) { + private @Nullable Boolean isVisible(ClassSymbol sym) { RetentionPolicy retention = requireNonNull(env.getNonNull(sym).annotationMetadata()).retention(); switch (retention) { diff --git a/java/com/google/turbine/lower/LowerSignature.java b/java/com/google/turbine/lower/LowerSignature.java index 5dffbf89..3afba32e 100644 --- a/java/com/google/turbine/lower/LowerSignature.java +++ b/java/com/google/turbine/lower/LowerSignature.java @@ -128,8 +128,7 @@ private TySig wildTy(WildTy ty) { * Produces a method signature attribute for a generic method, or {@code null} if the signature is * unnecessary. */ - @Nullable - public String methodSignature( + public @Nullable String methodSignature( Env env, TypeBoundClass.MethodInfo method, ClassSymbol sym) { if (!needsMethodSig(sym, env, method)) { return null; @@ -196,8 +195,8 @@ private boolean needsMethodSig( * Produces a class signature attribute for a generic class, or {@code null} if the signature is * unnecessary. */ - @Nullable - public String classSignature(SourceTypeBoundClass info, Env env) { + public @Nullable String classSignature( + SourceTypeBoundClass info, Env env) { if (!classNeedsSig(info)) { return null; } @@ -214,8 +213,7 @@ public String classSignature(SourceTypeBoundClass info, Envof()); @@ -416,8 +413,7 @@ private long parseLong(String text, int radix) { return r; } - @Nullable - private Expression unaryRest(TurbineOperatorKind op) { + private @Nullable Expression unaryRest(TurbineOperatorKind op) { boolean negate = op == TurbineOperatorKind.NEG; Expression expr = primary(negate); if (expr == null) { @@ -466,8 +462,7 @@ private Ident ident() { return new Ident(lexer.position(), lexer.stringValue()); } - @Nullable - private Expression finishClassLiteral(int pos, Tree.Type type) { + private @Nullable Expression finishClassLiteral(int pos, Tree.Type type) { while (token == Token.LBRACK) { eat(); if (token != Token.RBRACK) { @@ -487,8 +482,7 @@ private Expression finishClassLiteral(int pos, Tree.Type type) { return new ClassLiteral(pos, type); } - @Nullable - public Expression expression() { + public @Nullable Expression expression() { Expression result = expression(null); switch (token) { case EOF: @@ -502,8 +496,7 @@ public Expression expression() { } } - @Nullable - private Expression expression(TurbineOperatorKind.Precedence prec) { + private @Nullable Expression expression(TurbineOperatorKind.Precedence prec) { Expression term1 = primary(false); if (term1 == null) { return null; @@ -511,8 +504,7 @@ private Expression expression(TurbineOperatorKind.Precedence prec) { return expression(term1, prec); } - @Nullable - private Expression expression(Expression term1, TurbineOperatorKind.Precedence prec) { + private @Nullable Expression expression(Expression term1, TurbineOperatorKind.Precedence prec) { while (true) { if (token == Token.EOF) { return term1; @@ -546,8 +538,7 @@ private Expression expression(Expression term1, TurbineOperatorKind.Precedence p } } - @Nullable - private Expression assign(Expression term1, TurbineOperatorKind op) { + private @Nullable Expression assign(Expression term1, TurbineOperatorKind op) { if (!(term1 instanceof Tree.ConstVarName)) { return null; } @@ -563,8 +554,7 @@ private Expression assign(Expression term1, TurbineOperatorKind op) { return new Tree.Assign(term1.position(), name, rhs); } - @Nullable - private Expression ternary(Expression term1) { + private @Nullable Expression ternary(Expression term1) { Expression thenExpr = expression(TurbineOperatorKind.Precedence.TERNARY); if (thenExpr == null) { return null; @@ -580,8 +570,7 @@ private Expression ternary(Expression term1) { return new Tree.Conditional(position, term1, thenExpr, elseExpr); } - @Nullable - private Expression castTail(TurbineConstantTypeKind ty) { + private @Nullable Expression castTail(TurbineConstantTypeKind ty) { if (token != Token.RPAREN) { return null; } diff --git a/java/com/google/turbine/parse/StreamLexer.java b/java/com/google/turbine/parse/StreamLexer.java index b9f9c5c3..2348385f 100644 --- a/java/com/google/turbine/parse/StreamLexer.java +++ b/java/com/google/turbine/parse/StreamLexer.java @@ -65,9 +65,8 @@ private void eat() { ch = reader.next(); } - @Nullable @Override - public String javadoc() { + public @Nullable String javadoc() { String result = javadoc; javadoc = null; if (result == null) { diff --git a/java/com/google/turbine/processing/TurbineElement.java b/java/com/google/turbine/processing/TurbineElement.java index fff27b79..71c03d0c 100644 --- a/java/com/google/turbine/processing/TurbineElement.java +++ b/java/com/google/turbine/processing/TurbineElement.java @@ -574,8 +574,7 @@ public TyVarInfo get() { } }); - @Nullable - private TyVarInfo info() { + private @Nullable TyVarInfo info() { return info.get(); } diff --git a/java/com/google/turbine/processing/TurbineMessager.java b/java/com/google/turbine/processing/TurbineMessager.java index 37d6b185..b16ccea3 100644 --- a/java/com/google/turbine/processing/TurbineMessager.java +++ b/java/com/google/turbine/processing/TurbineMessager.java @@ -103,8 +103,7 @@ public void printMessage( * Returns the {@link SourceFile} that contains the declaration of the given {@link Symbol}, or * {@code null} if the symbol was not compiled from source. */ - @Nullable - private SourceFile getSource(Symbol sym) { + private @Nullable SourceFile getSource(Symbol sym) { ClassSymbol encl = ModelFactory.enclosingClass(sym); TypeBoundClass info = factory.getSymbol(encl); if (!(info instanceof SourceTypeBoundClass)) { diff --git a/java/com/google/turbine/processing/TurbineTypes.java b/java/com/google/turbine/processing/TurbineTypes.java index 32e1a990..9eb89d0a 100644 --- a/java/com/google/turbine/processing/TurbineTypes.java +++ b/java/com/google/turbine/processing/TurbineTypes.java @@ -626,8 +626,7 @@ private ClassTy substClassTy(ClassTy type, Map mapping) { * Returns a mapping that can be used to adapt the signature 'b' to the type parameters of 'a', or * {@code null} if no such mapping exists. */ - @Nullable - private static ImmutableMap getMapping(MethodTy a, MethodTy b) { + private static @Nullable ImmutableMap getMapping(MethodTy a, MethodTy b) { if (a.tyParams().size() != b.tyParams().size()) { return null; } @@ -646,8 +645,7 @@ private static ImmutableMap getMapping(MethodTy a, MethodTy b * Returns a map from formal type parameters to their arguments for a given class type, or an * empty map for non-parameterized types, or {@code null} for raw types. */ - @Nullable - private ImmutableMap getMapping(ClassTy ty) { + private @Nullable ImmutableMap getMapping(ClassTy ty) { ImmutableMap.Builder mapping = ImmutableMap.builder(); for (SimpleClassTy s : ty.classes()) { TypeBoundClass info = factory.getSymbol(s.sym()); diff --git a/java/com/google/turbine/type/Type.java b/java/com/google/turbine/type/Type.java index 5e46f883..085346af 100644 --- a/java/com/google/turbine/type/Type.java +++ b/java/com/google/turbine/type/Type.java @@ -491,8 +491,7 @@ abstract class MethodTy implements Type { public abstract Type returnType(); /** The type of the receiver parameter (see JLS 8.4.1). */ - @Nullable - public abstract Type receiverType(); + public abstract @Nullable Type receiverType(); public abstract ImmutableList parameters(); diff --git a/java/com/google/turbine/types/Canonicalize.java b/java/com/google/turbine/types/Canonicalize.java index a0ba2c4e..f944bb51 100644 --- a/java/com/google/turbine/types/Canonicalize.java +++ b/java/com/google/turbine/types/Canonicalize.java @@ -284,8 +284,7 @@ private ClassTy.SimpleClassTy instantiate( } /** Instantiates a type argument using the given mapping. */ - @Nullable - private static Type instantiate(Map mapping, Type type) { + private static @Nullable Type instantiate(Map mapping, Type type) { if (type == null) { return null; } @@ -344,8 +343,7 @@ private static Type instantiateClassTy(Map mapping, ClassTy t * Returns the type variable symbol for a concrete type argument whose type is a type variable * reference, or else {@code null}. */ - @Nullable - private static TyVarSymbol tyVarSym(Type type) { + private static @Nullable TyVarSymbol tyVarSym(Type type) { if (type.tyKind() == TyKind.TY_VAR) { return ((TyVar) type).sym(); } diff --git a/javatests/com/google/turbine/processing/TurbineFilerTest.java b/javatests/com/google/turbine/processing/TurbineFilerTest.java index 188a75ba..83dcc706 100644 --- a/javatests/com/google/turbine/processing/TurbineFilerTest.java +++ b/javatests/com/google/turbine/processing/TurbineFilerTest.java @@ -56,9 +56,8 @@ public class TurbineFilerTest { public void setup() { Function> classpath = new Function>() { - @Nullable @Override - public Supplier apply(String input) { + public @Nullable Supplier apply(String input) { return null; } };