cderoove / damp.ekeko.aspectj

Ekeko plugin that provides support for Aspectj
Eclipse Public License 1.0
5 stars 0 forks source link

pointcut-concretizedby pointcuts != advice-pointcut pointcuts #6

Closed jfabry closed 11 years ago

jfabry commented 11 years ago

The pointcuts returned by the predicates should be of the same 'thing' so they can be unified.

Example in the AJ-LMP-RefineUsedPointcut project:

 (ekeko [?pc ?npc] (pointcut-concretizedby ?pc ?npc))
([#<ResolvedPointcutDefinition pointcut cl.pleiad.ajlmp.testRefineUsedPointcuts.FirstAspect.pc1()> #<ResolvedPointcutDefinition pointcut cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect.pc1()>])

versus

(ekeko [ ?npc ?adv] (advice-pointcut ?adv ?npc))
([#<AndPointcut (execution(* cl.pleiad.ajlmp.testRefineUsedPointcuts.BaseClass.*2(..)) && persingleton(cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect))> #<BcelAdvice (before: (execution(* cl.pleiad.ajlmp.testRefineUsedPointcuts.BaseClass.*2(..)) && persingleton(cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect))->void cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect.ajc$before$cl_pleiad_ajlmp_testRefineUsedPointcuts_SecondAspect$2$65809e0())>] [#<AndPointcut (execution(* cl.pleiad.ajlmp.testRefineUsedPointcuts.BaseClass.*2(..)) && persingleton(cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect))> #<BcelAdvice (before: (execution(* cl.pleiad.ajlmp.testRefineUsedPointcuts.BaseClass.*2(..)) && persingleton(cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect))->void cl.pleiad.ajlmp.testRefineUsedPointcuts.FirstAspect.ajc$before$cl_pleiad_ajlmp_testRefineUsedPointcuts_FirstAspect$2$65809e0())>] [#<AndPointcut (execution(* cl.pleiad.ajlmp.testRefineUsedPointcuts.BaseClass.*1(..)) && persingleton(cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect))> #<BcelAdvice (before: (execution(* cl.pleiad.ajlmp.testRefineUsedPointcuts.BaseClass.*1(..)) && persingleton(cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect))->void cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect.ajc$before$cl_pleiad_ajlmp_testRefineUsedPointcuts_SecondAspect$1$658061f())>] [#<AndPointcut (execution(* cl.pleiad.ajlmp.testRefineUsedPointcuts.BaseClass.*1(..)) && persingleton(cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect))> #<BcelAdvice (before: (execution(* cl.pleiad.ajlmp.testRefineUsedPointcuts.BaseClass.*1(..)) && persingleton(cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect))->void cl.pleiad.ajlmp.testRefineUsedPointcuts.FirstAspect.ajc$before$cl_pleiad_ajlmp_testRefineUsedPointcuts_FirstAspect$1$658061f())>])
jfabry commented 11 years ago

What I need to be able to do is something like this:

(defn 
  aspect-usedpointcut
  [?aspect ?pointcut]
  (l/fresh [?advice]
           (aspect-advice ?aspect ?advice)
           (advice-pointcut ?advice ?pointcut)))

;; does not work due to issue #6: these guys here do not have a name
(defn
  aspect-usedpointcutname
  [?aspect ?pointcutname]
  (l/fresh [?pointcut]
    (aspect-usedpointcut ?aspect ?pointcut)
    (pointcut-name ?pointcut ?pointcutname)))

And something like this:

(defn aspect-allusedpointcuts
  [?aspect ?usedpointcuts]
  (l/all
    (aspect ?aspect)
    (findall ?usedpointcut (aspect-usedpointcut ?aspect ?usedpointcut) ?usedpointcuts)))

(defn
  samepointcuts-reuse-super-sub1-sub2
  [?aspect1 ?aspect2 ?usedpc1 ?usedpc2]
  (l/fresh [?superaspect]
           (aspect-declaredsuperaspect+ ?aspect1 ?superaspect)
           (aspect-declaredsuperaspect+ ?aspect2 ?superaspect)
           (l/!= ?aspect1 ?aspect2)
           (aspect-allusedpointcuts ?aspect1 ?usedpc1)
           (aspect-allusedpointcuts ?aspect2 ?usedpc2)
           (same-elements ?usedpc1 ?usedpc2)
           )) 
jfabry commented 11 years ago

Does not seem to work for me. What is wrong with the following?

=> (ekeko [?pointcutdef ?newpointcutdef] (pointcut-concretizedby ?pointcutdef ?newpointcutdef))
([#<ResolvedPointcutDefinition pointcut cl.pleiad.ajlmp.testRefineUsedPointcuts.FirstAspect.pc1()> #<ResolvedPointcutDefinition pointcut cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect.pc1()>])

-> OK

=> (ekeko [?pointcutdef ?newpointcutdef ?pointcut] 
             (l/all
                      (pointcut-concretizedby ?pointcutdef ?newpointcutdef)
                      (pointcutdefinition-pointcut ?pointcutdef ?pointcut)))
()

-> NOK!

cderoove commented 11 years ago

Abstract pointcut definitions don't have a pointcut.

Changing ?pointcutdef into ?newpointcutdef in the second condition works:

=> (damp.ekeko/ekeko [?pointcutdef ?newpointcutdef ?pointcut]
         (pointcutdefinition-concretizedby ?pointcutdef ?newpointcutdef) 
         (pointcutdefinition-pointcut ?newpointcutdef ?pointcut))

([#<ResolvedPointcutDefinition pointcut cl.pleiad.ajlmp.testRefineUsedPointcuts.FirstAspect.pc1()> #<ResolvedPointcutDefinition pointcut cl.pleiad.ajlmp.testRefineUsedPointcuts.SecondAspect.pc1()> #<KindedPointcut execution(* cl.pleiad.ajlmp.testRefineUsedPointcuts.BaseClass.*1(..))>])

(Above commit renamed pointcut-concretizedby to pointcutdefinition-concretizedby and added a pointcutdefinition|concrete condition on its second argument to be absolutely sure that the documentation "Relation of (possibly abstract) pointcut definitions and their concretizing (definitely concrete) pointcuts." holds).

jfabry commented 11 years ago

I dont agree that abstract pointcuts dont have a pointcutdefinition. It's there although void. If I don't have that the assumption will not work.

The new, brief code for the assumption is

(damp.ekeko/ekeko [?pointcutdef ?newpointcutdef ?advice]
(pointcutdefinition-concretizedby ?pointcutdef ?newpointcutdef)
    (advice-pointcutdefinition ?advice ?pointcutdef)

should match on the use of pc1 in FirstAspect because that aspect sais:

    before() : pc1() {
        System.out.println("FirstAspect-Before-1");
    }
jfabry commented 11 years ago

After discussion I see the error of my ways.