diff --git a/java/com/google/turbine/processing/TurbineElement.java b/java/com/google/turbine/processing/TurbineElement.java index 288d49a9..38745366 100644 --- a/java/com/google/turbine/processing/TurbineElement.java +++ b/java/com/google/turbine/processing/TurbineElement.java @@ -1038,7 +1038,12 @@ private static ImmutableSet asModifierSet(ModifierOwner modifierOwner, if ((access & TurbineFlag.ACC_STRICT) == TurbineFlag.ACC_STRICT) { modifiers.add(Modifier.STRICTFP); } - + if ((access & TurbineFlag.ACC_SEALED) == TurbineFlag.ACC_SEALED) { + modifiers.add(Modifier.SEALED); + } + if ((access & TurbineFlag.ACC_NON_SEALED) == TurbineFlag.ACC_NON_SEALED) { + modifiers.add(Modifier.NON_SEALED); + } return Sets.immutableEnumSet(modifiers); } diff --git a/javatests/com/google/turbine/processing/ProcessingIntegrationTest.java b/javatests/com/google/turbine/processing/ProcessingIntegrationTest.java index 588adcb2..c2ca38ed 100644 --- a/javatests/com/google/turbine/processing/ProcessingIntegrationTest.java +++ b/javatests/com/google/turbine/processing/ProcessingIntegrationTest.java @@ -869,6 +869,36 @@ public void recordComponents() { "enclosing: R, name: y, accessor: y() [@java.lang.Deprecated]"); } + @SupportedAnnotationTypes("*") + public static class ModifiersProcessor extends AbstractProcessor { + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latestSupported(); + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (Element e : roundEnv.getRootElements()) { + processingEnv + .getMessager() + .printMessage(Diagnostic.Kind.ERROR, String.format("%s %s", e, e.getModifiers()), e); + } + return false; + } + } + + @Test + public void modifiers() { + ImmutableList units = + parseUnit( + "=== I.java ===", // + "sealed interface I {}", + "non-sealed interface J {}"); + TurbineError e = runProcessors(units, new ModifiersProcessor()); + assertThat(e.diagnostics().stream().map(d -> d.message())) + .containsExactly("I [abstract, sealed]", "J [abstract, non-sealed]"); + } + private TurbineError runProcessors(ImmutableList units, Processor... processors) { return assertThrows( TurbineError.class,