Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » [EMFTVM] Exception while loading metamodel
[EMFTVM] Exception while loading metamodel [message #1337070] Tue, 06 May 2014 18:03 Go to next message
Maxim Gromov is currently offline Maxim GromovFriend
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);
			// 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);
				// 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 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 358
Registered: September 2012
Location: Belgium
Senior Member

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.

Re: [EMFTVM] Exception while loading metamodel [message #1349192 is a reply to message #1339227] Mon, 12 May 2014 05:11 Go to previous message
Maxim Gromov is currently offline Maxim GromovFriend
Messages: 7
Registered: May 2014
Junior Member
OK, I see. Thanks for answering!
Previous Topic:[ATL] Translate BPMN models into UML
Next Topic:Using of Sequence as global variable
Goto Forum:

Current Time: Mon May 21 19:06:34 GMT 2018

Powered by FUDForum. Page generated in 0.01889 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top