diff options
author | cushon <cushon@google.com> | 2019-08-14 11:12:13 -0700 |
---|---|---|
committer | Liam Miller-Cushon <cushon@google.com> | 2019-08-14 20:19:41 -0700 |
commit | 8c646deb03d5a49cf64f665396e6d9130fd87381 (patch) | |
tree | 1c895f66a334aa53777ba16f36b8d731964bdfdd | |
parent | 6610b8084bdb8d8071ed220f08eb1bbaca8bc3b9 (diff) | |
download | turbine-8c646deb03d5a49cf64f665396e6d9130fd87381.tar.gz |
Make handling of erroneous annotation class values match javac
for bug-compatibility with javac, AnnotationValues for class literals that
cannot be resolved (e.g. `@SomeAnnotation(value = NoSuch.class)`) now implement
AnnotationValue#accept by calling AnnotationValueVisitor#visitString with the
value `"<error>"`.
See: https://bugs.openjdk.java.net/browse/JDK-8229535
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=263388230
-rw-r--r-- | java/com/google/turbine/processing/TurbineAnnotationMirror.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/java/com/google/turbine/processing/TurbineAnnotationMirror.java b/java/com/google/turbine/processing/TurbineAnnotationMirror.java index 064d36a..5ea3de1 100644 --- a/java/com/google/turbine/processing/TurbineAnnotationMirror.java +++ b/java/com/google/turbine/processing/TurbineAnnotationMirror.java @@ -33,6 +33,7 @@ import com.google.turbine.processing.TurbineElement.TurbineExecutableElement; import com.google.turbine.processing.TurbineElement.TurbineFieldElement; import com.google.turbine.type.AnnoInfo; import com.google.turbine.type.Type.ErrorTy; +import com.google.turbine.type.Type.TyKind; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -255,7 +256,13 @@ class TurbineAnnotationMirror implements TurbineAnnotationValueMirror, Annotatio @Override public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) { - return v.visitType(getValue(), p); + if (value.type().tyKind() == TyKind.ERROR_TY) { + // represent unresolvable class literals as the string value "<error>" for compatibility + // with javac: https://bugs.openjdk.java.net/browse/JDK-8229535 + return v.visitString("<error>", p); + } else { + return v.visitType(getValue(), p); + } } @Override |