aboutsummaryrefslogtreecommitdiff
path: root/javatests
diff options
context:
space:
mode:
authorcushon <cushon@google.com>2018-05-21 11:17:50 -0700
committerLiam Miller-Cushon <cushon@google.com>2018-06-12 19:44:46 -0700
commit64e445733351379f7eba2b37fd34c116cc856dd1 (patch)
tree66462a3d6f899419fde6abd755ebd6808e2b93ae /javatests
parent7e5cf9a597e2ea0737b989ef46aa09d29d7fea3d (diff)
downloadturbine-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.java29
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);
}