Menu ▾ ▴

#227 TransitionUndefinedException does not reach AppClass

SMC 7.3.0
closed-fixed
None
5
2021-11-11
2021-01-14
No

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!

Discussion

  • Martin Baltiyski

    ... actually, the one below is the more appropriate one, as it will also propagate the StateUndefinedException that can be thrown by getState().

    catch (Throwable tex)
    {
        if (mDebugFlag)
        {
            tex.printStackTrace(mDebugStream);
        }
    
        if (tex instanceof RuntimeException)
        {
            throw (RuntimeException)tex;
        }
    }
    
     

    Last edit: Martin Baltiyski 2021-01-14
  • Charles Rapp

    Charles Rapp - 2021-11-06

    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.

     
  • Charles Rapp

    Charles Rapp - 2021-11-11
    • Group: Assigned --> SMC 7.3.0
     
  • Charles Rapp

    Charles Rapp - 2021-11-11
    • status: open --> open-accepted
     
  • Charles Rapp

    Charles Rapp - 2021-11-11
    • status: open-accepted --> closed-fixed
     

Log in to post a comment.