library multithreading; --------------------------------------------- DontCallThreadRun --------------------------------------------- --Goes through all the methods to check if the following rule is followed: --Don't call Thread.run() helper def: dontCallThreadRun() : Set(smm!Measure) = java!MethodDeclaration.allInstances() -> select (m | m.name='run' ) -> select (m | m.abstractTypeDeclaration <> OclUndefined ) -> select (m | m.abstractTypeDeclaration.name = 'Thread' ) -> collect (m | thisModule.MeasureDontCallThreadRun(m)); --------------------------------------------- AvoidThreadGroup --------------------------------------------- --Goes through all the variables to check if the following rule is followed: --Avoid using java.lang.ThreadGroup; helper def: avoidThreadGroup() : Set(smm!Measure) = java!VariableDeclarationStatement.allInstances() -> select(variable | variable.type.type.name = 'ThreadGroup') -> collect(variable | thisModule.measureAvoidThreadGroup(variable) ); --------------------------------------------- UseNotifyAllInsteadOfNotify --------------------------------------------- -- Returns a set of measures each time the method 'notify()' is used instead of 'notifyAll()' helper def: useNotifyAllInsteadOfNotify(): Set(smm!Measure) = -- Get the method declarations of notify() and for each of their MethodInvocation usages, create a measure java!MethodDeclaration.allInstances() ->select(methodDeclaration | methodDeclaration.name = 'notify') ->collect (methodDeclaration |methodDeclaration.usages ->collect(methodInvocation | thisModule.MeasureUseNotifyAllInsteadOfNotify(methodInvocation))) ;