« Return to Thread: Java exceptions and throws

Java exceptions and throws

by John Heisey :: Rate this Message:

Reply to Author | View in Thread

I have not figured out how to get the Java code to include the throws declaration.

%extend CCdciStreamInterface {

  ...

  void write(char *BYTE, long off, long len)
  {
    int readTimeout = 2000;
    ULONG cbWritten;
    EError error = $self->Write((void *)&BYTE[off], (ULONG)len, cbWritten,
                        (DWORD)readTimeout);
    if(error != ESuccess)
    {
      // throw
      char msg[20];
      sprintf(&msg[0], "CDCI Error: %u", error);
      SWIG_exception(SWIG_IOError, &msg[0]);
    }
    return;
  }

}

Resulting Java code:

  public final static native void CdciStreamInterface_write(long jarg1, CdciStreamInterface jarg1_, byte[] jarg2, int jarg3, int jarg4);

And

  public void write(byte[] BYTE, int off, int len) {
    CdciControllerInterfacesJNI.CdciStreamInterface_write(swigCPtr, this, BYTE, off, len);
  }


How do I get swig to include the throws declaration to the Java functions?

Thanks,
J.R. Heisey
Sr. Software Engineer
Synaptics, Inc.
3120 Scott Blvd.
Santa Clara CA 95054
+1 408 454-5373
jrheisey@...
www.synaptics.com

Enriching the Interaction between humans and intelligent devices


------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: Java exceptions and throws