Skip to content

Java doesn't support Hierarchical default event handlers #507

@drekbour

Description

@drekbour

HSM works generally but the following minimal example

state ONLINE {

  ' default handling
  ONLINE : WANT

  IDLE -> REQUESTED : WANT
  REQUESTED -> IDLE : GIVE

}

[*] --> IDLE

generates the code that is legit in JS, C# etc but is a hard-stop "Unreachable code" compile error in Java

    private void IDLE_want()    {
        boolean consume_event = false;
        {
            IDLE_exit();
            REQUESTED_enter();
            
            // Step 4: complete transition. Ends event dispatch. No other behaviors are checked.
            return;
        } // end of behavior for IDLE
        
        // Check if event has been consumed before calling ancestor handler.
        if (!consume_event)       {
            ONLINE_want();
        }
    }

Feels like (not java-specifica) SS should use consume_event = true; not return; here or (far better) elide the cascading handler altogether since it is unreachable!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Will Do Soon

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions