Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[] multiple instances of oclstdlib

I’m having problem figuring out the root cause of this issue. Any pointers are appreciated.

First, the problem is that I have a .mtl template with a conditional that checks whether a String is empty:

[if (path <> null) and (path.size() > 0)]

The exception is:

org.eclipse.acceleo.engine.AcceleoEvaluationException: Undefined condition of "If" at line 37 in Module CppIncludeUtils
for block if (path.<>(null).and(path.size().>(0))). Last recorded value of self was
     at CppIncludeUtils.IncludeDirective(String)(CppIncludeUtils.mtl:37)
     at CppIncludeUtils.IncludeDirective(String)(CppIncludeUtils.mtl:36)
     at CppPackageHeader.CppPackageHeader(Package)(CppPackageHeader.mtl:0)
     at CppPackageHeader.CppPackageHeader(Package)(CppPackageHeader.mtl:15)

And it happens because the OCL evaluation of path.size() returns false. This happens because there are two copies of the ocl String type loaded. Starting at line 555 of EvaluationVisitorImpl (in org.eclipse.ocl):

    case PredefinedType.SIZE:
        if (sourceType == getString()) {
            // String::size()
            return new Integer(((String) sourceVal).length());
        } else if (sourceType instanceof CollectionType<?, ?>) {
            return new Integer(((Collection<?>) sourceVal).size());

I’ve found that sourceType and the result of getString() are different instances. The first comes from loading the ecore file at org.eclipse.ocl/plugins/org.eclipse.ocl.ecore/model/oclstdlib.ecore the second comes from the in-memory model

I’m guessing that the first instance should not have been loaded from the file. It comes from Acceleo’s loading of my .emtl file. The header has xmlns:ocl.ecore=”“ and this loads the file instead of using OCLStandardLibraryImpl.INSTANCE.

If that guess is right, then how do I make that happen?


Back to the top