Browse Source

* mark classes representing records as final
* mark sealed classes as final
* mark "final" fields as final

git-svn-id: branches/jvmbackend@18609 -

Jonas Maebe 14 years ago
parent
commit
52b62732e2
1 changed files with 5 additions and 2 deletions
  1. 5 2
      compiler/agjasmin.pas

+ 5 - 2
compiler/agjasmin.pas

@@ -555,7 +555,8 @@ implementation
             case obj.typ of
             case obj.typ of
               recorddef:
               recorddef:
                 begin
                 begin
-                  AsmWrite('.class ');
+                  { can't inherit from records }
+                  AsmWrite('.class final ');
                   if toplevelowner.symtabletype=globalsymtable then
                   if toplevelowner.symtabletype=globalsymtable then
                     AsmWrite('public ');
                     AsmWrite('public ');
                   AsmWriteln(obj.jvm_full_typename(true));
                   AsmWriteln(obj.jvm_full_typename(true));
@@ -567,6 +568,8 @@ implementation
                     odt_javaclass:
                     odt_javaclass:
                       begin
                       begin
                         AsmWrite('.class ');
                         AsmWrite('.class ');
+                        if oo_is_sealed in tobjectdef(obj).objectoptions then
+                          AsmWrite('final ');
                         if toplevelowner.symtabletype=globalsymtable then
                         if toplevelowner.symtabletype=globalsymtable then
                           AsmWrite('public ');
                           AsmWrite('public ');
                         AsmWriteln(obj.jvm_full_typename(true));
                         AsmWriteln(obj.jvm_full_typename(true));
@@ -821,7 +824,7 @@ implementation
         if (sym.typ=staticvarsym) or
         if (sym.typ=staticvarsym) or
            (sp_static in sym.symoptions) then
            (sp_static in sym.symoptions) then
           result:=result+'static ';
           result:=result+'static ';
-        if sym.varspez=vs_const then
+        if sym.varspez in [vs_const,vs_final] then
           result:=result+'final ';
           result:=result+'final ';
         result:=result+jvmmangledbasename(sym,true);
         result:=result+jvmmangledbasename(sym,true);
       end;
       end;