How to implement a java interface in c++?
tsuraan
tsuraan@gmail.com
Thu May 18 14:17:00 GMT 2006
> No. Just add the "native" keyword to your methods in the java class like
> this:
>
> ====CppImplementation.java========================
> public class CppImplementation implements JavaInterface
> {
> public native void doIt():
> }
> =====================================
>
> Then you add a *.cpp file containing a normal C++ method implementation:
>
> #include "CppImplementation.h"
>
> void
> CppImplementation::doIt()
> {
> // Do something
> }
>
>
> The needed header file can be generated with gcjh.
This really looks a lot like
$ cat CppImplementation.h
class CppImplementation : public JavaInterface
{
public:
void doIt():
}
Are there plans in the pipe for allowing this? It seems like a
pre-processor run could go through and check if c++ classes are
extending java ones, and do some parsing work to re-phrase them to be
java files. Multiple inheritance wouldn't work that way, but for
simple things it seems like it could be done. Will it be?
More information about the Java
mailing list