Class ArityException
- All Implemented Interfaces:
Serializable
- Since:
- 0.11
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ArityExceptioncreate(int expectedMinArity, int expectedMaxArity, int actualArity) Creates anArityExceptionto indicate that the wrong number of arguments were provided.static ArityExceptionCreates anArityExceptionto indicate that the wrong number of arguments were provided.intReturns the actual number of arguments provided by the foreign access.intReturns the maximum number of arguments that are expected.intReturns the minimum number of arguments that are expected.Methods inherited from class com.oracle.truffle.api.interop.InteropException
fillInStackTrace, getCause, initCauseMethods inherited from class java.lang.Throwable
addSuppressed, getLocalizedMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Method Details
-
getMessage
- Overrides:
getMessagein classThrowable- Since:
- 19.0
-
getExpectedMinArity
public int getExpectedMinArity()Returns the minimum number of arguments that are expected. The returned minimum arity might be less conservative than the actual specification of the executable or instantiable invoked.- Since:
- 21.0
-
getExpectedMaxArity
public int getExpectedMaxArity()Returns the maximum number of arguments that are expected. Returns a negative number if infinite arguments can be provided.- Since:
- 21.0
-
getActualArity
public int getActualArity()Returns the actual number of arguments provided by the foreign access. If a negative value is returned then the actual arity is unknown.- Returns:
- the number of provided arguments
- Since:
- 0.11
-
create
Creates anArityExceptionto indicate that the wrong number of arguments were provided. Throws anIllegalArgumentExceptionif the arguments are invalid and assertions (-ea) are enabled.This method is designed to be used in
compiledcode paths.- Parameters:
expectedMinArity- (inclusive) the minimum number of arguments expected by the executable. Must be greater or equal to zero.expectedMaxArity- (inclusive) the maximum number of arguments expected by the executable. If the maximum is negative then an infinite number of arguments is expected. If the number is positive then the maximum must be greater or equal toexpectedMinArity.actualArity- the number of provided by the executable. The actual arity must not be within range of the expected min and max arity.- Since:
- 21.2
-
create
public static ArityException create(int expectedMinArity, int expectedMaxArity, int actualArity, Throwable cause) Creates anArityExceptionto indicate that the wrong number of arguments were provided. Throws anIllegalArgumentExceptionif the arguments are invalid and assertions (-ea) are enabled.In addition a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the
InteropExceptionis translated to a source language error. If theInteropExceptionis discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of typeAbstractTruffleExceptionotherwise anIllegalArgumentExceptionis thrown.This method is designed to be used in
compiledcode paths.- Parameters:
expectedMinArity- (inclusive) the minimum number of arguments expected by the executable. Must be greater or equal to zero.expectedMaxArity- (inclusive) the maximum number of arguments expected by the executable. If the maximum is negative then an infinite number of arguments is expected. If the number is positive then the maximum must be greater or equal toexpectedMinArity.actualArity- the number of provided by the executable. The actual arity must not be within range of the expected min and max arity.cause- the guest language exception that caused the error.- Since:
- 21.2
-