[EMFTVM] Exception while loading metamodel [message #1337070] |
Tue, 06 May 2014 18:03 |
Maxim Gromov Messages: 7 Registered: May 2014 |
Junior Member |
|
|
We have recently fallen into the following problem. While reading metamodel ATL/EMFTVM engine throws an exception:
org.eclipse.m2m.atl.emftvm.util.VMException: Error during module loading: <HERE IS CLASS NAME> cannot be cast to org.eclipse.emf.ecore.EClassifier
The source of this exception is class MetamodelImpl, specifically the following code:
private static void registerTypeChain(
final Map<String, EClassifier> types,
final EList<? extends EObject> objects,
final String ns,
final Set<Object> ignore,
final Set<String> ambiguousTypes) {
for (EObject o : objects) {
switch (o.eClass().getClassifierID()) {
case EcorePackage.EPACKAGE:
String pname = ((EPackage)o).getName();
if (ns != null) {
pname = ns + EMFTVMUtil.NS_DELIM + pname;
}
registerTypeChain(types, o.eContents(), pname, ignore, ambiguousTypes);
break;
// Fix for bug # 423597: switch on all concrete EClassifier sub-types
case EcorePackage.EDATA_TYPE:
case EcorePackage.EENUM:
case EcorePackage.ECLASS:
registerTypeChain(types, (EClassifier)o, ns, ignore, ambiguousTypes);
break;
default:
// No meta-package or meta-class => just keep digging.
// N.B. This situation occurs in UML2 profiles, where
// EPackages containing EClasses are buried somewhere
// underneath other elements.
registerTypeChain(types, o.eContents(), ns, ignore, ambiguousTypes);
}
}
}
More precisely the line
registerTypeChain(types, (EClassifier)o, ns, ignore, ambiguousTypes);
The reason is that at the moment of exception object o is a subclass of EAttribute not of EClass and therefore indeed cannot be casted to EClassifier. You see, we re-define classifier identifiers and some of them coincide with identifiers defined in EcorePackage. For this very example object o has identifier 2, which accidentally coincides with EcorePackage.ECLASS value.
So, the question is, can this method (the above one) be rewritten using notions like
o.eClass() instanceof EClassifier
instead of relying on classifier identifiers or we just have to keep this issue in mind and avoid using identifiers defined in EcorePackage?
|
|
|
Re: [EMFTVM] Exception while loading metamodel [message #1339227 is a reply to message #1337070] |
Wed, 07 May 2014 15:27 |
|
I'm a bit confused as to what you're doing here. Did you extend the Ecore language for the metamodel you're trying to load? If so, any code generated by the EMF code generator should not reuse Classifer IDs from imported metamodels, as this would break the generated code for eSet(), eGet(), etc. The error listed above is just the tip of the iceberg for all the other EMF-related problems you're going to encounter.
Cheers,
Dennis
|
|
|
|
Powered by
FUDForum. Page generated in 0.02040 seconds