Method Signature for multiple return values

asked 2014-05-31 15:37:36 -0700

anonymous user


updated 2014-06-02 11:55:02 -0700

georgen gravatar image

For a method such as

<method name='GetAllIDs'>"
     <arg name='responseCode' type='u' direction='out'/>"
     <arg name='IDs' type='as' direction='out'/>"

Java interface...

public interface ServiceDescriptionBusInterface
public class GetAllIDsValues {
    @Position(0) public int responseCode;
    @Position(1) public String[] IDs;

public GetAllIDsValues GetAllIDs() throws BusException;

GetAllIDsValues result = new GetAllIDsValues();
result.IDs = new String[];

//this crashes...
result = proxy.getInterface(ServiceDescriptionBusInterface.class).GetAllIDs();

The code above is getting "java.lang.StringIndexOutOfBoundsException: length=1; regionStart=2; regionLength=-2” at proxy.getInterface. Is my bus method signature correct?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2014-06-02 12:04:10 -0700

georgen gravatar image

Your signature should be:

//note the signature matches the actual AllJoyn interface not the Java responseCode type
public GetAllIDsValues GetAllIDs() throws BusException;

AllJoyn methods support unsigned types. While Java does not. Since Java does not support unsigned types you are forced to place the unsigned type into a container that only supports a Signed type. This is something you must be aware of. If the value returned that is larger then the maximum value supported by Java Integers (Integer.MAX_VALUE = 2147483647) then the responseCode should be long not int.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2014-05-31 15:37:36 -0700

Seen: 139 times

Last updated: Jun 02 '14