Strange error with the __xmiID__ field [message #1850240] |
Tue, 22 February 2022 12:54 |
Yves BERNARD Messages: 146 Registered: July 2014 |
Senior Member |
|
|
I'm developing a transformation from UML to a custom Ecore metamodel.
This transformation sets the xmi:id of all the target element using the __xmiID__ special field. However if some input models are transformed as expected, some others (always the same ones) generate the following error on one line where this field is assigned a value:
org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.NoSuchFieldException: Field MM1!ElementX::__xmiID__ not found
Since the very same rules run fine with some models, I don't think that the root cause is actually that this field is not found. Do you have any idea about where it can come from ?
Thanks.
Yves
|
|
|
Re: Strange error with the __xmiID__ field [message #1850280 is a reply to message #1850240] |
Wed, 23 February 2022 17:59 |
|
This is the code from EMFTVM that handles setting the __xmiID__ property:
if (EMFTVMUtil.XMI_ID_FEATURE.equals(propname) && resource instanceof XMIResource) { //$NON-NLS-1$
if (queueSet) {
env.queueXmiIDForSet(eo, v, frame);
} else {
((XMIResource)resource).setID(eo, v.toString());
}
return;
}
throw new NoSuchFieldException(String.format("Field %s::%s not found",
EMFTVMUtil.toPrettyString(type, env), propname));
See:
So the only way __xmiID__ is not found is when the model is not an XMIResource.
Cheers,
Dennis
|
|
|
|
Re: Strange error with the __xmiID__ field [message #1851298 is a reply to message #1851279] |
Fri, 01 April 2022 17:14 |
|
Another situation that may be happening here is that the target element you're trying to set the __xmiID__ on is orphaned at that moment, i.e. it has a null Resource. EMFTVM normally verifies - every time a reference is set - that each element is contained in the Resource of the Model it belongs to, but custom metamodels can break that guarantee by manipulating the EMF containment hierarchy in Java code.
Cheers,
Dennis
|
|
|
|
Powered by
FUDForum. Page generated in 0.01987 seconds