[vtk-developers] Handling of static function keyword in Java

Mathieu Malaterre mathieu.malaterre at gmail.com
Thu Feb 10 05:53:20 EST 2011


Hi,

  I have push a minor change to gerrit to handle static keyword in the
Java wrapped interface:

http://review.source.kitware.com/#change,888

  This works with a very minor patch to the vtkPaseJava code. However
there is a single case which is not handled, which can be seen here:

http://review.source.kitware.com/#patch,sidebyside,888,2,IO/vtkGenericEnSightReader.h

  This is a case in C++, which cannot be reproduced in Java, this can
be summarized by:

struct vtkGenericEnSightReader
{
static int CanReadFile(const char*) { return 0; }
};

struct vtkEnSightMasterServerReader : public vtkGenericEnSightReader
{
int CanReadFile(const char *) { return 2; }
};

int main()
{
  vtkGenericEnSightReader* o = vtkEnSightMasterServerReader::New();
  int v = o->CanReadFile(NULL);
  std::cout << v << std::endl;
  return 0;
}

Which prints '0', even thought the object is of type
vtkEnSightMasterServerReader. I believe this breaks the paradigm in
VTK.

So my proposition is to change the 'static' keyword into 'virtual'. This will:
- mimic the behavior found in vtkImageReader2 subclass
- allow the wrapping of VTK in Java and support static keyword

Thanks for comments,
-- 
Mathieu



More information about the vtk-developers mailing list