www.delorie.com/gnu/docs/gcc/gcj_41.html   search  
 
Buy the book!


Guide to GNU gcj

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.9.4 Instance methods

Calling a Java instance method from a C++ CNI method is done using the standard C++ syntax, e.g.:

 
// First create the Java object.
java::lang::Integer *x = new java::lang::Integer(234);
// Now call a method.
jint prim_value = x->intValue();
if (x->longValue == 0) 
  ...

Defining a Java native instance method is also done the natural way:

 
#include <java/lang/Integer.h>

jdouble
java::lang:Integer::doubleValue()
{
  return (jdouble) value;
}


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003