[vtkusers] Coding Errors in VTK Java

Dale Greer dmgreer at airmail.net
Mon May 20 20:29:17 EDT 2002


There are some fatal coding errors in the Java interface to the vtk dll's.
For example, in vtkPoints, there's a declaration for GetPoint which returns
a pointer to a float on the stack. But in Java, GetPoint returns a reference
to a double array. If GetPoint is used in Java, the first element in the
double
array is valid, but the other two are not.

C++

float* vtkPoints::GetPoint( vtkdType id)

Java

  private native double[] GetPoint_26(int id0);
  public double[] GetPoint(int id0)
    { return GetPoint_26(id0); }


Even worse, the C++ way to get back an array of doubles is to pass by
reference in the argument, which isn't possible in Java, but which is
nevertheless attempted by the autogenerated Java interface to the dll.

C++

void vtkPoints::GetPoint( vtkIdType id, double x[3])

Java

  private native void GetPoint_27(int id0,double id1[]);
  public void GetPoint(int id0,double id1[])
    { GetPoint_27(id0,id1); }


Having pinpointed the problem, I'm not sure if I know how to fix this. Is
there someone else who could put a fix for this into the nightly build?

Dale





More information about the vtkusers mailing list