to the main page about the tutorial  INTERACTIVE WEB SERVICES WITH JAVA back up next

The JWIG Analyzer

The JWIG analyzer works as follows:

JWIG analyzer

The three checks guarantee that:

On the example program:
import dk.brics.jwig.runtime.*;

public class Greetings extends Service {
  String greeting = null;

  public class Welcome extends Session {
    XML cover = [[ <html>
                   <body bgcolor=[color]>
                    <{ if (greeting==null)
                         return [[ <em>Hello World!</em> ]];
                         return [[ <b><[g]></b> ]] <[g=greeting];
                 </html> ]];
    XML getinput = [[ <form>Enter today's greeting: 
                         <input type="text" name="salutation"/>
                         <input type="submit"/>
                      </form> ]];
    XML message = [[ Welcome to <[what]>. ]];

    public void main() {
      XML h = cover<[color="white",contents=message];
      if (greeting==null) {
        show cover<[color="red",contents=getinput];
        greeting = receive salutation;
      exit h<[what=[[<b>BRICS</b>]]];

the analyzer goes through eight phases:

  1. single methods
  2. code gaps
  3. method invocations
  4. exceptions
  5. show and receive operations
  6. arrays
  7. field variables
  8. graph simplification
to construct a flow graph:

flow graph

The possible documents being shown at the exit statement are then approximated by a summary graph:

summary graph

No errors are found, in this case.

The key idea is the notion of summary graphs: a summary graph approximates the set of XML templates that may appear at a given program point for a given variable or expression.