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

Xbase interpreter throws mysterious exception #312

Closed istvanrath closed 11 years ago

istvanrath commented 11 years ago

I have noticed that the evaluation of check() expressions can have problems in interpreted mode. For instance, the stretchedArm pattern from https://github.com/ujhelyiz/EMF-IncQuery-Examples/blob/master/bodymodel/bodymodel.incquery/src/bodymodel/ymca/ymca.eiq throws the following exception in interpreted mode (while it works flawlessly in generated mode):

!ENTRY org.eclipse.viatra2.patternlanguage.emf.ui 2 0 2012-09-28 07:11:33.304
!MESSAGE The incremental pattern matcher encountered an error during check() evaluation over variables T(org.jnect.bodymodel.impl.RightElbowImpl@60e82e17 (x: 0.218052, y: 0.8626194, z: 2.26913, color_r: 0, color_g: 0, color_b: 0);org.jnect.bodymodel.impl.BodyImpl@22b10cfd;org.jnect.bodymodel.impl.RightHandImpl@40f5ea2f (x: 0.3916594, y: 1.122009, z: 2.240108, color_r: 255, color_g: 0, color_b: 0);org.jnect.bodymodel.impl.RightShoulderImpl@e72490d (x: 0.09509262, y: 0.6789038, z: 2.306966, color_r: 0, color_g: 0, color_b: 0);0.218052;0.3916594;0.09509262;0.8626194;1.122009;0.6789038;2.26913;2.240108;2.306966;). Error message: Could not invoke method: bodymodel.ymca.VectorMaths.createVector(org.jnect.bodymodel.PositionedElement,org.jnect.bodymodel.PositionedElement) on instance: null. (Developer note: IllegalStateException in [61]PredicateEvaluatorNode)

!STACK 0
java.lang.IllegalStateException: Could not invoke method: bodymodel.ymca.VectorMaths.createVector(org.jnect.bodymodel.PositionedElement,org.jnect.bodymodel.PositionedElement) on instance: null
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:738)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallOperation(XbaseInterpreter.java:713)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalFeatureCallDispatch(XbaseInterpreter.java:663)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluateArgumentExpressions(XbaseInterpreter.java:751)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallOperation(XbaseInterpreter.java:712)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalFeatureCallDispatch(XbaseInterpreter.java:663)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateVariableDeclaration(XbaseInterpreter.java:601)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(XbaseInterpreter.java:321)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218)
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204)
    at org.eclipse.viatra2.emf.incquery.runtime.internal.matcherbuilder.XBaseEvaluator.doEvaluate(XBaseEvaluator.java:136)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.boundary.AbstractEvaluator.evaluate(AbstractEvaluator.java:36)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.boundary.PredicateEvaluatorNode.evaluateTerm(PredicateEvaluatorNode.java:238)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.boundary.PredicateEvaluatorNode.evaluateExpression(PredicateEvaluatorNode.java:210)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.boundary.PredicateEvaluatorNode.check(PredicateEvaluatorNode.java:197)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.boundary.PredicateEvaluatorNode.update(PredicateEvaluatorNode.java:143)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.ReteContainer.messageConsumptionSingleThreaded(ReteContainer.java:489)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.Network.waitForReteTermination(Network.java:333)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.ReteContainer.flushUpdates(ReteContainer.java:365)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.ReteContainer.connectAndSynchronize(ReteContainer.java:184)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.ReteContainer.connectRemoteSupplier(ReteContainer.java:134)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.ReteContainer.connectRemoteNodes(ReteContainer.java:98)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.Network.connectRemoteNodes(Network.java:237)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.ReteContainerBuildable.buildPredicateChecker(ReteContainerBuildable.java:240)
    at org.eclipse.viatra2.emf.incquery.runtime.internal.matcherbuilder.XBaseCheck.doCheckOn(XBaseCheck.java:110)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.psystem.DeferredPConstraint.checkOn(DeferredPConstraint.java:36)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.basiclinear.BasicLinearLayout.layout(BasicLinearLayout.java:94)
    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)
    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:568)
    at org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.boundary.ReteBoundary.accessProduction(ReteBoundary.java:499)
    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:642)
    at org.eclipse.viatra2.emf.incquery.runtime.internal.EMFPatternMatcherRuntimeContext.coalesceTraversals(EMFPatternMatcherRuntimeContext.java:198)
    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:116)
    at org.eclipse.viatra2.emf.incquery.runtime.api.GenericPatternMatcher.<init>(GenericPatternMatcher.java:71)
    at org.eclipse.viatra2.emf.incquery.queryexplorer.content.matcher.ObservablePatternMatcherRoot.addMatchersForPatterns(ObservablePatternMatcherRoot.java:203)
    at org.eclipse.viatra2.emf.incquery.queryexplorer.content.matcher.ObservablePatternMatcherRoot.registerPattern(ObservablePatternMatcherRoot.java:171)
    at org.eclipse.viatra2.emf.incquery.queryexplorer.util.DatabindingUtil.createPatternMatcherRoot(DatabindingUtil.java:480)
    at org.eclipse.viatra2.emf.incquery.queryexplorer.content.matcher.MatcherTreeViewerRoot.addPatternMatcherRoot(MatcherTreeViewerRoot.java:40)
    at org.eclipse.viatra2.emf.incquery.queryexplorer.handlers.util.EMFModelConnector.loadModel(EMFModelConnector.java:42)
    at org.eclipse.viatra2.emf.incquery.queryexplorer.handlers.LoadModelHandler.execute(LoadModelHandler.java:46)
