Browse Source

+ support for final methods in Java classes

git-svn-id: branches/jvmbackend@18394 -
Jonas Maebe 14 years ago
parent
commit
121a141953
2 changed files with 7 additions and 3 deletions
  1. 2 0
      compiler/agjasmin.pas
  2. 5 3
      compiler/pdecsub.pas

+ 2 - 0
compiler/agjasmin.pas

@@ -677,6 +677,8 @@ implementation
           result:=result+'static ';
           result:=result+'static ';
         if is_javainterface(tdef(pd.owner.defowner)) then
         if is_javainterface(tdef(pd.owner.defowner)) then
           result:=result+'abstract ';
           result:=result+'abstract ';
+        if po_finalmethod in pd.procoptions then
+          result:=result+'final ';
         result:=result+pd.jvmmangledbasename;
         result:=result+pd.jvmmangledbasename;
       end;
       end;
 
 

+ 5 - 3
compiler/pdecsub.pas

@@ -1673,7 +1673,9 @@ begin
   if is_objectpascal_helper(tprocdef(pd).struct) and
   if is_objectpascal_helper(tprocdef(pd).struct) and
       (m_objfpc in current_settings.modeswitches) then
       (m_objfpc in current_settings.modeswitches) then
     Message1(parser_e_not_allowed_in_helper, arraytokeninfo[_FINAL].str);
     Message1(parser_e_not_allowed_in_helper, arraytokeninfo[_FINAL].str);
-  if (po_virtualmethod in pd.procoptions) then
+  if (po_virtualmethod in pd.procoptions) or
+     { all Java methods are virtual }
+     is_javaclass(tdef(pd.owner.defowner)) then
     include(pd.procoptions,po_finalmethod)
     include(pd.procoptions,po_finalmethod)
   else
   else
     Message(parser_e_only_virtual_methods_final);
     Message(parser_e_only_virtual_methods_final);
@@ -2261,13 +2263,13 @@ const
       mutexclpo     : [po_external]
       mutexclpo     : [po_external]
     ),(
     ),(
       idtok:_FINAL;
       idtok:_FINAL;
-      pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_notrecord];
+      pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_notrecord,pd_javaclass];
       handler  : @pd_final;
       handler  : @pd_final;
       pocall   : pocall_none;
       pocall   : pocall_none;
       pooption : [po_finalmethod];
       pooption : [po_finalmethod];
       mutexclpocall : [pocall_internproc];
       mutexclpocall : [pocall_internproc];
       mutexclpotype : [];
       mutexclpotype : [];
-      mutexclpo     : [po_exports,po_interrupt,po_external,po_inline]
+      mutexclpo     : [po_exports,po_interrupt,po_inline]
     ),(
     ),(
       idtok:_FORWARD;
       idtok:_FORWARD;
       pd_flags : [pd_implemen,pd_notobject,pd_notobjintf,pd_notrecord,pd_nothelper];
       pd_flags : [pd_implemen,pd_notobject,pd_notobjintf,pd_notrecord,pd_nothelper];