TransitionUndefinedException does not reach AppClass
Translates state machine into a target programming language.
Brought to you by:
cwrapp
Hello,
I would like to report a potential issue with the generator for java and java7. According to the SMC Programer's Manual:
- Since SMC does not force you to specify a Default state or Default transition, it is possible that there is no transition defined. If SMC falls through this list, it will throw a "Transition Undefined" exception.
- global Default transition throws a "Transition Undefined" exception
That is the case, but that exception does not get to the AppClass. It is being absorbed by the catch block that is generated in the method for each transition.
catch (Throwable tex)
{
if (mDebugFlag)
{
tex.printStackTrace(mDebugStream);
}
}
Would it be possible to update the generator for java and java7, so that it allows for the TransitionUndefinedException exception to reach the AppClass? For example:
catch (Throwable tex)
{
if (mDebugFlag)
{
tex.printStackTrace(mDebugStream);
}
if (tex instanceof TransitionUndefinedException)
{
throw (TransitionUndefinedException)tex;
}
}
OR
catch (Throwable tex)
{
if (mDebugFlag)
{
tex.printStackTrace(mDebugStream);
}
if (tex instanceof RuntimeException)
{
throw (RuntimeException)tex;
}
}
Thank you!
... actually, the one below is the more appropriate one, as it will also propagate the StateUndefinedException that can be thrown by getState().
Last edit: Martin Baltiyski 2021-01-14
This is an issue only when using -java7 as the target language. When using -java no try/catch block is generated. Therefore the above re-throw code will be added to java7 target encoding so as to bring -java7 behavior in line with -java.