JavaMOP2.3 Online Instructions - How to Compile Monitor

From FSL
Revision as of 03:54, 23 August 2011 by Clee83 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

JavaMOP uses the name of the specification file to decide the name of the generated Aspect: the latter is the former + MonitorAspect. For example, if the specification file is HasNext.mop, the generated Aspect will be HasNextMonitorAspect. It is because that one specification file may contain more than one property, making it improper to use the property name as the name of the generated Aspect.

However, one cannot give the name of the specification file using the web interface (but we will support this functionality in the near future), and the name of the generated Aspect will always be WebTestMonitorAspect for any user input specification. Similarly, when the user chooses an example, e.g., HasNext, from the web interface, the name of the example specification file, e.g., HasNext will be used in the later code generation and the generated Aspect will be HasNextMonitorAspect. If the user changes the name of the property in the example specification, for example, to HasNextNew, the generated Aspect will still use the name of the example instead of the new property name, that is, still be HasNextMonitorAspect instead of HasNextNewMonitorAspect, because the underlying specification file keeps its name unchanged. The user should keep this in mind and manually change the Aspect name to what she/he wants.

After the AspectJ code is generated, the user can copy and save it in a .aj file. The name of the .aj file you intend to compile needs to be the same. For example, HasNextMonitorAspect should be placed in a file named HasNextMonitorAspect.aj. Then one can use any AspectJ compiler, including AJC or ABC, to weave the generated Apsect into a base program, like the following example (AJC is used in this example):

ajc -1.5 -cp <AspectJ runtime library>:<JavaMOP runtime library> -input <the base program root folder> HasNextMonitorAspect.aj

The generated Aspect uses the Apache Commons Collection library and the user should include it in the class path. It is also necessary to pass the option -1.5 because ajc defaults to Java 1.4, which does not support generics.

One may append within or !within clauses to the event definitions in JavaMOP to control the scope of instrumentation. For example, if it is certain that some class C will not trigger any event of interest, one may use !within(C) in the event definitions to ignore C during the instrumentation, improving the instrumentation efficiency. The syntax of the within clause can be found in the AspectJ documentation.

Personal tools