diff options
author | cushon <cushon@google.com> | 2019-06-05 20:33:11 -0700 |
---|---|---|
committer | Liam Miller-Cushon <cushon@google.com> | 2019-06-15 15:40:18 -0700 |
commit | 00defc5b5d40b311401b206b30df3e0e2ae2f826 (patch) | |
tree | 239a578f0cda635c1ecdf66377f0fefe85a04576 /javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java | |
parent | a4a2d8ede51144083c035f51a07b386c36eb2b55 (diff) | |
download | turbine-00defc5b5d40b311401b206b30df3e0e2ae2f826.tar.gz |
Load field signatures and annotations from bytecode
MOE_MIGRATED_REVID=251774958
Diffstat (limited to 'javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java')
-rw-r--r-- | javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java b/javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java index 2a0de48..c9e38e7 100644 --- a/javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java +++ b/javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java @@ -23,9 +23,11 @@ import static com.google.turbine.testing.TestClassPaths.TURBINE_BOOTCLASSPATH; import static java.util.Objects.requireNonNull; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; import com.google.common.io.ByteStreams; import com.google.turbine.binder.bound.TurbineClassValue; import com.google.turbine.binder.bound.TypeBoundClass; +import com.google.turbine.binder.bound.TypeBoundClass.FieldInfo; import com.google.turbine.binder.bound.TypeBoundClass.MethodInfo; import com.google.turbine.binder.env.CompoundEnv; import com.google.turbine.binder.env.Env; @@ -116,6 +118,21 @@ public class BytecodeBoundClassTest { .isEqualTo(Type.TyKind.ARRAY_TY); } + static class HasField { + @Deprecated List<String> foo; + } + + @Test + public void fieldTypes() { + FieldInfo f = + getBytecodeBoundClass(HasField.class).fields().stream() + .filter(x -> x.name().equals("foo")) + .collect(onlyElement()); + + assertThat(Iterables.getLast(((ClassTy) f.type()).classes()).targs()).hasSize(1); + assertThat(f.annotations()).hasSize(1); + } + private static byte[] toByteArrayOrDie(InputStream is) { try { return ByteStreams.toByteArray(is); |