diff options
author | cushon <cushon@google.com> | 2018-05-21 11:17:50 -0700 |
---|---|---|
committer | Liam Miller-Cushon <cushon@google.com> | 2018-06-12 19:44:46 -0700 |
commit | 64e445733351379f7eba2b37fd34c116cc856dd1 (patch) | |
tree | 66462a3d6f899419fde6abd755ebd6808e2b93ae /javatests | |
parent | 7e5cf9a597e2ea0737b989ef46aa09d29d7fea3d (diff) | |
download | turbine-64e445733351379f7eba2b37fd34c116cc856dd1.tar.gz |
Don't crash on multiple visibility modifiers
MOE_MIGRATED_REVID=197423090
Diffstat (limited to 'javatests')
-rw-r--r-- | javatests/com/google/turbine/lower/LowerTest.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/javatests/com/google/turbine/lower/LowerTest.java b/javatests/com/google/turbine/lower/LowerTest.java index 86d4ce4..d97f46a 100644 --- a/javatests/com/google/turbine/lower/LowerTest.java +++ b/javatests/com/google/turbine/lower/LowerTest.java @@ -598,6 +598,35 @@ public class LowerTest { } } + // If an element incorrectly has multiple visibility modifiers, pick one, and rely on javac to + // report a diagnostic. + @Test + public void multipleVisibilities() throws Exception { + ImmutableMap<String, String> sources = + ImmutableMap.of("Test.java", "public protected class Test {}"); + + Map<String, byte[]> lowered = + IntegrationTestSupport.runTurbine(sources, /* classpath= */ ImmutableList.of()); + int[] testAccess = {0}; + new ClassReader(lowered.get("Test")) + .accept( + new ClassVisitor(Opcodes.ASM6) { + @Override + public void visit( + int version, + int access, + String name, + String signature, + String superName, + String[] interfaces) { + testAccess[0] = access; + } + }, + 0); + assertThat((testAccess[0] & TurbineFlag.ACC_PUBLIC) == TurbineFlag.ACC_PUBLIC).isTrue(); + assertThat((testAccess[0] & TurbineFlag.ACC_PROTECTED) == TurbineFlag.ACC_PROTECTED).isFalse(); + } + static String lines(String... lines) { return Joiner.on("\n").join(lines); } |