istvanrath commented 11 years ago

More specifically, the issue can be reproduced with https://github.com/ujhelyiz/EMF-IncQuery-Examples/blob/master/bodymodel/bodymodel.incquery/src/bodymodel/ymca/ymca.eiq, query handsAreClose_buggy

okrosa commented 11 years ago

I can reproduce the issue. I even tried it with another domain, and get the same error. I tried to use the emf objects in the java method's body and it worked well, I only get the error, if I use them as attributes in the java method. As the processing of the attributes for the interpreter is our code, the bug is likely to be ours, so I'll continue working on it.

2012/10/1 Istvan Rath notifications@github.com

More specifically, the issue can be reproduced with https://github.com/ujhelyiz/EMF-IncQuery-Examples/blob/master/bodymodel/bodymodel.incquery/src/bodymodel/ymca/ymca.eiq, query handsAreClose_buggy

— Reply to this email directly or view it on GitHubhttps://github.com/ujhelyiz/EMF-IncQuery/issues/312#issuecomment-9027207.

okrosa commented 11 years ago

Actually the attribute is correctly encapsulated in a context object for the xbase. It seems that the interpreter does not use the given classloader when it handles these attributes.

2012/10/1 András Ökrös okrosa@gmail.com

I can reproduce the issue. I even tried it with another domain, and get the same error. I tried to use the emf objects in the java method's body and it worked well, I only get the error, if I use them as attributes in the java method. As the processing of the attributes for the interpreter is our code, the bug is likely to be ours, so I'll continue working on it.

2012/10/1 Istvan Rath notifications@github.com

More specifically, the issue can be reproduced with https://github.com/ujhelyiz/EMF-IncQuery-Examples/blob/master/bodymodel/bodymodel.incquery/src/bodymodel/ymca/ymca.eiq, query handsAreClose_buggy

— Reply to this email directly or view it on GitHubhttps://github.com/ujhelyiz/EMF-IncQuery/issues/312#issuecomment-9027207.

okrosa commented 11 years ago

The error originates from the XbaseInterpreter's following method: protected Object invokeOperation(JvmOperation operation, Object receiver, List argumentValues) It actually uses the java.lang.reflect.Method class, so I have no idea how can we continue from here.

2012/10/1 András Ökrös okrosa@gmail.com

Actually the attribute is correctly encapsulated in a context object for the xbase. It seems that the interpreter does not use the given classloader when it handles these attributes.

2012/10/1 András Ökrös okrosa@gmail.com

I can reproduce the issue. I even tried it with another domain, and get the same error. I tried to use the emf objects in the java method's body and it worked well, I only get the error, if I use them as attributes in the java method. As the processing of the attributes for the interpreter is our code, the bug is likely to be ours, so I'll continue working on it.

2012/10/1 Istvan Rath notifications@github.com

More specifically, the issue can be reproduced with https://github.com/ujhelyiz/EMF-IncQuery-Examples/blob/master/bodymodel/bodymodel.incquery/src/bodymodel/ymca/ymca.eiq, query handsAreClose_buggy

— Reply to this email directly or view it on GitHubhttps://github.com/ujhelyiz/EMF-IncQuery/issues/312#issuecomment-9027207.

istvanrath commented 11 years ago

What is the problem with reflection? Based on the error message (" ... on instance:null"), I suspect that some object is not being passed where it should be.

okrosa commented 11 years ago

Most of it seems right, the attribute value is the correct emf object implementation as it should be. I came up with one more idea during lunch, I'll try it out now.

2012/10/2 Istvan Rath notifications@github.com

What is the problem with reflection? Based on the error message (" ... on instance:null"), I suspect that some object is not being passed where it should be.

— Reply to this email directly or view it on GitHubhttps://github.com/ujhelyiz/EMF-IncQuery/issues/312#issuecomment-9065999.

okrosa commented 11 years ago

The fix of the #346 issue should fix this as well. The bug is still present in the system, but should be unreachable. I set this issue to resolved now.

istvanrath commented 11 years ago

Closing.