Next: , Previous: Primitive types, Up: About CNI

10.4 Interfaces

A Java class can implement zero or more interfaces, in addition to inheriting from a single base class.

CNI allows CNI code to implement methods of interfaces. You can also call methods through interface references, with some limitations.

CNI doesn't understand interface inheritance at all yet. So, you can only call an interface method when the declared type of the field being called matches the interface which declares that method. The workaround is to cast the interface reference to the right superinterface.

For example if you have:

     interface A
       void a();
     interface B extends A
       void b();

and declare a variable of type B in C++, you can't call a() unless you cast it to an A first.