eMoflon / emoflon-ibex-democles

Incremental unidirectional and bidirectional graph transformations with the Democles pattern matching engine
GNU General Public License v3.0
1 stars 2 forks source link

RuntimeException in Democles when changing target model of TGG #93

Open SvenPeldszus opened 5 years ago

SvenPeldszus commented 5 years ago

I am getting RuntimeException when performing changes on the target model of my TGG.

For sure this happens when the change has an influence on the containment hierarchy of model elements - e.g. I change the container of an element.

Below is the RuntimeException for another case:

java.lang.RuntimeException
    at org.gervarro.democles.incremental.emf.NotificationCollector.handleReferenceAddition(NotificationCollector.java:424)
    at org.gervarro.democles.incremental.emf.NotificationCollector.notifyChanged(NotificationCollector.java:214)
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
    at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
    at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:356)
    at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:340)
    at org.gravity.security.annotations.SecurityAnnotationsProcessorFwd.replace(SecurityAnnotationsProcessorFwd.java:83)
    at org.gravity.security.annotations.SecurityAnnotationsProcessorFwd.process(SecurityAnnotationsProcessorFwd.java:48)
    at org.gravity.tgg.modisco.MoDiscoTGGConverter.convertProject(MoDiscoTGGConverter.java:147)
    at org.gravity.tgg.modisco.MoDiscoTGGConverter.convertProject(MoDiscoTGGConverter.java:80)
    at org.gravity.tgg.test.complete.pm.ProgramModelTest.testForward(ProgramModelTest.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
    at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:748)

In this case I was executing the following code:

private void replace(TAnnotation tAnnotation, TAnnotation replacement) {
    EcoreUtil.replace(tAnnotation, replacement);
    for(Setting setting : EcoreUtil.UsageCrossReferencer.find(tAnnotation, rs)) {
        if (setting instanceof EList) {
            @SuppressWarnings("unchecked") 
            EList<TAnnotation> list = (EList<TAnnotation>) setting;
            int index = list.indexOf(tAnnotation);
            list.remove(index);
            list.add(index, replacement);
        }
        else {
            EObject eObject = setting.getEObject();
            eObject.eSet(setting.getEStructuralFeature(), replacement);
        }
    }
}

The error appears when the following statement is executed: list.add(index, replacement);