list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

Tracing Methods

Tracing non api methods is possible using MOTL. Entry and/or exit of methods can be traced.

  • Method Entry: trace code is injected at the method entry.
  • Method Exit: trace code is injected at method exit before return statements if exits.

Method Entry

// this example shows how to trace
// non-generated method entry

@SuppressWarnings("deprecation")
class JavaMethod
{
  trace method();
    
  int method( int x ) {
    x += 5;
    return x;
  }
}

      

Load the above code into UmpleOnline

 

Method Exit

// this example shows how to trace generated
// method exit. In case of methods with a return
// statement, trace code is injected before
// the return

@SuppressWarnings("deprecation")
class JavaMethod
{
  trace exit method();
    
  int method( int x ) {
    x += 5;
    return x;
  }
}

      

Load the above code into UmpleOnline

 

Syntax


traceDirective : trace [[Prefix]]? [[traceEntity]] [[Postfix]] ;