viatra / EMF-IncQuery

This repository is only kept for historic reasons. All development happens on eclipse.org
http://eclipse.org/viatra
13 stars 4 forks source link

NPE from EMFPatternMatcherContext #251

Closed istvanrath closed 11 years ago

istvanrath commented 12 years ago

To reproduce: attempt to run a pattern referring to a non-existing EReference type:

pattern coursesOfTeacherNames(TName, CName) = {
    Teacher.courses(T,C);
    Teacher.name(T, TName); 
    Course.subject<<s>>(C, CName); // .subjects does not exist in the metamodel
 } 

Result:

!ENTRY org.eclipse.viatra2.patternlanguage.emf.ui 4 0 2012-07-24 13:57:04.727
!MESSAGE EMF-IncQuery Base encountered an error while traversing the EMF model to gather new information. 

!STACK 0
org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.RetePatternBuildException: Error during constructing Rete pattern matcher; please review Error Log and consult developers
    at org.eclipse.viatra2.emf.incquery.runtime.internal.matcherbuilder.EPMBuilder.construct(EPMBuilder.java:72)
    at org.eclipse.viatra2.emf.incquery.runtime.internal.matcherbuilder.EPMBuilder.construct(EPMBuilder.java:1)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.boundary.ReteBoundary.construct(ReteBoundary.java:552)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.boundary.ReteBoundary.accessProduction(ReteBoundary.java:483)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.matcher.ReteEngine$1.call(ReteEngine.java:178)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.matcher.ReteEngine$1.call(ReteEngine.java:1)
    at org.eclipse.viatra2.emf.incquery.base.core.NavigationHelperImpl.coalesceTraversals(NavigationHelperImpl.java:644)
    at org.eclipse.viatra2.emf.incquery.runtime.internal.EMFPatternMatcherRuntimeContext.coalesceTraversals(EMFPatternMatcherRuntimeContext.java:200)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.matcher.ReteEngine.accessMatcher(ReteEngine.java:174)
    at org.eclipse.viatra2.emf.incquery.runtime.api.GenericPatternMatcher.accessMatcher(GenericPatternMatcher.java:114)
    at org.eclipse.viatra2.emf.incquery.runtime.api.GenericPatternMatcher.<init>(GenericPatternMatcher.java:69)
    at org.eclipse.viatra2.emf.incquery.runtime.api.GenericPatternMatcher.<init>(GenericPatternMatcher.java:55)
    at org.eclipse.viatra2.emf.incquery.queryexplorer.content.matcher.ObservablePatternMatcherRoot.addMatchersForPatterns(ObservablePatternMatcherRoot.java:163)
    at org.eclipse.viatra2.emf.incquery.queryexplorer.content.matcher.ObservablePatternMatcherRoot.registerPattern(ObservablePatternMatcherRoot.java:131)
    at org.eclipse.viatra2.emf.incquery.queryexplorer.handlers.RuntimeMatcherRegistrator.run(RuntimeMatcherRegistrator.java:106)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3944)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3621)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:585)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:540)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Caused by: java.lang.NullPointerException
    at org.eclipse.viatra2.emf.incquery.runtime.internal.EMFPatternMatcherContext.printType(EMFPatternMatcherContext.java:240)
    at org.eclipse.viatra2.emf.incquery.runtime.internal.EMFPatternMatcherContext.printType(EMFPatternMatcherContext.java:239)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.psystem.basicenumerables.TypeBinary.keyToString(TypeBinary.java:69)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.psystem.KeyedEnumerablePConstraint.toStringRestRest(KeyedEnumerablePConstraint.java:41)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.psystem.EnumerablePConstraint.toStringRest(EnumerablePConstraint.java:62)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.psystem.BasePConstraint.toString(BasePConstraint.java:45)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.basiclinear.OrderingHeuristics$1.doCompare(OrderingHeuristics.java:62)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.util.OrderingCompareAgent.compare(OrderingCompareAgent.java:42)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.basiclinear.OrderingHeuristics.compare(OrderingHeuristics.java:65)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.basiclinear.OrderingHeuristics.compare(OrderingHeuristics.java:1)
    at java.util.Collections.min(Collections.java:611)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.basiclinear.BasicLinearLayout.layout(BasicLinearLayout.java:81)
    at org.eclipse.viatra2.emf.incquery.runtime.internal.matcherbuilder.EPMBuildScaffold.construct(EPMBuildScaffold.java:60)
    at org.eclipse.viatra2.emf.incquery.runtime.internal.matcherbuilder.EPMBuilder.construct(EPMBuilder.java:70)
    ... 40 more
bergmanngabor commented 12 years ago

Analysis: the pattern is parsed, the corresponding EStructuralFeature is left as an unresolvable proxy. The engine wants to access the name of the feature, and gets null.

Since this issue is about the engine processing a Pattern that hopefully would not pass validation, let's see if we can reproduce this after #134.

ujhelyiz commented 12 years ago

@istvanrath Please check whether this is already solved.

istvanrath commented 11 years ago

The NPE is gone (which is good), but there is another UI-specific issue. I'll create a separate ticket for that.