From 121a1419538524647aa80c9fef2081a089d7b2f3 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 20 Aug 2011 07:55:55 +0000 Subject: [PATCH] + support for final methods in Java classes git-svn-id: branches/jvmbackend@18394 - --- compiler/agjasmin.pas | 2 ++ compiler/pdecsub.pas | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/agjasmin.pas b/compiler/agjasmin.pas index 0fa934da2d..5c59374703 100644 --- a/compiler/agjasmin.pas +++ b/compiler/agjasmin.pas @@ -677,6 +677,8 @@ implementation result:=result+'static '; if is_javainterface(tdef(pd.owner.defowner)) then result:=result+'abstract '; + if po_finalmethod in pd.procoptions then + result:=result+'final '; result:=result+pd.jvmmangledbasename; end; diff --git a/compiler/pdecsub.pas b/compiler/pdecsub.pas index a055066b1f..7e7eb9c2aa 100644 --- a/compiler/pdecsub.pas +++ b/compiler/pdecsub.pas @@ -1673,7 +1673,9 @@ begin if is_objectpascal_helper(tprocdef(pd).struct) and (m_objfpc in current_settings.modeswitches) then 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) else Message(parser_e_only_virtual_methods_final); @@ -2261,13 +2263,13 @@ const mutexclpo : [po_external] ),( 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; pocall : pocall_none; pooption : [po_finalmethod]; mutexclpocall : [pocall_internproc]; mutexclpotype : []; - mutexclpo : [po_exports,po_interrupt,po_external,po_inline] + mutexclpo : [po_exports,po_interrupt,po_inline] ),( idtok:_FORWARD; pd_flags : [pd_implemen,pd_notobject,pd_notobjintf,pd_notrecord,pd_nothelper];