Anthony Green wrote:

> A tool, somewhat like javah, can be used to create a header file
> containing:
> 
> class Foo : public java::lang::Object
> {
> public:
>   virtual void fn1 (java::lang::String *);
>   virtual jdouble fn2 ();
>   Foo ();
>   static jint aaa;
> private:
>   static jlong bbb;
> };
> 
> These are just two faces on the same object in memory.
> 
> The main advantages are:
> 
>  - zero overhead calls between compiled Java and C++ code, and
>  - direct manipulation of Java instance variables from C++.

You have listed some advantages which might lead people to wonder what,
if any, the disadvantages are. One disadvantage is that because Java
involves only single inheritance and interfaces for defining virtual
function tables, the object layout can be done in ways that are more
efficient than the object layout used for C++ objects. Another
disadvantage is that many VMs might wish to implement memory management
in a way that takes advantage of their object layout scheme, which could
be hard or impossible while also creating objects that are just like C++
objects. These are the main problems I can think of off-hand.

alex

Reply via email to