Home » Archived » M2M (model-to-model transformation) » [Xtend] Creation of associations (ClassCastException)([Xtend] Creation of associations (ClassCastException))
| | |
Re: [Xtend] Creation of associations (ClassCastException) [message #659576 is a reply to message #659462] |
Mon, 14 March 2011 15:54 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------090300060501080309070109
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Peter,
At this line:
BasicEObjectImpl.java:302
The code is walking the referenced objects
public String eURIFragmentSegment(EStructuralFeature
eStructuralFeature, EObject eObject)
{
if (eStructuralFeature == null)
{
for (@SuppressWarnings("unchecked")
EContentsEList.FeatureIterator<EObject> crossReferences =
(EContentsEList.FeatureIterator<EObject>)((InternalEList<? >)eCrossReferences()).basicIterator();
crossReferences.hasNext(); )
{
EObject crossReference = crossReferences.next();
if (crossReference == eObject)
{
eStructuralFeature = crossReferences.feature();
}
}
}
StringBuilder result = new StringBuilder();
result.append('@');
result.append(eStructuralFeature.getName());
if (eStructuralFeature instanceof EAttribute)
{
All the objects in the eCrossReferences() must be EObjects and they can
only be there by virtue of a EReference or an EAttribute that's a
feature map. So, what's an an EAttribute of type string doing there? If
you use the debugger the walk through the logic, you should be able to
discover that somehow this code is returning a bad list.
public static <T> ECrossReferenceEList<T>
createECrossReferenceEList(EObject eObject)
{
EStructuralFeature [] eStructuralFeatures =
((EClassImpl.FeatureSubsetSupplier)eObject.eClass().getEAllS tructuralFeatures()).crossReferences();
You'll see that in EClassImpl
private void init()
{
BasicEList<EStructuralFeature> containmentsList = new
EStructuralFeatureUniqueEList();
BasicEList<EStructuralFeature> crossReferencesList = new
EStructuralFeatureUniqueEList();
boolean isMixed =
"mixed".equals(EcoreUtil.getAnnotation(EClassImpl.this,
ExtendedMetaData.ANNOTATION_URI, "kind"));
for (int i = 0; i < size; ++i)
{
// Skip derived features.
//
EStructuralFeature eStructuralFeature =
(EStructuralFeature)data[i];
if (eStructuralFeature instanceof EReference)
{
EReference eReference = (EReference)eStructuralFeature;
if (eReference.isContainment())
{
if (!eReference.isDerived())
{
containmentsList.add(eReference);
}
}
else if (!eReference.isContainer())
{
// Include derived relations only if they won't also
come from mixed or a group.
//
if (!eReference.isDerived() ||
!isMixed &&
EcoreUtil.getAnnotation(eReference, ExtendedMetaData.ANNOTATION_URI,
"group") == null)
{
*crossReferencesList*.add(eReference);
}
}
}
else if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
{
if (!eStructuralFeature.isDerived())
{
containmentsList.add(eStructuralFeature);
*crossReferencesList*.add(eStructuralFeature);
}
}
}
It should only be possible that EReferences and EAttributes that are
features maps are in the list of cross references...
In the end, you need to do the analysis...
Peter Sasse wrote:
> Hi Ed,
>
> thank you for your reply. In the last days I tried to figure out, what
> the problem is. May I ask you, when I cannot get a solution (what do
> you need for analysis)?
>
> Thank you & regards,
> Peter
--------------090300060501080309070109
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Peter,<br>
<br>
At this line:<br>
<blockquote>BasicEObjectImpl.java:302<br>
</blockquote>
<small><big>The code is walking the referenced objects </big></small><br>
<blockquote><small><br>
public String eURIFragmentSegment(EStructuralFeature
eStructuralFeature, EObject eObject)<br>
{<br>
if (eStructuralFeature == null)<br>
{<br>
for (@SuppressWarnings("unchecked")
EContentsEList.FeatureIterator<EObject> crossReferences = <br>
(EContentsEList.FeatureIterator<EObject>)((Int ernalEList<?>)eCrossReferences()).basicIterato r();
<br>
crossReferences.hasNext(); )<br>
{<br>
EObject crossReference = crossReferences.next();<br>
if (crossReference == eObject)<br>
{<br>
eStructuralFeature = crossReferences.feature();<br>
}<br>
}<br>
}<br>
<br>
StringBuilder result = new StringBuilder();<br>
result.append('@');<br>
result.append(eStructuralFeature.getName());<br>
<br>
if (eStructuralFeature instanceof EAttribute)<br>
{<br>
</small></blockquote>
All the objects in the eCrossReferences() must be EObjects and they can
only be there by virtue of a EReference or an EAttribute that's a
feature map. So, what's an an EAttribute of type string doing there?
If you use the debugger the walk through the logic, you should be able
to discover that somehow this code is returning a bad list.<br>
<br>
<small> public static <T> ECrossReferenceEList<T>
createECrossReferenceEList(EObject eObject)<br>
{<br>
EStructuralFeature [] eStructuralFeatures = <br>
((EClassImpl.FeatureSubsetSupplier)eObject.eClass().getEAllS tructuralFeatures()).crossReferences(); </small><br>
<br>
You'll see that in EClassImpl<br>
<br>
<blockquote><small> private void init()</small><br>
<small> {</small><br>
<small> BasicEList<EStructuralFeature>
containmentsList = new EStructuralFeatureUniqueEList();</small><br>
<small> BasicEList<EStructuralFeature>
crossReferencesList = new EStructuralFeatureUniqueEList();</small><br>
<small> boolean isMixed =
"mixed".equals(EcoreUtil.getAnnotation(EClassImpl.this,
ExtendedMetaData.ANNOTATION_URI, "kind"));</small><br>
<small> for (int i = 0; i < size; ++i)</small><br>
<small> {</small><br>
<small> // Skip derived features.</small><br>
<small> //</small><br>
<small> EStructuralFeature eStructuralFeature =
(EStructuralFeature)data[i];</small><br>
<small> if (eStructuralFeature instanceof EReference)</small><br>
<small> {</small><br>
<small> EReference eReference =
(EReference)eStructuralFeature;</small><br>
<small> if (eReference.isContainment())</small><br>
<small> {</small><br>
<small> if (!eReference.isDerived())</small><br>
<small> {</small><br>
<small> containmentsList.add(eReference);</small><br>
<small> }</small><br>
<small> }</small><br>
<small> else if (!eReference.isContainer())</small><br>
<small> {</small><br>
<small> // Include derived relations only if they
won't also come from mixed or a group.</small><br>
<small> //</small><br>
<small> if (!eReference.isDerived() || </small><br>
<small> !isMixed &&
EcoreUtil.getAnnotation(eReference, ExtendedMetaData.ANNOTATION_URI,
"group") == null)</small><br>
<small> {</small><br>
<small> <b>crossReferencesList</b>.add(eReference);</small><br>
<small> }</small><br>
<small> }</small><br>
<small> }</small><br>
<small> else if
(FeatureMapUtil.isFeatureMap(eStructuralFeature))</small><br >
<small> {</small><br>
<small> if (!eStructuralFeature.isDerived())</small><br>
<small> {</small><br>
<small> containmentsList.add(eStructuralFeature);</small><br>
<small> <b>crossReferencesList</b>.add(eStructuralFeature);</small ><br>
<small> }</small><br>
<small> }</small><br>
<small> }</small><br>
</blockquote>
It should only be possible that EReferences and EAttributes that are
features maps are in the list of cross references...<br>
<br>
In the end, you need to do the analysis...<br>
<br>
<br>
Peter Sasse wrote:
<blockquote cite="mid:ilkflh$p23$1@news.eclipse.org" type="cite">Hi Ed,
<br>
<br>
thank you for your reply. In the last days I tried to figure out, what
the problem is. May I ask you, when I cannot get a solution (what do
you need for analysis)?
<br>
<br>
Thank you & regards,
<br>
Peter
<br>
</blockquote>
</body>
</html>
--------------090300060501080309070109--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | |
Re: [Xtend] Creation of associations (ClassCastException) [message #660235 is a reply to message #659863] |
Thu, 17 March 2011 14:08 |
Peter Sasse Messages: 5 Registered: March 2011 |
Junior Member |
|
|
Hi Ed,
first regarding your questions:
> Have these models been changing to add features?
> Have a look at what happens in eBasicSetContainer when you add it to the
> containment reference. The feature ID there should be -1 - <the feature
> of the containment reference in the parent class>.
> Are all these classes in the same package or is it possible some are in
> a base package and derived classes in another package need to be
> regenerated?
All mentioned classes are in the same package. But I am using two ecores. One model is from that type used to be read from, one model is from that type used to be read and merged the content of the first model into it. The feature ID of the model (first ecore) is other than -1, the feature IDs of the merged model (second ecore) is equal to -1.
Thus I found the bug, that creating the BatchStream aggregations into BatchNets won't set the object at the opposite role for BatchStream. I saw, that traversing to BatchStream and back to BatchNet returns null. Now explicite setting of the object at the opposite role (BatchNet) inside object of type BatchStream leads to following exception:
...
EvaluationException : The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@4c594c59 (name: BatchNet)...' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@25d625d6 (name: BatchNet) ...'
...
Is above issue related to http://www.openarchitectureware.org/forum/viewtopic.php?foru m=2&showtopic=11530, or is following opposite setting wrong?
create mmBatch::BatchStream createCtmStream(mmCtm::SCHED_GROUP ctmSchedTable, mmBatch::BatchNet net) : ... -> this.setBatchnet(net);
Thank you & kind regards,
Peter
[Updated on: Thu, 17 March 2011 14:09] Report message to a moderator
|
|
|
Re: [Xtend] Creation of associations (ClassCastException) [message #660286 is a reply to message #660235] |
Thu, 17 March 2011 15:35 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------000706030202030905090506
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Peter,
Comments below.
Peter Sasse wrote:
> Hi Ed,
>
> first regarding your questions:
>> Have these models been changing to add features? Have a look at what
>> happens in eBasicSetContainer when you add it to the containment
>> reference. The feature ID there should be -1 - <the feature of the
>> containment reference in the parent class>.
>> Are all these classes in the same package or is it possible some are
>> in a base package and derived classes in another package need to be
>> regenerated?
> All mentioned classes are in the same package. But I am using two ecores.
Hmmm. This sounds fishy.
> One model is from that type used to be read from, one model is from
> that type used to be read and merged the content of the first model
> into it.
Not sure what that means and I'm not sure what you mean by there being
two Ecore in the same package.
> The feature ID of the model (first ecore) is other than -1, the
> feature IDs of the merged model (second ecore) is equal to -1.
Feature IDs are never negative.
The encoding for tracking the container/containment feature is like this:
/**
* The feature ID of this object's container holding feature, if
there is one,
* or {@link #EOPPOSITE_FEATURE_BASE EOPPOSITE_FEATURE_BASE} minus
the feature ID of the container's feature that contains this object.
*/
protected int eContainerFeatureID;
So it sounds to me like there is some inconsistency between the
containment feature IDs you use in the two different cases.
>
> Thus I found the bug, that creating the BatchStream aggregations into
> BatchNets won't set the object at the opposite role for BatchStream.
It's hard for me to imagine how that's possible, but then I have no idea
what you mean by "two Ecore" when you've only described one model...
> I saw, that traversing to BatchStream and back to BatchNet returns
> null. Now explicite setting of the object at the opposite role
> (BatchNet) inside object of type BatchStream leads to following
> exception:
> ..
> EvaluationException : The value of type
> mailto:'org.eclipse.emf.ecore.impl.EClassImpl@4c594c59 (name:
> BatchNet)...' must be of type
> mailto:'org.eclipse.emf.ecore.impl.EClassImpl@25d625d6 (name: BatchNet)
So clearly you have two different versions of the model and you're
mixing up instances of these two as if they should be instances of just
a single model. That's not going to work.
> ...'
> ..
>
> Is above issue related to
> http://www.openarchitectureware.org/forum/viewtopic.php?foru m=2&showtopic=11530,
> or is following opposite setting wrong?
It doesn't sound related.
> create mmBatch::BatchStream createCtmStream(mmCtm::SCHED_GROUP
> ctmSchedTable, mmBatch::BatchNet net) : ... -> this.setBatchnet(net);
>
>
> Thank you & kind regards,
> Peter
--------------000706030202030905090506
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Peter,<br>
<br>
Comments below.<br>
<br>
Peter Sasse wrote:
<blockquote cite="mid:ilt48g$5p1$1@news.eclipse.org" type="cite">Hi Ed,
<br>
<br>
first regarding your questions:
<br>
<blockquote type="cite">Have these models been changing to add
features? Have a look at what happens in eBasicSetContainer when you
add it to the containment reference. The feature ID there should be -1
- <the feature of the containment reference in the parent class>.
<br>
Are all these classes in the same package or is it possible some are in
a base package and derived classes in another package need to be
regenerated?
<br>
</blockquote>
All mentioned classes are in the same package. But I am using two
ecores.</blockquote>
Hmmm. This sounds fishy.<br>
<blockquote cite="mid:ilt48g$5p1$1@news.eclipse.org" type="cite"> One
model is from that type used to be read from, one model is from that
type used to be read and merged the content of the first model into it.</blockquote>
Not sure what that means and I'm not sure what you mean by there being
two Ecore in the same package. <br>
<blockquote cite="mid:ilt48g$5p1$1@news.eclipse.org" type="cite"> The
feature ID of the model (first ecore) is other than -1, the feature IDs
of the merged model (second ecore) is equal to -1.
<br>
</blockquote>
Feature IDs are never negative. <br>
<br>
The encoding for tracking the container/containment feature is like
this:<br>
<blockquote> /**<br>
* The feature ID of this object's container holding feature, if
there is one,<br>
* or {@link #EOPPOSITE_FEATURE_BASE EOPPOSITE_FEATURE_BASE} minus
the feature ID of the container's feature that contains this object.<br>
*/<br>
protected int eContainerFeatureID;<br>
</blockquote>
So it sounds to me like there is some inconsistency between the
containment feature IDs you use in the two different cases.<br>
<blockquote cite="mid:ilt48g$5p1$1@news.eclipse.org" type="cite"><br>
Thus I found the bug, that creating the BatchStream aggregations into
BatchNets won't set the object at the opposite role for BatchStream. </blockquote>
It's hard for me to imagine how that's possible, but then I have no
idea what you mean by "two Ecore" when you've only described one
model...<br>
<blockquote cite="mid:ilt48g$5p1$1@news.eclipse.org" type="cite">I saw,
that traversing to BatchStream and back to BatchNet returns null. Now
explicite setting of the object at the opposite role (BatchNet) inside
object of type BatchStream leads to following exception:
<br>
...
<br>
EvaluationException : The value of type
<a class="moz-txt-link-freetext" href="mailto:'org.eclipse.emf.ecore.impl.EClassImpl@4c594c59">mailto:'org.eclipse.emf.ecore.impl.EClassImpl@4c594c59</a> (name:
BatchNet)...' must be of type
<a class="moz-txt-link-freetext" href="mailto:'org.eclipse.emf.ecore.impl.EClassImpl@25d625d6">mailto:'org.eclipse.emf.ecore.impl.EClassImpl@25d625d6</a> (name: BatchNet)</blockquote>
So clearly you have two different versions of the model and you're
mixing up instances of these two as if they should be instances of just
a single model. That's not going to work.<br>
<blockquote cite="mid:ilt48g$5p1$1@news.eclipse.org" type="cite"> ...'
<br>
...
<br>
<br>
Is above issue related to
<a class="moz-txt-link-freetext" href=" http://www.openarchitectureware.org/forum/viewtopic.php?foru m=2&showtopic=11530"> http://www.openarchitectureware.org/forum/viewtopic.php?foru m=2&showtopic=11530</a>,
or is following opposite setting wrong?
<br>
</blockquote>
It doesn't sound related.<br>
<blockquote cite="mid:ilt48g$5p1$1@news.eclipse.org" type="cite"> create
mmBatch::BatchStream createCtmStream(mmCtm::SCHED_GROUP ctmSchedTable,
mmBatch::BatchNet net) : ... -> this.setBatchnet(net);
<br>
<br>
<br>
Thank you & kind regards,
<br>
Peter
<br>
</blockquote>
</body>
</html>
--------------000706030202030905090506--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Goto Forum:
Current Time: Mon Sep 23 22:39:04 GMT 2024
Powered by FUDForum. Page generated in 0.03596 seconds
|