You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java d.f is called. f is not overridden in Java, so Java B.f is called
JNI Java_B_f is called. Since B is virtualized, instead of calling C++ B::f, the object is checked whether if's an instance of the peer class JavaCPP_B. It's not the case, the object is a JavaCPP_D, and JavaCPP_D doesn't derive from JavaCPP_B. So f is called on the object, that is JavaCPP_D::f.
JavaCPP_D::f calls Java d.f.
How to solve this ?
Shouldn't JavaCPP_D derives from JavaCPP_B in addition of deriving from D ?
Or should we call explicity B::f and bypass dynamic invocation at the end of 2. ?
The text was updated successfully, but these errors were encountered:
D is already virtual, since inherits a virtual function.
The point ofupcast is to introduce static_cast or dynamic_cast when C cast doesn't work. That's not the case here. Look at my 2 suggestions at the end of the post. Doesn't one of them sound sane ?
This triggers an infinite recursion:
d.f
is called.f
is not overridden in Java, so JavaB.f
is calledJava_B_f
is called. SinceB
is virtualized, instead of calling C++B::f
, the object is checked whether if's an instance of the peer classJavaCPP_B
. It's not the case, the object is aJavaCPP_D
, andJavaCPP_D
doesn't derive fromJavaCPP_B
. Sof
is called on the object, that isJavaCPP_D::f
.JavaCPP_D::f
calls Javad.f
.How to solve this ?
Shouldn't
JavaCPP_D
derives fromJavaCPP_B
in addition of deriving fromD
?Or should we call explicity
B::f
and bypass dynamic invocation at the end of 2. ?The text was updated successfully, but these errors were encountered: