Browse Source

* never allow hiding an inherited virtual class method or virtual constructor
by a non-virtual classmethod/constructor on the JVM target, because they
would also be picked up by the dynamic dispatch

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

Jonas Maebe 14 years ago
parent
commit
18310034d7
1 changed files with 6 additions and 2 deletions
  1. 6 2
      compiler/nobj.pas

+ 6 - 2
compiler/nobj.pas

@@ -309,10 +309,14 @@ implementation
                 begin
                 begin
 {$ifdef jvm}
 {$ifdef jvm}
                   { if the mangled names are different, the inheritance trees
                   { if the mangled names are different, the inheritance trees
-                    are different too in Java }
+                    are different too in Java; exception: when the parent method
+                    is a virtual class method or virtual constructor, because
+                    those are looked up dynamicall by name }
                   javanewtreeok:=
                   javanewtreeok:=
                     is_java_class_or_interface(_class) and
                     is_java_class_or_interface(_class) and
-                    (pd.jvmmangledbasename(false)<>vmtpd.jvmmangledbasename(false));
+                    (pd.jvmmangledbasename(false)<>vmtpd.jvmmangledbasename(false)) and
+                    ((vmtpd.proctypeoption<>potype_constructor) and
+                     not(po_staticmethod in vmtpd.procoptions));
 {$endif}
 {$endif}
                   if not(po_reintroduce in pd.procoptions) and
                   if not(po_reintroduce in pd.procoptions) and
                      not(po_java_nonvirtual in vmtpd.procoptions) then
                      not(po_java_nonvirtual in vmtpd.procoptions) then