Download Chapter 1 SCJ Annotations User Manual

Transcript
SUPPORT methods: Every method that overrides a @SCJAllowed(SUPPORT)
method code must restate this annotation.
1.2.2
@SCJRestricted Annotation
Description: The annotation restricts the behavior of a body of a method.
Annotation Arguments:
• phase: INITIALIZATION, EXECUTION, CLEANUP, ANY(default)
• mayAllocate: true (default), false
• maySelfSuspend: true (default), false
Usage: The following restrictions may by applied to a method, further, these restrictions should apply transitively also to all the methods invoked by that particular
method.
• define a phase when a method can be executed,
• forbid allocation of a given method,
• forbid the method to be able to self-suspend.
1.2.3
@SCJAllowed and @SCJRestricted Annotations Example
The example presented in Fig. 1.4 and in Fig. 1.5 shows a simple LEVEL_1 application with one periodic event handler annotated with the @SCJAllowed and @SCJRestricted annotations. The reader should notice mainly the following :
1. @SCJAllowed(SUPPORT) is restated for all the infrastructure overriden methods,
2. @SCJRestricted(INITIALIZATION/CLEANUP) are similarly restated.
3. Other @SCJAllowed annotations are omitted assuming that the -Alevel=0/1/2
command line argument was passed to the Checker.
1.2.4
Memory Safety Annotations
The three SCJ annotations for memory safety are summarized in Table 1.1.
The important restrictions of the Annotation System are:
1. A class implementing Schedulable can be instantiated only once per a mission.
2. Static fields are @Scope(IMMORTAL) and can be passed only where an IMMORTAL type is expected.
3. Schedulable-s can be instantiated only in the Mission.initialize() method.
Version
Confidentiality: Distribution
5