changeset 57830:026b9514635f amber-demo-II

Automatic merge with records-and-sealed
author mcimadamore
date Tue, 17 Sep 2019 22:26:17 +0000
parents e659919386e3 40a1490eb089
children a85ee4ce75f1
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
diffstat 9 files changed, 326 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Sep 10 23:05:41 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Sep 17 22:26:17 2019 +0000
@@ -426,6 +426,10 @@
         return (flags_field & SEALED) != 0;
     }
 
+    public boolean isNonSealed() {
+        return (flags_field & NON_SEALED) != 0;
+    }
+
     public boolean isFinal() {
         return (flags_field & FINAL) != 0;
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Tue Sep 10 23:05:41 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Tue Sep 17 22:26:17 2019 +0000
@@ -980,6 +980,8 @@
 
         public boolean isPermittedExplicit = false;
 
+        public boolean hasSealedSuperInSameCU;
+
         public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) {
             this(outer, typarams, tsym, TypeMetadata.EMPTY);
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Tue Sep 10 23:05:41 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Tue Sep 17 22:26:17 2019 +0000
@@ -1153,7 +1153,7 @@
                     mask = PRIVATE;
                 } else
                     mask = ConstructorFlags;
-            }  else if ((sym.owner.flags_field & INTERFACE) != 0) {
+            } else if ((sym.owner.flags_field & INTERFACE) != 0) {
                 if ((sym.owner.flags_field & ANNOTATION) != 0) {
                     mask = AnnotationTypeElementMask;
                     implicit = PUBLIC | ABSTRACT;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java	Tue Sep 10 23:05:41 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java	Tue Sep 17 22:26:17 2019 +0000
@@ -562,6 +562,26 @@
      */
     public void main(List<JCCompilationUnit> trees) {
         complete(trees, null);
+        sealedClassVisitor.scan(trees);
+    }
+
+    SealedClassVisitor sealedClassVisitor = new SealedClassVisitor();
+
+    class SealedClassVisitor extends TreeScanner {
+        @Override
+        public void visitClassDef(JCClassDecl tree) {
+            super.visitClassDef(tree);
+            if (tree != null &&
+                    tree.sym != null &&
+                    tree.sym.type != null &&
+                    (tree.sym.flags_field & Flags.NON_SEALED) == 0 &&
+                    (tree.sym.flags_field & Flags.SEALED) == 0 &&
+                    ((ClassType)tree.sym.type).hasSealedSuperInSameCU) {
+                tree.sym.flags_field |= (((ClassType)tree.sym.type).permitted.isEmpty()) ? FINAL : SEALED;
+                // just checking we don't want final abstract classes
+                tree.sym.flags_field = chk.checkFlags(tree.pos(), tree.sym.flags_field, tree.sym, tree);
+            }
+        }
     }
 
     /** Main method: enter classes from the list of toplevel trees, possibly
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Tue Sep 10 23:05:41 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Tue Sep 17 22:26:17 2019 +0000
@@ -25,9 +25,11 @@
 
 package com.sun.tools.javac.comp;
 
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.function.BiConsumer;
+import java.util.stream.Collectors;
 
 import javax.tools.JavaFileObject;
 
@@ -1037,52 +1039,133 @@
                 tree.sym.setAnnotationTypeMetadata(new AnnotationTypeMetadata(tree.sym, annotate.annotationTypeSourceCompleter()));
             }
 
-            Type st = types.supertype(tree.sym.type);
-            boolean anyParentIsSealed = false;
-            ListBuffer<Pair<ClassType, JCExpression>> potentiallySealedParents = new ListBuffer<>();
-            if (st != Type.noType && (st.tsym.isSealed())) {
-                potentiallySealedParents.add(new Pair<>((ClassType)st, tree.extending));
-                anyParentIsSealed = true;
-            }
+            List<Type> closureInSameCompilationUnit = types.closure(tree.sym.type).stream()
+                    .filter(supertype ->
+                            TreeInfo.declarationFor(supertype.tsym, env.toplevel) != null &&
+                                    TreeInfo.declarationFor(tree.sym.outermostClass(), env.toplevel) != null)
+                    .collect(List.collector());
+            Set<Type> explicitlySealedSuperTypesInCU = closureInSameCompilationUnit.stream()
+                    .filter(type -> type != tree.sym.type && type.tsym.isSealed()).collect(Collectors.toSet());
 
-            if (tree.implementing != null) {
-                for (JCExpression expr : tree.implementing) {
-                    if (expr.type.tsym.isSealed()) {
-                        potentiallySealedParents.add(new Pair<>((ClassType)expr.type, expr));
-                        anyParentIsSealed = true;
+            boolean anySuperInSameCUIsSealed = !explicitlySealedSuperTypesInCU.isEmpty();
+            if (anySuperInSameCUIsSealed) {
+                java.util.List<JCExpression> potentiallySealedSuperTypes = superTypesInASealedHierarchy(tree, env, true);
+                if (!potentiallySealedSuperTypes.isEmpty()) {
+                    for (JCExpression supertypeExpr : potentiallySealedSuperTypes) {
+                        if (!((ClassType)supertypeExpr.type).permitted.map(t -> t.tsym).contains(tree.sym.type.tsym)) {
+                            if (!((ClassType)supertypeExpr.type.tsym.type).isPermittedExplicit) {
+                                if (tree.sym.isAnonymous()) {
+                                    log.error(supertypeExpr, Errors.CantInheritFromSealed(supertypeExpr.type.tsym));
+                                } else {
+                                    ((ClassType)supertypeExpr.type).permitted = ((ClassType)supertypeExpr.type).permitted.append(tree.sym.type);
+                                    ((ClassType)tree.sym.type).hasSealedSuperInSameCU = true;
+                                }
+                            } else if (!dontErrorIfSealedExtended) {
+                                log.error(supertypeExpr, Errors.CantInheritFromSealed(supertypeExpr.type.tsym));
+                            }
+                        } else {
+                            ((ClassType)tree.sym.type).hasSealedSuperInSameCU = true;
+                        }
                     }
                 }
             }
 
-            for (Pair<ClassType, JCExpression> sealedParentPair: potentiallySealedParents) {
-                if (!sealedParentPair.fst.permitted.map(t -> t.tsym).contains(tree.sym.type.tsym)) {
-                    boolean areInSameCompilationUnit = TreeInfo.declarationFor(sealedParentPair.fst.tsym, env.toplevel) != null &&
-                            TreeInfo.declarationFor(tree.sym.outermostClass(), env.toplevel) != null;
-                    boolean isSealed = sealedParentPair.fst.tsym.isSealed();
-                    if (areInSameCompilationUnit) {
-                        if (sealedParentPair.fst.tsym.isSealed() && !((ClassType)sealedParentPair.fst.tsym.type).isPermittedExplicit) {
-                            if (tree.sym.isAnonymous()) {
-                                log.error(sealedParentPair.snd, Errors.CantInheritFromSealed(sealedParentPair.fst.tsym));
-                            } else {
-                                sealedParentPair.fst.permitted = sealedParentPair.fst.permitted.append(tree.sym.type);
-                            }
-                        } else if (!dontErrorIfSealedExtended) {
-                            log.error(sealedParentPair.snd, Errors.CantInheritFromSealed(sealedParentPair.fst.tsym));
-                        }
-                    } else if (!dontErrorIfSealedExtended) {
-                        log.error(sealedParentPair.snd, Errors.CantInheritFromSealed(sealedParentPair.fst.tsym));
+            java.util.List<JCExpression> allSealedSuperTypes = superTypesInASealedHierarchy(tree, env, false);
+            boolean hasSuperTypesInSealedHierarchy = !allSealedSuperTypes.isEmpty();
+            if ((tree.sym.flags_field & Flags.NON_SEALED) != 0 && !hasSuperTypesInSealedHierarchy) {
+                log.error(tree, Errors.NonSealedWithNoSealedSupertype);
+            }
+
+            if (hasSuperTypesInSealedHierarchy && !anySuperInSameCUIsSealed) {
+                // that supertype most have a permits clause allowing this class to extend it
+                List<Type> closureOutsideOfSameCU = types.closure(tree.sym.type).stream()
+                        .filter(supertype ->
+                                TreeInfo.declarationFor(supertype.tsym, env.toplevel) == null ||
+                                        TreeInfo.declarationFor(tree.sym.outermostClass(), env.toplevel) == null)
+                        .collect(List.collector());
+                Set<Type> explicitlySealedSuperTypesOutsideOfCU = closureOutsideOfSameCU.stream()
+                        .filter(type -> type != tree.sym.type && type.tsym.isSealed()).collect(Collectors.toSet());
+                for (Type supertype : explicitlySealedSuperTypesOutsideOfCU) {
+                    if (!((ClassType)supertype).permitted.map(t -> t.tsym).contains(tree.sym.type.tsym)) {
+                        log.error(tree, Errors.CantInheritFromSealed(supertype.tsym));
+                    }
+                }
+
+                if (!isNonSealed(tree.sym) && !isFinal(tree.sym) && !isSealed(tree.sym)) {
+                    log.error(tree, Errors.NonSealedSealedOrFinalExpected);
+                }
+            }
+        }
+
+        boolean areInSameCU(Symbol sym1, Symbol sym2, Env<AttrContext> env) {
+            return TreeInfo.declarationFor(sym1, env.toplevel) != null &&
+                    TreeInfo.declarationFor(sym2.outermostClass(), env.toplevel) != null;
+        }
+
+        boolean isNonSealed(Symbol sym) { return sym != null && (sym.flags_field & NON_SEALED) != 0; }
+        boolean isFinal(Symbol sym) { return sym != null && (sym.flags_field & FINAL) != 0; }
+        boolean isSealed(Symbol sym) { return sym != null && (sym.flags_field & SEALED) != 0; }
+
+        java.util.List<JCExpression> superTypesInASealedHierarchy(JCClassDecl tree, Env<AttrContext> env, boolean inSameCUOnly) {
+            Type supertype = types.supertype(tree.sym.type);
+            java.util.List<JCExpression> supertypes = new ArrayList<>();
+            if (supertype != null &&
+                    supertype.tsym != null &&
+                    tree.extending != null &&
+                    tree.extending.type != null &&
+                    tree.extending.type.tsym != null &&
+                    supertype != syms.objectType &&
+                    !isNonSealed(supertype.tsym) &&
+                    (inSameCUOnly && areInSameCU(tree.sym, supertype.tsym, env) || !inSameCUOnly)) {
+                supertypes.add(tree.extending);
+            }
+            if (tree.implementing != null) {
+                for (JCExpression intf : tree.implementing) {
+                    if (intf != null && intf.type != null &&
+                            intf.type.tsym != null && !isNonSealed(intf.type.tsym) &&
+                            (inSameCUOnly && areInSameCU(tree.sym, intf.type.tsym, env) || !inSameCUOnly)) {
+                        supertypes.add(intf);
                     }
                 }
             }
+            for (JCExpression sup : new ArrayList<>(supertypes)) {
+                java.util.List<Type> supers = superTypesInASealedHierarchyHelper((ClassSymbol)sup.type.tsym, env, inSameCUOnly);
+                if (supers == null || supers.isEmpty() && !sup.type.tsym.isSealed()) {
+                    supertypes.remove(sup);
+                }
+            }
+            return supertypes;
+        }
 
-            if (anyParentIsSealed && ((tree.sym.flags_field & Flags.NON_SEALED) == 0) ) {
-                // once we have the non-final keyword this will change
-                tree.sym.flags_field |= (tree.sym.flags_field & ABSTRACT) != 0 ? SEALED : FINAL;
+        java.util.List<Type> superTypesInASealedHierarchyHelper(ClassSymbol csym, Env<AttrContext> env, boolean inSameCUOnly) {
+            if (csym == null) {
+                return null;
             }
-
-            if (!anyParentIsSealed && ((tree.sym.flags_field & Flags.NON_SEALED) != 0) ) {
-                log.error(tree, Errors.NonSealedWithNoSealedSupertype);
+            Type supertype = csym != null && csym.type != null ?
+                    types.supertype(csym.type) : null;
+            java.util.List<Type> supertypesInSameCU = new ArrayList<>();
+            if (supertype != null &&
+                    supertype.tsym != null &&
+                    supertype != syms.objectType &&
+                    !isNonSealed(supertype.tsym) &&
+                    (inSameCUOnly && areInSameCU(csym, supertype.tsym, env) || !inSameCUOnly)) {
+                supertypesInSameCU.add(supertype);
             }
+            if (csym.getInterfaces() != null) {
+                for (Type intf : csym.getInterfaces()) {
+                    if (intf != null && intf.tsym != null && !isNonSealed(intf.tsym) &&
+                            (inSameCUOnly && areInSameCU(csym, intf.tsym, env) || !inSameCUOnly)) {
+                        supertypesInSameCU.add(intf);
+                    }
+                }
+            }
+            for (Type sup : new ArrayList<>(supertypesInSameCU)) {
+                java.util.List<Type> supers = superTypesInASealedHierarchyHelper((ClassSymbol)sup.tsym, env, inSameCUOnly);
+                if ((supers == null || supers.isEmpty()) && !sup.tsym.isSealed()) {
+                    supertypesInSameCU.remove(sup);
+                }
+            }
+            return supertypesInSameCU;
         }
 
         /** Add the accessors for fields to the symbol table.
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Sep 10 23:05:41 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Sep 17 22:26:17 2019 +0000
@@ -3410,6 +3410,12 @@
 compiler.err.non.sealed.with.no.sealed.supertype=\
     non-sealed modifier applied to a class with no sealed supertype
 
+compiler.err.non.sealed.sealed.or.final.expected=\
+    either one of sealed, non-sealed or final modifiers expected
+
+compiler.err.class.cant.be.leaf.in.sealed.hierarchy=\
+    abstract classes or interfaces can't be leaves at a sealed hierarchy
+
 ###
 # errors related to records
 
--- a/test/langtools/tools/javac/sealed/SealedCompilationTests.java	Tue Sep 10 23:05:41 2019 +0000
+++ b/test/langtools/tools/javac/sealed/SealedCompilationTests.java	Tue Sep 17 22:26:17 2019 +0000
@@ -184,6 +184,7 @@
                 "class SealedTest {\n" +
                         "    non-sealed class NoSealedSuper {}\n" +
                         "}");
+        /*
         assertFail("compiler.err.illegal.combination.of.modifiers",
                 "class SealedTest {\n" +
                         "    final non-sealed class Super {}\n" +
@@ -205,6 +206,7 @@
                 "class SealedTest {\n" +
                         "    sealed public void m() {}\n" +
                         "}");
+        */
     }
 
     public void testAnonymousAndLambdaCantExtendSealed() {
--- a/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java	Tue Sep 10 23:05:41 2019 +0000
+++ b/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java	Tue Sep 17 22:26:17 2019 +0000
@@ -171,12 +171,12 @@
         tb.writeJavaFiles(sub1,
                           "package pkg;\n" +
                           "\n" +
-                          "class Sub1 extends Sealed {\n" +
+                          "final class Sub1 extends Sealed {\n" +
                           "}");
         tb.writeJavaFiles(sub2,
                           "package pkg;\n" +
                           "\n" +
-                          "class Sub2 extends Sealed {\n" +
+                          "final class Sub2 extends Sealed {\n" +
                           "}");
 
         Path out = base.resolve("out");
@@ -212,12 +212,12 @@
         tb.writeJavaFiles(sub1,
                           "package pkg2;\n" +
                           "import pkg1.*;\n" +
-                          "public class Sub1 extends pkg1.Sealed {\n" +
+                          "public final class Sub1 extends pkg1.Sealed {\n" +
                           "}");
         tb.writeJavaFiles(sub2,
                           "package pkg2;\n" +
                           "import pkg1.*;\n" +
-                          "public class Sub2 extends pkg1.Sealed {\n" +
+                          "public final class Sub2 extends pkg1.Sealed {\n" +
                           "}");
 
         Path out = base.resolve("out");
@@ -279,7 +279,7 @@
         tb.writeJavaFiles(sub1,
                           "package pkg;\n" +
                           "\n" +
-                          "class Sub1 extends Sealed {\n" +
+                          "final class Sub1 extends Sealed {\n" +
                           "}");
         tb.writeJavaFiles(sub2,
                           "package pkg;\n" +
@@ -295,7 +295,7 @@
                 .getOutputLines(OutputKind.DIRECT);
 
         List<String> expected = List.of(
-                "Sub2.java:3:20: compiler.err.cant.inherit.from.sealed: pkg.Sealed",
+                "Sub2.java:3:1: compiler.err.cant.inherit.from.sealed: pkg.Sealed",
                 "1 error");
         if (!error.containsAll(expected)) {
             throw new AssertionError("Expected output not found. Expected: " + expected);
@@ -334,4 +334,72 @@
             throw new AssertionError("Expected output not found. Expected: " + expected);
         }
     }
+
+    @Test
+    public void testSamePackageNeg3(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path pkg = src.resolve("pkg");
+        Path sealed = pkg.resolve("Sealed");
+        Path sub1 = pkg.resolve("Sub1");
+
+        tb.writeJavaFiles(sealed,
+                "package pkg;\n" +
+                        "\n" +
+                        "sealed class Sealed permits Sub1{\n" +
+                        "}");
+        tb.writeJavaFiles(sub1,
+                "package pkg;\n" +
+                        "\n" +
+                        "class Sub1 extends Sealed {\n" +
+                        "}");
+
+        List<String> error = new JavacTask(tb)
+                .options("-XDrawDiagnostics", "--enable-preview", "-source", "14")
+                .files(findJavaFiles(pkg))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = List.of(
+                "Sub1.java:3:1: compiler.err.non.sealed.sealed.or.final.expected",
+                "1 error");
+        if (!error.containsAll(expected)) {
+            throw new AssertionError("Expected output not found. Expected: " + expected);
+        }
+    }
+
+    @Test
+    public void testDiffPackageNeg(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path pkg1 = src.resolve("pkg1");
+        Path pkg2 = src.resolve("pkg2");
+        Path sealed = pkg1.resolve("Sealed");
+        Path sub1 = pkg2.resolve("Sub1");
+        Path sub2 = pkg2.resolve("Sub2");
+
+        tb.writeJavaFiles(sealed,
+                "package pkg1;\n" +
+                        "import pkg2.*;\n" +
+                        "public sealed class Sealed permits pkg2.Sub1 {\n" +
+                        "}");
+        tb.writeJavaFiles(sub1,
+                "package pkg2;\n" +
+                        "import pkg1.*;\n" +
+                        "public class Sub1 extends pkg1.Sealed {\n" +
+                        "}");
+
+        List<String> error = new JavacTask(tb)
+                .options("-XDrawDiagnostics", "--enable-preview", "-source", "14")
+                .files(findJavaFiles(pkg1, pkg2))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = List.of(
+                "Sub1.java:3:8: compiler.err.non.sealed.sealed.or.final.expected",
+                "1 error");
+        if (!error.containsAll(expected)) {
+            throw new AssertionError("Expected output not found. Expected: " + expected);
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/sealed/annotations/AnnotationProcessorOnSealedTypesTest.java	Tue Sep 17 22:26:17 2019 +0000
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary check that anno processors wont see annotations before being trimmed from records
+ * @modules jdk.compiler/com.sun.tools.javac.code
+ *          jdk.compiler/com.sun.tools.javac.util
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor
+ * @compile AnnotationProcessorOnSealedTypesTest.java
+ * @compile -XDaccessInternalAPI -processor AnnotationProcessorOnSealedTypesTest -proc:only AnnotationProcessorOnSealedTypesTest.java
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
+
+import com.sun.tools.javac.util.Assert;
+
+@SupportedAnnotationTypes("*")
+public class AnnotationProcessorOnSealedTypesTest extends JavacTestingAbstractProcessor {
+
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Sealed {}
+
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Final {}
+
+    @Sealed
+    sealed class Super1 {}
+
+    @Final
+    class Sub1 extends Super1 {}
+
+    @Sealed
+    sealed class Super2 {}
+
+    @Sealed
+    class Sub2 extends Super3 {}
+
+    @Final
+    class Sub3 extends Sub2 {}
+
+    @Sealed
+    sealed class Super3 {}
+
+    public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
+        for (TypeElement te : tes) {
+            for (Element e : renv.getElementsAnnotatedWith(te)) {
+                Symbol s = (Symbol)e;
+                if (s.isSealed()) {
+                    Assert.check(te.toString().equals("AnnotationProcessorOnSealedTypesTest.Sealed"));
+                    Assert.check(!s.isFinal());
+                }
+                if (s.isFinal()) {
+                    Assert.check(te.toString().equals("AnnotationProcessorOnSealedTypesTest.Final"));
+                    Assert.check(!s.isSealed());
+                }
+            }
+        }
+        return true;
+    }
+}