Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334821 - [ast] Persistent caching of pre-compiled expressions
Summary: [ast] Persistent caching of pre-compiled expressions
Status: CLOSED WONTFIX
Alias: None
Product: OCL
Classification: Modeling
Component: Core (show other bugs)
Version: 3.1.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: OCL Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-19 14:09 EST by Axel Uhl CLA
Modified: 2013-05-20 11:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Axel Uhl CLA 2011-01-19 14:09:30 EST
As a spin-off of https://bugs.eclipse.org/bugs/show_bug.cgi?id=329167 which from now on will only deal with the transient caching of compiled expressions, this bug concerns persistent caching only. Currently, there are two different EAnnotation sources for OCL-related stuff: OCLDelegateDomain.OCL_DELEGATE_URI ("http://www.eclipse.org/emf/2002/Ecore/OCL") and Environment.OCL_NAMESPACE_URI ("http://www.eclipse.org/ocl/1.1.0/OCL"). The former is used to store OCL expressions as strings, the latter is used to store definitions attached to elements such as properties (derivation expression) or operations (body expression). It would be useful to harmonize this.

Suggestion: look up the compiled AST first in the OCLDelegateDomain.OCL_DELEGATE_URI annotation; then, for backward compatibility, keep checking in the old location (Environment.OCL_NAMESPACE_URI) which would be deprecated and removed in some future release.
Comment 1 Axel Uhl CLA 2011-01-20 08:16:25 EST
It may be noted that currently the EcoreEnvironment.getDefinition operation already fetches ASTs from annotations which may be stored durably in an Ecore resource. The missing piece is in particular a persistent storage location for *invariants* used during validation.

Suggestion: store the invariant Constraints objects the same way in an Ecore resource as is used for the operation/property bodies, namely in the contents of an OCL_NAMESPACE_URI annotation.
Comment 2 Ed Willink CLA 2011-01-30 07:39:10 EST
I think that there is a third EAnnotation URI used when a UML model with an OpaqueExpression constraint is exported to Ecore.

The various workers on the Ecore delegates were, I suspect, variously ignorant of, or forgetful of, the pre-existing mechanisms.

It would be good to go through old tutorials and current tools to rediscover the old mechanisms and support them on input. Please document in a wiki page and/or Documentation contribution; list of persistence mechanisms, list of creation tooling, list of consumption tooling.

Since there is currently no AST persistence, it is presumably safe to define any AST in an input model as the master with respect to a conflicting textual representation, so the AST can be stored in the eContents of the OCLDelegateDomain.OCL_DELEGATE_URI EAnnotation that currently has an eAdapter. No need for correlation of eContents and eDetails, the AST should be self-describing and uncorrelated with eDetails.

Since changing the eContents involves a Resource change, I think we load automatically, but require explicit use of a helper function to put the AST in the persistent eContents and/or trash the eContents in favour of a text string.

[This problem goes away in the Pivot model where a Constraint has a specification which may be an OpaqueExpression containing a multi-lingual set of expression strings, or an ExpressionInOcl containing the AST. However when saving the Pivot as Ecore, the above policy should work fine.]
Comment 3 Ed Willink CLA 2011-03-14 16:29:51 EDT
Axel: I think this is resolved.
Comment 4 Axel Uhl CLA 2011-03-14 18:06:53 EDT
(In reply to comment #3)
> Axel: I think this is resolved.

You mean by means of the Pivot model?
Comment 5 Ed Willink CLA 2011-03-15 02:31:15 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > Axel: I think this is resolved.
> 
> You mean by means of the Pivot model?

Sorry. Not reading the title. PERSISTENT.
Comment 6 Ed Willink CLA 2011-11-07 16:59:09 EST
Caching run-time compilation is obsoleted by the availability of compile-time code generation of direct Java.
Comment 7 Axel Uhl CLA 2011-11-08 03:26:42 EST
Quick question: where does Java code get generated if I don't genmodel? I doubt that Java code generation is a full replacement for persistently caching the OCL AST in the Ecore model.
Comment 8 Ed Willink CLA 2011-11-08 03:54:08 EST
There is no on the fly Java Code Generation so dynamic EMF OCL is interpreted.

I assumed that anyone concerned about performance would genmodel.

If you have a use case for significant dynamic EMF OCL, either reopen this bug, to support caching, or open a new bug to support JIT code generation.

JIT code generation shouldn't be that hard, but it probably needs Java 6 to provide a friendly interface to the Java compiler and Java 7 to make a ClassLoader reload easily.
Comment 9 Ed Willink CLA 2013-05-20 11:37:33 EDT
CLOSED after a year in the RESOLVED state.