Aspect-Oriented Programming with Model Checking Naoyasu Ubayashi
Tetsuo Tamai
Systems Integration Technology Center, Toshiba Corporation Tokyo, Japan
Interfaculty Initiative in Information Studies, Graduate School, University of Tokyo Tokyo, Japan
[email protected]
[email protected]
ABSTRACT
! "
# " $ # % & ' # ( # # Categories and Subject Descriptors )( *+& , - General Terms
Keywords
. # / 0# # 1.
INTRODUCTION
*'1+*'2+
3 4 4 Æ Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. AOSD 2002, Enschede, The Netherlands Copyright 2002 ACM 1-58113-469-X/02/0004... 5.00
5
6 $
! 7 8 $ " # " $ # . # " 9,
: # " . # #
% & ' # ( # # :
" # " 4 " 6
# " % . $ % # # : " # / " "
( ; # < $ # , = # # , 1 9 >
2. AOP AND RELATED ISSUES 2.1 AOP
4 *(+ #
6 ,
*''+ 0 ? *'+ : . *'=+*('+*((+ *@+ *A+ % B*(+ $ B B " B " -$
$ " . B $ " $ C C " 2.2 Issues on AOP
"
%
Example: error logging
4
4 $ *(+
% $ " #
$ #
# "
! " #$%
&
' (" " ) # "
% *+ ,
- - .. -
+ $% , *+ / 01' + 0# ( , *+
#
3 4 &
$ D
$ D
% " 7 #
" " 3 # $
< Æ 3. VERIFICATION WITH MODEL CHECKING 3.1 Model checking
" #
. # # " *1+ !
# . " . $ E 6 . " " $ % 4 0%9F0 % 9
" *1+ ?
' 0%9F 4 "
4 " & - & G$ ? H 6 :
0%9 9%99 % 9 0%9F 0%9 9%9 0%9 4 9%9 *1+
s
% M,s |= AG(
)
ThrowingException-Bar-m1 --> AF ErrorLoggin-Bar-m1
9
" , I :.-9 9%9 B ? B B 9%9 7 -,0CB B
ThrowingException -Bar-m1
Producer
put halt
get
Consumer
ErrorLogging -Bar-m1
0
1
2 HaltException
ErrorLogging -Bar-m1
ErrorLogging -Bar-m1
Example: error logging
9 " 23 4) &560#( 7 & ("
% 0%9F & " $
- 9
7 '
$ % -$ 7 ' ?
' 0%9F $ $ 3.2 Main model checkers
, I*';+ ,./*'>+ # B ? B*'(+ 7 *<+*>+ -,0CB*(2+ # B , I
:.-9 # 9%9 , I # Æ :.-9 $ " , I . # B 7 B 6 " # . " " 9%9 % 4 9%9 4 9%9
" Æ % # % ' " #
Buffer
3.3 AOP verification with model checking
% # . #
" " 4
"
$ 6 # " 7 8 4 " . $ 4. APPLICATION TO AOP
# $ % $
C0 $ 4.1 Example
?
( $ 8 8 % 8 % 8 8 %
8 8 % ! 8 % $ #$ 8 ! 7 $ $ $ B½
?
; ½ $ *'(+ B
TraceAspect Aspect for method tracing
ConcurrentAspect Aspect for concurrent processing
Basic function
Buffer Class
!" Classes
Aspects
Buffer Class :
ConcurrentAspect TraceAspect
AspectJ woven Java code
Model Checking
# $
%
%J 0 8 $ B & 1< K 1@ B # '*'(+ ) # 4.2 Checking crosscutting concerns
$ " $ " # ?
J 4 J $L ;( %¾ $ # ?
< ' % 8 2 ' ( ( % " " ¾ % $ *'(+
; % 2 " ' $
( % ! < M $ #$ % " % EE 2 Æ $ # $ ! " 0 Æ # 5. AOP-BASED MODEL CHECKING FRAMEWORK
# # # Æ 6
# # # % #
# # 5.1 Basic concepts
$ # 6 # # $ 7 % ' $ 7 1< K 1@ $ % &
: #
0# # # " # 7
" $ % #
#
% !"&
I 0# '
( ;
C
B
,
,
,
,
7-$
7-$
# M # Æ 8 # " # $ 6
# # # # 5.2 Join points needed for checking B*;+ (
- 8*'A+ $ $ # # 3 Æ % 8 $ " # #
" % ( # #
B % # % " % $ B % " % $ B 9 % $ B " # # # 5.3 Checking framework
% # # # # $ ?
= % $ # B
Program to be checked
Checking aspect X
before mothod
pre-condition
After post-condition
Checking aspect Y It is only needed to weave aspects that describe checking features corresponding to testing viewpoints.
Checking aspect Y
' !"& /
+ % +' ,
.. + , +'
+ + , +'
+
# # M B # "
# # # 6 # # ? $ # # B # " # # $ # # # 6 # # % # GG *=+ G $ # B6 " B " % # # # 6. DISCUSSION
# 3 Æ # 7 # B 7 $
? 7 $ " #
" 9%9 B
/ $ # "
)
M B ) )
B 7
#
) #
) " *'@+ *'@+ *'<+ 9 % , 9%, N # 9%, # % #
3 8 # # % ? $ #
*'2+ - % ? :- 7 & / " << '2 (@;( (22' *''+ 3 M 3& , ) **+,01 <''<(A '@@; *'(+ 3 O& B ? 6 H '@@@ *';+ 3 HB , .3& % . 0# , I ) + (; = (>@(@= '@@> *'<+ B# )& & + ... (222 *'=+ O -& : . )
) **+,00 ;=;;1@ '@@@ *'1+ O H 9 B . # . 0 9 0 9 B B& ) **,02 9 I 0 , , '(<' ((2(<( '@@> *'>+ .. O9& , . 0# & , -$ O '@@; *'A+ . 7& , 0 ( - 3 (222 *'@+ I % 0 ) & , ? / " 0 0 ) 34*5 .. 9 I 0 , , ('@( '=;'1@ (22' *(2+ O : . 9 H I B 7 ,$& -,0CB 6 L . (222 *('+ % %& & + / /<' I'< '22='2'2 '@@@ *((+ 6 I % %& , 0
. ) 34*5 .. 9 I 0 , , ('@( A@'2@ (22'
7.
APPENDIX A. Producer/Consumer problem [AOP]
CONCLUSIONS
' # ( # # 8 " 8.
REFERENCES
*'+ # . % & ) . , C,% ) **+,-- (1=(>= '@AA *(+ B &CC C *;+ % B H (22' *<+ 7 &CC # C C C *=+ 7# O& -$ -$ & - 0 M '@@@ *1+ 0 # - H )& . 0# % . % '@@@ *>+ 0 B0 ) .7 3 8 B 9 , 0, N 3& 7 & -$ ? . B , 0 ) + ... (222 *A+ 0 # O - # 6M& H M (222 *@+ ) &CC C C C
Buffer Class
, ++ !, + /*8( ) 9 9, $%:; ) # $%:/*8(; <, ' ) = >, ' ) = ?, @, 0A $% B, :'; ) C, ' ) ' D E /*8( =, , !, 0A $% 9, 0# F ( <, $% ) :'; >, :'; )
?, ' ) ' D E /*8( @, B, C,
Concurrent Aspect
, & !, + 0%++ 9, <, / ) = >, 0 ) + ?, @,
+ GGHH 0
B, C, =, , !, 9, <, >, ?, @, B, C, !=, !, !!, !9, !<, !>, !?, !@, !B, !C, 9=, 9, 9!, 99, 9<, 9>, 9?, 9@, 9B, 9C, <=, <, , =, >, >!, >9, ><,
++'++ ,
- .. +++ , ++' #0 / )) ++ /*8( # 0*( +++ , ++' + / )) = +&
/ DD
+ GGHH 0 ++5++ ,
- .. +++ , ++5 #0 / )) = .. I0 # 0*(
+ 0 --- J5II ---
F ( 0 ) # F ( 0#0
+++ , ++5 + / )) ++ /*8( +&
/
GG0 HH 0 * 0A ++ 0 ++F ++ ,
- 0 .. +++ , ++F 0 ) +&
Trace Aspect
, 6& !, *+, 9,
- - <, >, +, *+ ?, / @, K:6 0; K B, D 01' "/ C, =,
Main Class, etc. , !, 9, <, >, ?, @, B, C, =, , !, 9, <, >, ?,
60 2 2 /:; ++ ) # ++ ' ) # ' ) #
60 & & & 0 )
@, B, C, !=, !, !!, !9, !<, !>, !?, !@, !B, !C, 9=, 9, 9!, 99, 9<, 9>, 9?, 9@, 9B, 9C, <=, <, , =, >, >!, >9, ><, >>, >?, >@, >B, >C, ?=, ?, ?!, ?9, ?<, ?>, ??, ?@, ?B, ?C, @=, @, @!,
&L & &L 3 0 )
60 ' ' 60 + $JM6 ) ? ++ ++ '++ ++ ) 0
+ ) = I) $JM6 DD &L ) # &L3- ++ ++ 0
60 60 ++ ++ ++ ++ ) 0 ) = &L:; ) # &L:=; #0 I) = :; ) &L++ DD 0F (
N+ + 1+ N+ K I) $JM6K3 )) ' $JM6 + ) = I) DD N+ K# K3 :; ))
B. Aspect for model checking Verify Aspect
, N+& !, O , 9,
.. <, >, + , O ?, @,
N+ + 1+ B, N+ K I) $JM6K3 C, )) ' $JM6 =, + ) = I) DD , N+ K# K3 !, :; )) 9, <, >,