next up previous contents
Next: Other problems Up: MPI Java Wrapper Implementation. Previous: Problems due to strong   Contents

The polymorphism of Java Datatype class

The Datatype class listed partly as following.
package MPI ;
public class Datatype {
  public Datatype() { handle = type = 0;}
  public Datatype(byte[] data) { SetupByte(data);}
  public Datatype(char[] data) { SetupChar(data);}
  private native void SetupByte(byte[] data);
  private native void SetupChar(char[] data);
  private long handle, type;
  private int size;
There are constructors for each java datatype array. In each constructor, it will invoke a native method with different identifier that store the memory address into 64 bits handle variable, store the corresponding MPI_Datatype object (eg. MPI_CHAR, MPI_SHORT, ...) into 64 bits type variable, and the buffer size into size variable.

The original MPI call in C/C++

MPI_Send(void*, int size, MPI_Datatype, int dest, int tag, MPI_Comm);
would become much simpler in Java
MPI.Comm.Send(MPI.Datatype, int dest, int tag);

Bryan Carpenter 2002-07-12