Improved error message for Java strategies
By accident I forget to a the extra parameters to the invoke method and got an IllegalArgumentException. This generally indicates the wrong type of arguments rather than the wrong amount of parameters. It would be useful to check that Java strategies actually implement the specified amount of parameters in the invoke message (upon class loading) or through a more specific message (at some point I got an error saying the the strategy expected N parameters and that I only provided M).
Submitted by Sven Stork on 14 December 2012 at 22:10
Issue Log
Analysis in Stratego is expected to cover this at the use-site of the strategy, and probably does. There is indeed no static check for the consistency between the Java-side and the Stratego declaration-site of an external strategy. I suspect a reflective check at load-time would be ineffective because the method with the correct arity is already implemented and non-abstract in the Strategy class. At the same time a reflective check for the existence of an overriding method may be quite expensive. Perhaps we should provide a better error message, at invocation?
When the interpreter calls the Java method, can it catch the exception and throw a different, more specific exception?
Log in to post comments