Woven Aspects from reused aspects not woven

Issue #170 resolved
Omar Alam created an issue

Hello,

I tried to load a woven aspect of Observer with both features Active and Pull selected. The weaver produces the woven aspect, however, the tool throws a NullPointer exception in TracingView. I debugged the code, and I found that inside the method initMapWovenAspects(Aspect a), the line List<WovenAspect> wovenAspectsForNext = trNext.getComesFrom(); returns HashSet from the Association concern (Observer reuses Association). And Association does not exist in mapWovenAspects.

Exception in thread "Animation Thread" java.lang.NullPointerException at ca.mcgill.ram.ui.views.TracingView.initMapWovenAspects(TracingView.java:119) at ca.mcgill.ram.ui.views.TracingView.<init>(TracingView.java:77) at ca.mcgill.ram.ui.scenes.DisplayAspectScene.showTracing(DisplayAspectScene.java:697) at ca.mcgill.ram.ui.scenes.DisplayAspectScene.<init>(DisplayAspectScene.java:173) at ca.mcgill.ram.RamApp.getExistingOrCreateAspectScene(RamApp.java:495) at ca.mcgill.ram.RamApp$9.run(RamApp.java:571) at org.mt4j.AbstractMTApplication.runApplication(AbstractMTApplication.java:359) at org.mt4j.AbstractMTApplication.draw(AbstractMTApplication.java:272) at processing.core.PApplet.handleDraw(PApplet.java:1603) at processing.core.PApplet.run(PApplet.java:1502) at java.lang.Thread.run(Thread.java:695)

Comments (14)

  1. Matthias Schoettle
    • changed status to open

    Unfortunately this problem is only semi-fixed. If, after weaving, one goes back and weaves again, the same exception occurs again. This happens, because the fix copies the references over, which removes them from its original container. I.e., the woven aspect information is then missing from the instantiated aspect.

  2. Matthias Schoettle

    I found out why this happens:

    The StructuralWeaver uses EcoreUtil.copy(...) to copy operations when weaving them. This also copies the comesFrom information, which will lead to the copied operation to point to a WovenAspect instance in the lower-level aspect.

    This means that (when removing this) it does not happen in the first place.

  3. Matthias Schoettle

    References issue #170: Temporary fix to avoid having this issue.

    The reason this occurred is because the StructuralWeaver clones operations and hence, "comesFrom" information is duplicated as well (with the same reference to the "old" WovenAspect).

    The weaver now removes this information.

    Furthermore, adding the list is removed (see comment above).

    Finally, the TracingView is now more robust in that it does not crash if the woven aspect is not in the map. In general, this should not occur, which is why an error is logged.

    → <<cset f10ea637f7c5>>

  4. Matthias Schoettle

    In our meeting on Oct. 16 we decided to move tracing up to CORE. Then, COREModel will contain this information, but the woven information will refer directly to all elements that were woven. I.e., Traceable elements don't have the "comesFrom" reference.

    That means, in order to find out which elements were woven from another model, it is enough to look up the list of woven elements (suggestion: wovenElements) in the woven model element (suggestion: WovenModel). I.e., not all TraceableElements need to be looked at to check whether they contain such information).

    In addition, we decided that it is not necessary to keep track of (i.e., to store) the complete weaving hierarchy in the woven model, because this information can be obtained by going back/looking at the reused model from the reused concern. The reused concern is copied into the current concerns folder so it will always be possible to access this information (model evolution does not impact it).

  5. Log in to comment